Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
d74af1f6
Commit
d74af1f6
authored
12 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
redirect stdio to DOS console on windows
parent
8d32f8e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/Gmsh.cpp
+4
-0
4 additions, 0 deletions
Common/Gmsh.cpp
Common/OS.cpp
+33
-2
33 additions, 2 deletions
Common/OS.cpp
Common/OS.h
+1
-0
1 addition, 0 deletions
Common/OS.h
with
38 additions
and
2 deletions
Common/Gmsh.cpp
+
4
−
0
View file @
d74af1f6
...
@@ -45,6 +45,10 @@
...
@@ -45,6 +45,10 @@
int
GmshInitialize
(
int
argc
,
char
**
argv
)
int
GmshInitialize
(
int
argc
,
char
**
argv
)
{
{
#if defined(HAVE_FLTK)
RedirectIOToConsole
();
#endif
// we need at least one model during option parsing
// we need at least one model during option parsing
GModel
*
dummy
=
0
;
GModel
*
dummy
=
0
;
if
(
GModel
::
list
.
empty
())
dummy
=
new
GModel
();
if
(
GModel
::
list
.
empty
())
dummy
=
new
GModel
();
...
...
This diff is collapsed.
Click to expand it.
Common/OS.cpp
+
33
−
2
View file @
d74af1f6
...
@@ -26,6 +26,10 @@
...
@@ -26,6 +26,10 @@
#include
<process.h>
#include
<process.h>
#include
<io.h>
#include
<io.h>
#include
<direct.h>
#include
<direct.h>
#include
<fcntl.h>
#include
<io.h>
#include
<iostream>
#include
<fstream>
#endif
#endif
#if defined(__APPLE__)
#if defined(__APPLE__)
...
@@ -238,8 +242,8 @@ std::string getCurrentWorkdir()
...
@@ -238,8 +242,8 @@ std::string getCurrentWorkdir()
if
(
!
getcwd
(
path
,
sizeof
(
path
)))
return
""
;
if
(
!
getcwd
(
path
,
sizeof
(
path
)))
return
""
;
#endif
#endif
std
::
string
str
(
path
);
std
::
string
str
(
path
);
// match the convention of SplitFileName that delivers directory path
endig
// match the convention of SplitFileName that delivers directory path
// with a directory separator
//
ending
with a directory separator
#if defined(WIN32)
#if defined(WIN32)
str
.
append
(
"
\\
"
);
str
.
append
(
"
\\
"
);
#else
#else
...
@@ -247,3 +251,30 @@ std::string getCurrentWorkdir()
...
@@ -247,3 +251,30 @@ std::string getCurrentWorkdir()
#endif
#endif
return
str
;
return
str
;
}
}
void
RedirectIOToConsole
()
{
#if defined(WIN32) && !defined(__CYGWIN__)
// Win32 GUI apps do not write to the DOS console; make it work again by
// attaching to parent console, which allows to use the DOS shell to work
// with Gmsh on the command line (without this hack, you need to either use
// a better shell (e.g. bash), or compile a /subsystem:console version
AttachConsole
(
ATTACH_PARENT_PROCESS
);
// redirect unbuffered stdout, stdin and stderr to the console
intptr_t
lStdHandle
=
(
intptr_t
)
GetStdHandle
(
STD_OUTPUT_HANDLE
);
int
hConHandle
=
_open_osfhandle
(
lStdHandle
,
_O_TEXT
);
*
stdout
=
_fdopen
(
hConHandle
,
"w"
);
setvbuf
(
stdout
,
NULL
,
_IONBF
,
0
);
lStdHandle
=
(
intptr_t
)
GetStdHandle
(
STD_INPUT_HANDLE
);
hConHandle
=
_open_osfhandle
(
lStdHandle
,
_O_TEXT
);
*
stdin
=
_fdopen
(
hConHandle
,
"r"
);
setvbuf
(
stdin
,
NULL
,
_IONBF
,
0
);
lStdHandle
=
(
intptr_t
)
GetStdHandle
(
STD_ERROR_HANDLE
);
hConHandle
=
_open_osfhandle
(
lStdHandle
,
_O_TEXT
);
*
stderr
=
_fdopen
(
hConHandle
,
"w"
);
setvbuf
(
stderr
,
NULL
,
_IONBF
,
0
);
// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to
// console as well
std
::
ios
::
sync_with_stdio
();
#endif
}
This diff is collapsed.
Click to expand it.
Common/OS.h
+
1
−
0
View file @
d74af1f6
...
@@ -22,5 +22,6 @@ int KillProcess(int pid);
...
@@ -22,5 +22,6 @@ int KillProcess(int pid);
int
CreateDirectory
(
const
std
::
string
&
dirName
);
int
CreateDirectory
(
const
std
::
string
&
dirName
);
int
SystemCall
(
const
std
::
string
&
command
,
bool
blocking
=
false
);
int
SystemCall
(
const
std
::
string
&
command
,
bool
blocking
=
false
);
std
::
string
getCurrentWorkdir
();
std
::
string
getCurrentWorkdir
();
void
RedirectIOToConsole
();
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment