Remove console designate null view/buffer as console
This commit is contained in:
@@ -81,14 +81,6 @@ void ToggleFullscreen() {
|
|||||||
IsInFullscreen = !IsInFullscreen;
|
IsInFullscreen = !IsInFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToggleConsole() {
|
|
||||||
if (ToggleVisibility(ConsoleWindowID)) {
|
|
||||||
SetActiveWindow(ConsoleWindowID);
|
|
||||||
} else {
|
|
||||||
SetActiveWindow(GetLastActiveWindow());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckpointBeforeGoto(WindowID window_id, ViewID view_id) {
|
void CheckpointBeforeGoto(WindowID window_id, ViewID view_id) {
|
||||||
Window *window = GetWindow(window_id);
|
Window *window = GetWindow(window_id);
|
||||||
View *view = GetView(view_id);
|
View *view = GetView(view_id);
|
||||||
@@ -427,10 +419,6 @@ bool GlobalCommand(Event event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ctrl(SDLK_GRAVE)) {
|
|
||||||
ToggleConsole();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CtrlShift(SDLK_BACKSLASH)) {
|
if (CtrlShift(SDLK_BACKSLASH)) {
|
||||||
AddRowWindow();
|
AddRowWindow();
|
||||||
} else if (Ctrl(SDLK_BACKSLASH)) {
|
} else if (Ctrl(SDLK_BACKSLASH)) {
|
||||||
@@ -469,15 +457,6 @@ bool GlobalCommand(Event event) {
|
|||||||
return run_window_command;
|
return run_window_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
View *FindView(BufferID buffer_id) {
|
|
||||||
For(Views) {
|
|
||||||
if (it.active_buffer == buffer_id) {
|
|
||||||
return ⁢
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Command_Append(ViewID view_id, String16 string, bool scroll_to_end_if_cursor_on_last_line) {
|
void Command_Append(ViewID view_id, String16 string, bool scroll_to_end_if_cursor_on_last_line) {
|
||||||
View *view = GetView(view_id);
|
View *view = GetView(view_id);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
@@ -516,19 +495,25 @@ 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);
|
||||||
Command_Append(ConsoleViewID, string, true);
|
Command_Append(NullViewID, string, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportConsolef(const char *fmt, ...) {
|
void ReportConsolef(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
Command_Append(ConsoleViewID, string, true);
|
Command_Append(NullViewID, string, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportWarningf(const char *fmt, ...) {
|
void ReportWarningf(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
Command_Append(ConsoleViewID, string, true);
|
Command_Append(NullViewID, string, true);
|
||||||
SetVisibility(ConsoleWindowID, true);
|
Window *window = GetWindowWithView(NullViewID);
|
||||||
SetActiveWindow(ConsoleWindowID);
|
if (!window) {
|
||||||
|
WindowID last_active_window_id = GetLastActiveWindow();
|
||||||
|
window = GetWindow(last_active_window_id);
|
||||||
|
}
|
||||||
|
CheckpointBeforeGoto(window->id);
|
||||||
|
window->active_view = NullViewID;
|
||||||
|
SetActiveWindow(window->id);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ int Lua_AppendCmd(lua_State *L) {
|
|||||||
String string = lua_tostring(L, 1);
|
String string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
String working_dir = GetCurrentBufferDir();
|
String working_dir = GetCurrentBufferDir();
|
||||||
Exec(ConsoleViewID, true, string, working_dir);
|
Exec(NullViewID, true, string, working_dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ int Lua_Print(lua_State *L) {
|
|||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String string = lua_tostring(L, 1);
|
String string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
Command_Append(ConsoleViewID, string, true);
|
Command_Append(NullViewID, string, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +161,6 @@ int Lua_ListBuffers(lua_State *L) {
|
|||||||
Command_SelectEntireBuffer(view);
|
Command_SelectEntireBuffer(view);
|
||||||
Command_Replace(view, string16);
|
Command_Replace(view, string16);
|
||||||
Command_SelectRangeOneCursor(view, {});
|
Command_SelectRangeOneCursor(view, {});
|
||||||
Command_Replace(view, L"\n");
|
|
||||||
Command_SelectRangeOneCursor(view, {});
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ Array<Window> Windows = {};
|
|||||||
WindowID NullWindowID;
|
WindowID NullWindowID;
|
||||||
BufferID NullBufferID;
|
BufferID NullBufferID;
|
||||||
ViewID NullViewID;
|
ViewID NullViewID;
|
||||||
WindowID DebugWindowID;
|
|
||||||
WindowID ConsoleWindowID;
|
|
||||||
|
|
||||||
ViewID ConsoleViewID;
|
WindowID DebugWindowID;
|
||||||
BufferID DebugBufferID;
|
BufferID DebugBufferID;
|
||||||
|
|
||||||
// @note:
|
// @note:
|
||||||
@@ -137,6 +135,15 @@ void SetActiveWindow(WindowID window) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View *FindView(BufferID buffer_id) {
|
||||||
|
For(Views) {
|
||||||
|
if (it.active_buffer == buffer_id) {
|
||||||
|
return ⁢
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Window *GetWindowWithView(ViewID view_id) {
|
Window *GetWindowWithView(ViewID view_id) {
|
||||||
ForItem(window, Windows) {
|
ForItem(window, Windows) {
|
||||||
if (window.active_view.id == view_id.id) {
|
if (window.active_view.id == view_id.id) {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ String BuffCWD(String string) {
|
|||||||
|
|
||||||
void InitScratchBuffer() {
|
void InitScratchBuffer() {
|
||||||
Allocator sys_allocator = GetSystemAllocator();
|
Allocator sys_allocator = GetSystemAllocator();
|
||||||
Buffer *null_buffer = CreateBuffer(sys_allocator, BuffCWD("+scratch"));
|
Buffer *null_buffer = CreateBuffer(sys_allocator, BuffCWD("+console"));
|
||||||
View *null_view = CreateView(null_buffer->id);
|
View *null_view = CreateView(null_buffer->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,27 +147,6 @@ void InitWindows() {
|
|||||||
CreateTitlebar(window_id);
|
CreateTitlebar(window_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
Window *window = CreateWindow();
|
|
||||||
WindowID window_id = window->id;
|
|
||||||
ConsoleWindowID = window_id;
|
|
||||||
|
|
||||||
window->invisible_when_inactive = true;
|
|
||||||
window->deactivate_on_escape = true;
|
|
||||||
window->absolute_position = true;
|
|
||||||
window->dont_save_in_active_window_history = true;
|
|
||||||
|
|
||||||
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("+console"));
|
|
||||||
// buffer->no_history = true;
|
|
||||||
|
|
||||||
View *view = CreateView(buffer->id);
|
|
||||||
ConsoleViewID = view->id;
|
|
||||||
window->active_view = view->id;
|
|
||||||
|
|
||||||
CreateTitlebar(window_id);
|
|
||||||
SetVisibility(window_id, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Window *window = CreateWindow();
|
Window *window = CreateWindow();
|
||||||
WindowID window_id = window->id;
|
WindowID window_id = window->id;
|
||||||
@@ -202,22 +181,6 @@ void LayoutWindows() {
|
|||||||
float line_numbers_size = (float)FontCharSpacing * 10;
|
float line_numbers_size = (float)FontCharSpacing * 10;
|
||||||
float sizex = (float)GetSize(screen_rect).x;
|
float sizex = (float)GetSize(screen_rect).x;
|
||||||
|
|
||||||
{
|
|
||||||
Window *window = GetWindow(ConsoleWindowID);
|
|
||||||
if (window->visible) {
|
|
||||||
Vec2I size = GetSize(screen_rect);
|
|
||||||
window->total_rect = CutBottom(&screen_rect, (Int)((float)size.y * 0.5f));
|
|
||||||
|
|
||||||
Window *title_bar_window = GetWindow(window->title_bar_window);
|
|
||||||
title_bar_window->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window));
|
|
||||||
title_bar_window->document_rect = title_bar_window->total_rect;
|
|
||||||
|
|
||||||
window->document_rect = window->total_rect;
|
|
||||||
if (window->draw_scrollbar) window->scrollbar_rect = CutRight(&window->document_rect, (Int)ScrollBarSize);
|
|
||||||
if (window->draw_line_numbers) window->line_numbers_rect = CutLeft(&window->document_rect, (Int)line_numbers_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Array<VisualColumn> columns = GetVisualColumns(scratch);
|
Array<VisualColumn> columns = GetVisualColumns(scratch);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user