Append to end of console
This commit is contained in:
@@ -382,35 +382,36 @@ bool GlobalCommand(Event event) {
|
|||||||
return run_window_command;
|
return run_window_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppendToConsole(String16 string) {
|
||||||
|
Buffer *buffer = GetBuffer("*console*");
|
||||||
|
ReplaceText(buffer, GetEndAsRange(*buffer), string);
|
||||||
|
ReplaceText(buffer, GetEndAsRange(*buffer), L"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppendToConsole(String string) {
|
||||||
|
Scratch scratch;
|
||||||
|
String16 string16 = ToString16(scratch, string);
|
||||||
|
AppendToConsole(string16);
|
||||||
|
}
|
||||||
|
|
||||||
void ReportErrorf(const char *fmt, ...) {
|
void ReportErrorf(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error!", string.data, NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error!", string.data, NULL);
|
||||||
|
AppendToConsole(string);
|
||||||
Buffer *buffer = GetBuffer("*console*");
|
|
||||||
String16 string16 = ToString16(scratch, string);
|
|
||||||
ReplaceText(buffer, {}, string16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportConsolef(const char *fmt, ...) {
|
void ReportConsolef(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
String16 string16 = ToString16(scratch, string);
|
AppendToConsole(string);
|
||||||
Buffer *buffer = GetBuffer("*console*");
|
|
||||||
ReplaceText(buffer, {}, string16);
|
|
||||||
ReplaceText(buffer, Rng(string16.len), L"\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportWarningf(const char *fmt, ...) {
|
void ReportWarningf(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
String16 string16 = ToString16(scratch, string);
|
String16 string16 = ToString16(scratch, string);
|
||||||
|
AppendToConsole(string16);
|
||||||
{
|
|
||||||
Buffer *buffer = GetBuffer("*console*");
|
|
||||||
ReplaceText(buffer, {}, string16);
|
|
||||||
ReplaceText(buffer, Rng(string16.len), L"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Buffer *buffer = GetBuffer("*popup*");
|
Buffer *buffer = GetBuffer("*popup*");
|
||||||
|
|||||||
@@ -626,12 +626,12 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ctrl(SDLK_S) && buffer->dirty) {
|
if (Ctrl(SDLK_S)) {
|
||||||
String16 string16 = GetString(*buffer);
|
String16 string16 = GetString(*buffer);
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String string = ToString(scratch, string16);
|
String string = ToString(scratch, string16);
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (!StartsWith(string, "*")) success = WriteFile(buffer->name, string);
|
success = WriteFile(buffer->name, string);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
buffer->dirty = false;
|
buffer->dirty = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user