Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
ccd96bb4
Commit
ccd96bb4
authored
Feb 15, 2011
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added --export command line flag for using export templates, --export-image now export images
parent
57ea6d26
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
67 deletions
+112
-67
src/cli/cli_main.cpp
src/cli/cli_main.cpp
+2
-10
src/cli/cli_main.hpp
src/cli/cli_main.hpp
+0
-1
src/cli/text_io_handler.cpp
src/cli/text_io_handler.cpp
+20
-5
src/cli/text_io_handler.hpp
src/cli/text_io_handler.hpp
+1
-0
src/cli/win32_cli_wrapper.cpp
src/cli/win32_cli_wrapper.cpp
+20
-2
src/main.cpp
src/main.cpp
+69
-49
No files found.
src/cli/cli_main.cpp
View file @
ccd96bb4
...
...
@@ -34,7 +34,7 @@ CLISetInterface::CLISetInterface(const SetP& set, bool quiet)
setSet
(
set
);
// show welcome logo
if
(
!
quiet
)
showWelcome
();
print_pending_errors
();
cli
.
print_pending_errors
();
}
CLISetInterface
::~
CLISetInterface
()
{
...
...
@@ -90,7 +90,7 @@ void CLISetInterface::run_interactive() {
String
command
=
cli
.
getLine
();
if
(
command
.
empty
()
&&
!
cli
.
canGetLine
())
break
;
handleCommand
(
command
);
print_pending_errors
();
cli
.
print_pending_errors
();
cli
.
flush
();
cli
.
flushRaw
();
}
...
...
@@ -272,11 +272,3 @@ void CLISetInterface::handleCommand(const String& command) {
}
}
#endif
void
CLISetInterface
::
print_pending_errors
()
{
MessageType
type
;
String
msg
;
while
(
get_queued_message
(
type
,
msg
))
{
cli
.
show_message
(
type
,
msg
);
}
}
src/cli/cli_main.hpp
View file @
ccd96bb4
...
...
@@ -40,7 +40,6 @@ class CLISetInterface : public SetView {
#if USE_SCRIPT_PROFILING
void
showProfilingStats
(
const
FunctionProfile
&
parent
,
int
level
=
0
);
#endif
void
print_pending_errors
();
/// our own context, when no set is loaded
Context
&
getContext
();
...
...
src/cli/text_io_handler.cpp
View file @
ccd96bb4
...
...
@@ -55,7 +55,7 @@ void TextIOHandler::init() {
have_console
=
false
;
have_stderr
=
false
;
// Use console mode if one of the cli flags is passed
static
const
Char
*
redirect_flags
[]
=
{
_
(
"-?"
),
_
(
"--help"
),
_
(
"-v"
),
_
(
"--version"
),
_
(
"--cli"
),
_
(
"-c"
),
_
(
"--export"
),
_
(
"--create-installer"
)};
static
const
Char
*
redirect_flags
[]
=
{
_
(
"-?"
),
_
(
"--help"
),
_
(
"-v"
),
_
(
"--version"
),
_
(
"--cli"
),
_
(
"-c"
),
_
(
"--export"
),
_
(
"--
export-images"
),
_
(
"--
create-installer"
)};
for
(
int
i
=
1
;
i
<
wxTheApp
->
argc
;
++
i
)
{
for
(
int
j
=
0
;
j
<
sizeof
(
redirect_flags
)
/
sizeof
(
redirect_flags
[
0
])
;
++
j
)
{
if
(
String
(
wxTheApp
->
argv
[
i
])
==
redirect_flags
[
j
])
{
...
...
@@ -152,12 +152,12 @@ void TextIOHandler::flushRaw() {
if
(
!
buffer
.
empty
())
{
#ifdef UNICODE
wxCharBuffer
buf
=
buffer
.
mb_str
(
wxConvUTF8
);
fputs
(
buf
,
st
dout
);
fputs
(
buf
,
st
ream
);
#else
fputs
(
buffer
.
c_str
(),
st
dout
);
fputs
(
buffer
.
c_str
(),
st
ream
);
#endif
}
fflush
(
st
dout
);
fflush
(
st
ream
);
// clear
buffer
.
clear
();
raw_mode_status
=
0
;
...
...
@@ -166,7 +166,8 @@ void TextIOHandler::flushRaw() {
// ----------------------------------------------------------------------------- : Errors
void
TextIOHandler
::
show_message
(
MessageType
type
,
String
const
&
message
)
{
stream
=
stdout
;
flush
();
stream
=
stderr
;
if
(
type
==
MESSAGE_WARNING
)
{
*
this
<<
YELLOW
<<
_
(
"WARNING: "
)
<<
NORMAL
<<
replace_all
(
message
,
_
(
"
\n
"
),
_
(
"
\n
"
))
<<
ENDL
;
}
else
{
...
...
@@ -176,3 +177,17 @@ void TextIOHandler::show_message(MessageType type, String const& message) {
stream
=
stdout
;
if
(
raw_mode
)
raw_mode_status
=
max
(
raw_mode_status
,
type
==
MESSAGE_WARNING
?
1
:
2
);
}
void
TextIOHandler
::
print_pending_errors
()
{
MessageType
type
;
String
msg
;
while
(
get_queued_message
(
type
,
msg
))
{
if
(
haveConsole
())
{
cli
.
show_message
(
type
,
msg
);
cli
.
flush
();
}
else
{
// no console, use a messagebox instead
wxMessageBox
(
msg
,
wxMessageBoxCaptionStr
,
type
==
MESSAGE_INFO
?
wxICON_INFORMATION
:
type
==
MESSAGE_WARNING
?
wxICON_WARNING
:
wxICON_ERROR
);
}
}
}
src/cli/text_io_handler.hpp
View file @
ccd96bb4
...
...
@@ -38,6 +38,7 @@ class TextIOHandler {
/// Show an error or warning message
void
show_message
(
MessageType
type
,
String
const
&
message
);
void
print_pending_errors
();
/// Enable raw mode
void
enableRaw
();
...
...
src/cli/win32_cli_wrapper.cpp
View file @
ccd96bb4
...
...
@@ -45,6 +45,7 @@ DWORD WINAPI TransferThread(Transfer*);
BOOL
WINAPI
HandleCtrlEvent
(
DWORD
type
);
void
CopyFileBuffer
(
HANDLE
output
,
char
*
buffer
,
DWORD
size
);
void
InitEscapeTranslation
(
HANDLE
console
);
void
FinishEscapeTranslation
(
HANDLE
console
);
void
PerformEscapeCode
(
HANDLE
console
,
char
command
,
int
argc
,
int
argv
[]);
/// The child process
...
...
@@ -54,14 +55,15 @@ PROCESS_INFORMATION child_process_info;
HANDLE
in_mine
,
in_theirs
,
in_real
;
HANDLE
out_mine
,
out_theirs
,
out_real
;
HANDLE
err_mine
,
err_theirs
,
err_real
;
bool
need_redirection
;
// ----------------------------------------------------------------------------- : Main function
const
char
*
redirect_flags
[]
=
{
"-?"
,
"
--help"
,
"-v"
,
"--version"
,
"--cli"
,
"-c"
,
"--export
"
,
"--create-installer"
};
const
char
*
redirect_flags
[]
=
{
"-?"
,
"
/?"
,
"--help"
,
"-v"
,
"--version"
,
"--cli"
,
"-c"
,
"--export"
,
"--export-images
"
,
"--create-installer"
};
int
main
(
int
argc
,
char
**
argv
)
{
// determine whether we need to wrap console i/o
bool
need_redirection
=
false
;
need_redirection
=
false
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
for
(
int
j
=
0
;
j
<
sizeof
(
redirect_flags
)
/
sizeof
(
redirect_flags
[
0
])
;
++
j
)
{
if
(
strcmp
(
argv
[
i
],
redirect_flags
[
j
])
==
0
)
{
...
...
@@ -115,6 +117,7 @@ int main(int argc, char** argv) {
out_real
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
err_real
=
GetStdHandle
(
STD_ERROR_HANDLE
);
InitEscapeTranslation
(
out_real
);
InitEscapeTranslation
(
err_real
);
// start threads
Transfer
tranfer_in
=
{
in_real
,
in_mine
,
false
};
...
...
@@ -134,6 +137,7 @@ int main(int argc, char** argv) {
// start the child program
if
(
!
CreateProcess
(
app_path
,
command_line
,
NULL
,
NULL
,
TRUE
,
0
,
NULL
,
NULL
,
&
child_startup_info
,
&
child_process_info
))
{
fprintf
(
stderr
,
"Unable to start child process.
\n
"
);
ExitProcess
(
1
);
}
...
...
@@ -146,6 +150,10 @@ int main(int argc, char** argv) {
}
// That's all folks!
if
(
need_redirection
)
{
FinishEscapeTranslation
(
out_real
);
FinishEscapeTranslation
(
err_real
);
}
return
exit_code
;
}
...
...
@@ -168,6 +176,10 @@ BOOL WINAPI HandleCtrlEvent(DWORD type) {
TerminateProcess
(
child_process_info
.
hProcess
,
1
);
}
// exit this process
if
(
need_redirection
)
{
FinishEscapeTranslation
(
out_real
);
FinishEscapeTranslation
(
err_real
);
}
ExitProcess
(
exit_code
);
return
TRUE
;
}
...
...
@@ -251,6 +263,12 @@ void InitEscapeTranslation(HANDLE console) {
original_attributes
=
screen_buffer
.
wAttributes
;
}
/// Cleanup for escape translation: put things back to normal
void
FinishEscapeTranslation
(
HANDLE
console
)
{
CONSOLE_SCREEN_BUFFER_INFO
screen_buffer
;
SetConsoleTextAttribute
(
console
,
original_attributes
);
}
/// Perform an escape code
void
PerformEscapeCode
(
HANDLE
console
,
char
command
,
int
argc
,
int
argv
[])
{
switch
(
command
)
{
...
...
src/main.cpp
View file @
ccd96bb4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment