Refactoring Command_s, NextWindowID
This commit is contained in:
@@ -68,13 +68,13 @@ void JumpGarbageBuffer(BSet *set, String buffer_name = "") {
|
|||||||
set->buffer->garbage = true;
|
set->buffer->garbage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_BeginJump(BSet *set, BufferID buffer_id = NullBufferID) {
|
void BeginJump(BSet *set, BufferID buffer_id = NullBufferID) {
|
||||||
CheckpointBeforeGoto(set->window);
|
CheckpointBeforeGoto(set->window);
|
||||||
set->buffer = GetBuffer(buffer_id);
|
set->buffer = GetBuffer(buffer_id);
|
||||||
set->view = WindowOpenBufferView(set->window, set->buffer->name);
|
set->view = WindowOpenBufferView(set->window, set->buffer->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_EndJump(BSet set) {
|
void EndJump(BSet set) {
|
||||||
Int pos = XYToPos(set.buffer, {0, set.buffer->line_starts.len - 1});
|
Int pos = XYToPos(set.buffer, {0, set.buffer->line_starts.len - 1});
|
||||||
set.view->carets[0] = MakeCaret(pos);
|
set.view->carets[0] = MakeCaret(pos);
|
||||||
UpdateScroll(set.window, true);
|
UpdateScroll(set.window, true);
|
||||||
@@ -100,7 +100,7 @@ Int ScreenSpaceToBufferPosErrorOutOfBounds(Window *window, View *view, Buffer *b
|
|||||||
|
|
||||||
void MouseLoadWord(Event event, String meta = "") {
|
void MouseLoadWord(Event event, String meta = "") {
|
||||||
Vec2I mouse = MouseVec2I();
|
Vec2I mouse = MouseVec2I();
|
||||||
BSet active = GetActiveSet();
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
|
|
||||||
bool mouse_in_document = AreOverlapping(mouse, active.window->document_rect);
|
bool mouse_in_document = AreOverlapping(mouse, active.window->document_rect);
|
||||||
if (mouse_in_document) {
|
if (mouse_in_document) {
|
||||||
@@ -123,13 +123,12 @@ View *GetViewForFixingWhenBufferCommand(Buffer *buffer, bool *is_active = NULL)
|
|||||||
*is_active = false;
|
*is_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window *active_window = GetWindow(ActiveWindow);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
View *active_view = GetView(active_window->active_view);
|
if (active.buffer->id == buffer->id) {
|
||||||
if (active_view->active_buffer == buffer->id) {
|
|
||||||
if (is_active) {
|
if (is_active) {
|
||||||
*is_active = true;
|
*is_active = true;
|
||||||
}
|
}
|
||||||
return active_view;
|
return active.view;
|
||||||
}
|
}
|
||||||
|
|
||||||
For(Views) {
|
For(Views) {
|
||||||
@@ -152,15 +151,15 @@ void ReplaceWithoutMovingCarets(Buffer *buffer, Range range, String16 string) {
|
|||||||
Array<Caret> carets = Copy(GetSystemAllocator(), view->carets);
|
Array<Caret> carets = Copy(GetSystemAllocator(), view->carets);
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Command_SelectRangeOneCursor(view, range);
|
SelectRange(view, range);
|
||||||
Command_ReplaceEx(scratch, view, string);
|
ReplaceEx(scratch, view, string);
|
||||||
|
|
||||||
Dealloc(&view->carets);
|
Dealloc(&view->carets);
|
||||||
view->carets = carets;
|
view->carets = carets;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo: revamp interface since it scrolls ALL VIEWS??? or maybe not??
|
// @todo: revamp interface since it scrolls ALL VIEWS??? or maybe not??
|
||||||
void Command_Append(View *view, String16 string, bool scroll_to_end_if_cursor_on_last_line) {
|
void Append(View *view, String16 string, bool scroll_to_end_if_cursor_on_last_line) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
|
||||||
@@ -191,8 +190,8 @@ void Command_Append(View *view, String16 string, bool scroll_to_end_if_cursor_on
|
|||||||
Add(&view_info, vi);
|
Add(&view_info, vi);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command_SelectRangeOneCursor(view, GetBufferEndAsRange(buffer));
|
SelectRange(view, GetBufferEndAsRange(buffer));
|
||||||
Command_Replace(view, string);
|
Replace(view, string);
|
||||||
|
|
||||||
For (view_info) {
|
For (view_info) {
|
||||||
if (it.scroll_to_end) {
|
if (it.scroll_to_end) {
|
||||||
@@ -204,16 +203,16 @@ void Command_Append(View *view, String16 string, bool scroll_to_end_if_cursor_on
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_Append(View *view, String string, bool scroll_to_end_if_cursor_on_last_line) {
|
void Append(View *view, String string, bool scroll_to_end_if_cursor_on_last_line) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String16 string16 = ToString16(scratch, string);
|
String16 string16 = ToString16(scratch, string);
|
||||||
Command_Append(view, string16, scroll_to_end_if_cursor_on_last_line);
|
Append(view, string16, scroll_to_end_if_cursor_on_last_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_Appendf(View *view, const char *fmt, ...) {
|
void Appendf(View *view, const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
Command_Append(view, string, true);
|
Append(view, string, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportErrorf(const char *fmt, ...) {
|
void ReportErrorf(const char *fmt, ...) {
|
||||||
@@ -222,8 +221,8 @@ void ReportErrorf(const char *fmt, ...) {
|
|||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error!", string.data, NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error!", string.data, NULL);
|
||||||
View *view = GetView(NullViewID);
|
View *view = GetView(NullViewID);
|
||||||
if (view) {
|
if (view) {
|
||||||
Command_Appendf(view, "%S\n", string);
|
Appendf(view, "%S\n", string);
|
||||||
ActiveWindow = NullWindowID;
|
NextActiveWindowID = NullWindowID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,23 +230,23 @@ void ReportConsolef(const char *fmt, ...) {
|
|||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
View *view = GetView(NullViewID);
|
View *view = GetView(NullViewID);
|
||||||
Command_Appendf(view, "%S\n", string);
|
Appendf(view, "%S\n", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportWarningf(const char *fmt, ...) {
|
void ReportWarningf(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
View *null_view = GetView(NullViewID);
|
View *null_view = GetView(NullViewID);
|
||||||
Command_Appendf(null_view, "%S\n", string);
|
Appendf(null_view, "%S\n", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDebugf(const char *fmt, ...) {
|
void ReportDebugf(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
Command_Appendf(TraceView, "%S\n", string);
|
Appendf(TraceView, "%S\n", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_MoveCursorsByPageSize(Window *window, int direction, bool shift = false) {
|
void MoveCursorByPageSize(Window *window, int direction, bool shift = false) {
|
||||||
Assert(direction == DIR_UP || direction == DIR_DOWN);
|
Assert(direction == DIR_UP || direction == DIR_DOWN);
|
||||||
BSet set = GetBSet(window);
|
BSet set = GetBSet(window);
|
||||||
|
|
||||||
@@ -274,7 +273,7 @@ void Command_MoveCursorsByPageSize(Window *window, int direction, bool shift = f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_MoveCursorsToSide(View *view, int direction, bool shift = false) {
|
void MoveCursorToSide(View *view, int direction, bool shift = false) {
|
||||||
Assert(direction == DIR_LEFT || direction == DIR_RIGHT);
|
Assert(direction == DIR_LEFT || direction == DIR_RIGHT);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
|
||||||
@@ -400,7 +399,7 @@ Caret MoveCaret(Buffer *buffer, Caret it, int direction, bool ctrl = false, bool
|
|||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_Move(View *view, int direction, bool ctrl = false, bool shift = false) {
|
void MoveCarets(View *view, int direction, bool ctrl = false, bool shift = false) {
|
||||||
Assert(direction < DIR_COUNT);
|
Assert(direction < DIR_COUNT);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
For(view->carets) {
|
For(view->carets) {
|
||||||
@@ -408,7 +407,7 @@ void Command_Move(View *view, int direction, bool ctrl = false, bool shift = fal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_MoveLine(View *view, int direction) {
|
void MoveCaretsLine(View *view, int direction) {
|
||||||
Assert(direction == DIR_DOWN || direction == DIR_UP);
|
Assert(direction == DIR_DOWN || direction == DIR_UP);
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
|
|
||||||
@@ -467,7 +466,7 @@ void Command_MoveLine(View *view, int direction) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Array<Edit> Command_ReplaceEx(Allocator scratch, View *view, String16 string) {
|
Array<Edit> ReplaceEx(Allocator scratch, View *view, String16 string) {
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
||||||
MergeCarets(buffer, &view->carets);
|
MergeCarets(buffer, &view->carets);
|
||||||
@@ -476,9 +475,9 @@ Array<Edit> Command_ReplaceEx(Allocator scratch, View *view, String16 string) {
|
|||||||
return edits;
|
return edits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_Replace(View *view, String16 string) {
|
void Replace(View *view, String16 string) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Command_ReplaceEx(scratch, view, string);
|
ReplaceEx(scratch, view, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_DuplicateLine(View *view, int direction) {
|
void Command_DuplicateLine(View *view, int direction) {
|
||||||
@@ -702,10 +701,12 @@ void SaveBuffer(Buffer *buffer) {
|
|||||||
ReportWarningf("Failed to save file with name: %S", buffer->name);
|
ReportWarningf("Failed to save file with name: %S", buffer->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_Save() {
|
void Command_Save() {
|
||||||
BSet set = GetLastActiveLayoutSet();
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
SaveBuffer(set.buffer);
|
SaveBuffer(active.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_Save(lua_State *L) {
|
int Lua_Save(lua_State *L) {
|
||||||
Command_Save();
|
Command_Save();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -718,6 +719,7 @@ void Command_SaveAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_SaveAll(lua_State *L) {
|
int Lua_SaveAll(lua_State *L) {
|
||||||
Command_SaveAll();
|
Command_SaveAll();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -734,7 +736,7 @@ void Command_KillSelectedLines(View *view) {
|
|||||||
it.range.min = GetFullLineStart(buffer, it.range.min);
|
it.range.min = GetFullLineStart(buffer, it.range.min);
|
||||||
it.range.min -= Clamp(eof, (Int)0, buffer->len);
|
it.range.min -= Clamp(eof, (Int)0, buffer->len);
|
||||||
}
|
}
|
||||||
Command_Replace(view, u"");
|
Replace(view, u"");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncloseLine(View *view) {
|
void EncloseLine(View *view) {
|
||||||
@@ -840,18 +842,18 @@ void Command_CreateCursorVertical(View *view, int direction) {
|
|||||||
MergeCarets(buffer, &view->carets);
|
MergeCarets(buffer, &view->carets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_SelectRangeOneCursor(View *view, Caret caret) {
|
void SelectRange(View *view, Caret caret) {
|
||||||
view->carets.len = 1;
|
view->carets.len = 1;
|
||||||
view->carets[0] = caret;
|
view->carets[0] = caret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_SelectRangeOneCursor(View *view, Range range) {
|
void SelectRange(View *view, Range range) {
|
||||||
Command_SelectRangeOneCursor(view, MakeCaret(range.min, range.max));
|
SelectRange(view, MakeCaret(range.min, range.max));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_SelectEntireBuffer(View *view) {
|
void SelectEntireBuffer(View *view) {
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Command_SelectRangeOneCursor(view, GetRange(buffer));
|
SelectRange(view, GetRange(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
Caret FindPrev(Buffer *buffer, String16 needle, Caret caret) {
|
Caret FindPrev(Buffer *buffer, String16 needle, Caret caret) {
|
||||||
@@ -890,7 +892,7 @@ Caret FindNext(Buffer *buffer, String16 needle, Caret caret) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_IdentedNewLine(View *view) {
|
void IdentedNewLine(View *view) {
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
Array<Edit> edits = BeginEdit(scratch, buffer, view->carets);
|
||||||
@@ -911,7 +913,7 @@ void Command_Find(View *seek_view, String16 needle, bool forward = true) {
|
|||||||
Caret caret = seek_view->carets[0];
|
Caret caret = seek_view->carets[0];
|
||||||
if (forward) caret = FindNext(seek_buffer, needle, caret);
|
if (forward) caret = FindNext(seek_buffer, needle, caret);
|
||||||
if (!forward) caret = FindPrev(seek_buffer, needle, caret);
|
if (!forward) caret = FindPrev(seek_buffer, needle, caret);
|
||||||
Command_SelectRangeOneCursor(seek_view, caret);
|
SelectRange(seek_view, caret);
|
||||||
|
|
||||||
IF_DEBUG(AssertRanges(seek_view->carets));
|
IF_DEBUG(AssertRanges(seek_view->carets));
|
||||||
}
|
}
|
||||||
@@ -967,9 +969,9 @@ void Command_FuzzySort(View *view, String16 needle) {
|
|||||||
RawReplaceText(temp_buffer, GetBufferEndAsRange(temp_buffer), u"\n");
|
RawReplaceText(temp_buffer, GetBufferEndAsRange(temp_buffer), u"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Command_SelectEntireBuffer(view);
|
SelectEntireBuffer(view);
|
||||||
Command_Replace(view, GetString(temp_buffer));
|
Replace(view, GetString(temp_buffer));
|
||||||
Command_SelectRangeOneCursor(view, MakeRange(0));
|
SelectRange(view, MakeRange(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReopenBuffer(Buffer *buffer) {
|
void ReopenBuffer(Buffer *buffer) {
|
||||||
@@ -987,9 +989,9 @@ void ReopenBuffer(Buffer *buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Command_Reopen() {
|
void Command_Reopen() {
|
||||||
BSet set = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
ReopenBuffer(set.buffer);
|
ReopenBuffer(main.buffer);
|
||||||
ActiveWindow = set.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_Reopen(lua_State *L) {
|
int Lua_Reopen(lua_State *L) {
|
||||||
@@ -1015,7 +1017,7 @@ void New(Window *window, String name = "") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Command_New(String name = "") {
|
void Command_New(String name = "") {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
New(main.window, name);
|
New(main.window, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1048,7 +1050,7 @@ void NewDir(Window *window, String name = "") {
|
|||||||
int Lua_NewDir(lua_State *L) {
|
int Lua_NewDir(lua_State *L) {
|
||||||
String name = lua_tostring(L, 1);
|
String name = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
NewDir(main.window, name);
|
NewDir(main.window, name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1094,12 +1096,12 @@ void ListFilesRecursive(Buffer *buffer, String dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Command_ListCode(String dir = WorkDir) {
|
void Command_ListCode(String dir = WorkDir) {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
JumpGarbageBuffer(&main);
|
JumpGarbageBuffer(&main);
|
||||||
ListFilesRecursive(main.buffer, dir);
|
ListFilesRecursive(main.buffer, dir);
|
||||||
main.view->fuzzy_search = true;
|
main.view->fuzzy_search = true;
|
||||||
main.view->update_scroll = true;
|
main.view->update_scroll = true;
|
||||||
Command_SelectRangeOneCursor(main.view, GetBufferEndAsRange(main.buffer));
|
SelectRange(main.view, GetBufferEndAsRange(main.buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_ListCode(lua_State *L) {
|
int Lua_ListCode(lua_State *L) {
|
||||||
@@ -1119,17 +1121,19 @@ View *Command_ExecHidden(String buffer_name, String cmd, String working_dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BSet Command_Exec(String cmd, String working_dir, bool set_active = true) {
|
BSet Command_Exec(String cmd, String working_dir, bool set_active = true) {
|
||||||
BSet set = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
if (set_active) ActiveWindow = set.window->id;
|
if (set_active) {
|
||||||
JumpGarbageBuffer(&set);
|
NextActiveWindowID = main.window->id;
|
||||||
Exec(set.view->id, true, cmd, working_dir);
|
}
|
||||||
return set;
|
JumpGarbageBuffer(&main);
|
||||||
|
Exec(main.view->id, true, cmd, working_dir);
|
||||||
|
return main;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_C(lua_State *L) {
|
int Lua_C(lua_State *L) {
|
||||||
String string = lua_tostring(L, 1);
|
String string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
Command_Exec(string, Command_GetMainDir());
|
Command_Exec(string, GetMainDir());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,13 +1144,13 @@ BSet Command_Open(Window *window, String path, String meta, bool set_active = tr
|
|||||||
OnOpenResult ores = CallOnOpen(scratch, path, meta);
|
OnOpenResult ores = CallOnOpen(scratch, path, meta);
|
||||||
if (ores.kind == "text") {
|
if (ores.kind == "text") {
|
||||||
if (set_active) {
|
if (set_active) {
|
||||||
ActiveWindow = set.window->id;
|
NextActiveWindowID = set.window->id;
|
||||||
}
|
}
|
||||||
if (IsDir(ores.file_path)) {
|
if (IsDir(ores.file_path)) {
|
||||||
JumpGarbageBuffer(&set, GetUniqueBufferName(ores.file_path, "temp", ".dirlisting"));
|
JumpGarbageBuffer(&set, GetUniqueBufferName(ores.file_path, "temp", ".dirlisting"));
|
||||||
Command_Appendf(set.view, "..\n");
|
Appendf(set.view, "..\n");
|
||||||
for (FileIter it = IterateFiles(scratch, ores.file_path); IsValid(it); Advance(&it)) {
|
for (FileIter it = IterateFiles(scratch, ores.file_path); IsValid(it); Advance(&it)) {
|
||||||
Command_Appendf(set.view, "%S\n", it.filename);
|
Appendf(set.view, "%S\n", it.filename);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CheckpointBeforeGoto(set.window);
|
CheckpointBeforeGoto(set.window);
|
||||||
@@ -1161,7 +1165,7 @@ BSet Command_Open(Window *window, String path, String meta, bool set_active = tr
|
|||||||
UpdateScroll(set.window, true);
|
UpdateScroll(set.window, true);
|
||||||
} else if (ores.kind == "exec") {
|
} else if (ores.kind == "exec") {
|
||||||
if (set_active) {
|
if (set_active) {
|
||||||
ActiveWindow = set.window->id;
|
NextActiveWindowID = set.window->id;
|
||||||
}
|
}
|
||||||
JumpGarbageBuffer(&set);
|
JumpGarbageBuffer(&set);
|
||||||
Exec(set.view->id, true, ores.cmd, ores.working_dir);
|
Exec(set.view->id, true, ores.cmd, ores.working_dir);
|
||||||
@@ -1179,7 +1183,7 @@ BSet Command_Open(Window *window, String path, String meta, bool set_active = tr
|
|||||||
}
|
}
|
||||||
|
|
||||||
BSet Command_Open(String path, String meta) {
|
BSet Command_Open(String path, String meta) {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
main = Command_Open(main.window, path, meta);
|
main = Command_Open(main.window, path, meta);
|
||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
@@ -1206,7 +1210,7 @@ int Lua_Cmd(lua_State *L) {
|
|||||||
String working_dir = lua_tostring(L, -1);
|
String working_dir = lua_tostring(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (working_dir == "") {
|
if (working_dir == "") {
|
||||||
working_dir = Command_GetMainDir();
|
working_dir = GetMainDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_getfield(L, -1, "cmd");
|
lua_getfield(L, -1, "cmd");
|
||||||
@@ -1218,52 +1222,68 @@ int Lua_Cmd(lua_State *L) {
|
|||||||
String kind = lua_tostring(L, -1);
|
String kind = lua_tostring(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
if (kind == "console") {
|
if (kind == "console") {
|
||||||
BSet set = GetConsoleSet();
|
BSet set = GetConsoleSet();
|
||||||
main.window->active_goto_list = set.view->id;
|
main.window->active_goto_list = set.view->id;
|
||||||
main.window->goto_list_pos = set.buffer->len;
|
main.window->goto_list_pos = set.buffer->len;
|
||||||
Command_SelectRangeOneCursor(set.view, MakeRange(set.buffer->len));
|
SelectRange(set.view, MakeRange(set.buffer->len));
|
||||||
Command_BeginJump(&set);
|
BeginJump(&set);
|
||||||
Exec(set.view->id, true, cmd, working_dir);
|
Exec(set.view->id, true, cmd, working_dir);
|
||||||
Command_EndJump(set);
|
EndJump(set);
|
||||||
} else if (kind == "fuzzy") {
|
} else if (kind == "fuzzy") {
|
||||||
JumpGarbageBuffer(&main);
|
JumpGarbageBuffer(&main);
|
||||||
Exec(main.view->id, true, cmd, working_dir);
|
Exec(main.view->id, true, cmd, working_dir);
|
||||||
main.view->fuzzy_search = true;
|
main.view->fuzzy_search = true;
|
||||||
ActiveWindow = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
} else {
|
} else {
|
||||||
JumpGarbageBuffer(&main);
|
JumpGarbageBuffer(&main);
|
||||||
main.window->active_goto_list = main.view->id;
|
main.window->active_goto_list = main.view->id;
|
||||||
main.window->goto_list_pos = 0;
|
main.window->goto_list_pos = 0;
|
||||||
Exec(main.view->id, true, cmd, working_dir);
|
Exec(main.view->id, true, cmd, working_dir);
|
||||||
ActiveWindow = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_ShowBufferList() {
|
void Command_ShowBufferList() {
|
||||||
BSet main = GetBSet(CommandBarWindowID);
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||||
main.window->visible = true;
|
command_bar.window->visible = true;
|
||||||
ActiveWindow = main.window->id;
|
NextActiveWindowID = command_bar.window->id;
|
||||||
ResetBuffer(main.buffer);
|
ResetBuffer(command_bar.buffer);
|
||||||
For(Buffers) {
|
For(Buffers) {
|
||||||
RawAppendf(main.buffer, "%-80S || %S\n", SkipToLastSlash(it->name), it->name);
|
RawAppendf(command_bar.buffer, "%-80S || %S\n", SkipToLastSlash(it->name), it->name);
|
||||||
}
|
}
|
||||||
main.view->fuzzy_search = true;
|
command_bar.view->update_scroll = true;
|
||||||
main.view->update_scroll = true;
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
Command_SelectRangeOneCursor(main.view, GetBufferEndAsRange(main.buffer));
|
}
|
||||||
|
|
||||||
|
void Command_ShowCommandList() {
|
||||||
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||||
|
command_bar.window->visible = true;
|
||||||
|
NextActiveWindowID = command_bar.window->id;
|
||||||
|
ResetBuffer(command_bar.buffer);
|
||||||
|
for (int i = 0; LuaFunctions[i].name != NULL; i += 1) {
|
||||||
|
Appendf(command_bar.view, "%s()\n ", LuaFunctions[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
command_bar.view->update_scroll = true;
|
||||||
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_ListViews() {
|
void Command_ListViews() {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||||
ActiveWindow = main.window->id;
|
command_bar.window->visible = true;
|
||||||
JumpGarbageBuffer(&main);
|
NextActiveWindowID = command_bar.window->id;
|
||||||
|
ResetBuffer(command_bar.buffer);
|
||||||
For(Views) {
|
For(Views) {
|
||||||
Buffer *buffer = GetBuffer(it->active_buffer);
|
Buffer *buffer = GetBuffer(it->active_buffer);
|
||||||
Command_Appendf(main.view, "%d %S\n", (int)it->id.id, buffer->name);
|
Appendf(command_bar.view, "%d %S\n", (int)it->id.id, buffer->name);
|
||||||
}
|
}
|
||||||
|
command_bar.view->fuzzy_search = true;
|
||||||
|
command_bar.view->update_scroll = true;
|
||||||
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_ListViews(lua_State *L) {
|
int Lua_ListViews(lua_State *L) {
|
||||||
@@ -1298,34 +1318,47 @@ void SetProjectFile(Buffer *buffer) {
|
|||||||
LuaProjectBuffer->user_change_id = -1;
|
LuaProjectBuffer->user_change_id = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Command_SetProjectFile() {
|
||||||
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
SetProjectFile(main.buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Command_SetWorkDir() {
|
||||||
|
String dir = lua_tostring(LuaState, -1);
|
||||||
|
if (dir.len == 0) {
|
||||||
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
WorkDir = ChopLastSlash(main.buffer->name);
|
||||||
|
} else {
|
||||||
|
WorkDir = dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Command_SetProject() {
|
||||||
|
Command_SetWorkDir();
|
||||||
|
Command_SetProjectFile();
|
||||||
|
}
|
||||||
|
|
||||||
int Lua_SetProjectFile(lua_State *L) {
|
int Lua_SetProjectFile(lua_State *L) {
|
||||||
BSet set = GetLastActiveLayoutSet();
|
Command_SetProjectFile();
|
||||||
SetProjectFile(set.buffer);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_SetWorkDir(lua_State *L) {
|
int Lua_SetWorkDir(lua_State *L) {
|
||||||
String dir = lua_tostring(L, -1);
|
Command_SetWorkDir();
|
||||||
if (dir.len == 0) {
|
|
||||||
BSet set = GetLastActiveLayoutSet();
|
|
||||||
WorkDir = ChopLastSlash(set.buffer->name);
|
|
||||||
} else {
|
|
||||||
WorkDir = dir;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_ListCommands(lua_State *L) {
|
int Lua_ListCommands(lua_State *L) {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
Command_BeginJump(&main);
|
BeginJump(&main);
|
||||||
for (int i = 0; LuaFunctions[i].name != NULL; i += 1) {
|
for (int i = 0; LuaFunctions[i].name != NULL; i += 1) {
|
||||||
Command_Appendf(main.view, "%20s() ", LuaFunctions[i].name);
|
Appendf(main.view, "%20s() ", LuaFunctions[i].name);
|
||||||
if (((i + 1) % 6) == 0) {
|
if (((i + 1) % 6) == 0) {
|
||||||
Command_Appendf(main.view, "\n");
|
Appendf(main.view, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command_EndJump(main);
|
EndJump(main);
|
||||||
ActiveWindow = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1373,17 +1406,42 @@ Vec2I GetSideOfWindow(Window *window, int direction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Window *SwitchWindow(int direction) {
|
Window *SwitchWindow(int direction) {
|
||||||
Window *window = GetWindow(ActiveWindow);
|
Window *window = GetWindow(ActiveWindowID);
|
||||||
Vec2I p = GetSideOfWindow(window, direction);
|
Vec2I p = GetSideOfWindow(window, direction);
|
||||||
Window *result = GetOverlappingWindow(p, window);
|
Window *result = GetOverlappingWindow(p, window);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String16 FetchLoadWord(void) {
|
String16 FetchLoadWord(void) {
|
||||||
BSet active = GetActiveSet();
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
Caret caret = active.view->carets[0];
|
Caret caret = active.view->carets[0];
|
||||||
Range range = caret.range;
|
Range range = caret.range;
|
||||||
if (GetSize(caret.range) == 0) range = EncloseLoadWord(active.buffer, GetFront(caret));
|
if (GetSize(caret.range) == 0) range = EncloseLoadWord(active.buffer, GetFront(caret));
|
||||||
String16 string = GetString(active.buffer, range);
|
String16 string = GetString(active.buffer, range);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Command_ToggleDebug() {
|
||||||
|
Window *window = GetWindow(DebugWindowID);
|
||||||
|
window->visible = !window->visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Command_KillProcess() {
|
||||||
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
KillProcess(main.view);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Lua_KillProcess(lua_State *L) {
|
||||||
|
Command_KillProcess();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Command_KillWindow() {
|
||||||
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
main.window->kill = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Lua_KillWindow(lua_State *L) {
|
||||||
|
Command_KillWindow();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ void OnCommand(Event event) {
|
|||||||
view->scroll.y = (Int)(v * (double)s.line_count * (double)window->font->line_spacing);
|
view->scroll.y = (Int)(v * (double)s.line_count * (double)window->font->line_spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DocumentSelected != ActiveWindow) {
|
if (DocumentSelected != ActiveWindowID) {
|
||||||
DocumentSelected.id = -1;
|
DocumentSelected.id = -1;
|
||||||
} else if (IsDocumentSelectionValid() && MouseUp()) {
|
} else if (IsDocumentSelectionValid() && MouseUp()) {
|
||||||
Assert(ScrollbarSelected.id == -1);
|
Assert(ScrollbarSelected.id == -1);
|
||||||
@@ -179,17 +179,19 @@ void OnCommand(Event event) {
|
|||||||
}
|
}
|
||||||
bool mouse_in_document = AreOverlapping(mouse, it->document_rect);
|
bool mouse_in_document = AreOverlapping(mouse, it->document_rect);
|
||||||
if (mouse_in_document) {
|
if (mouse_in_document) {
|
||||||
ActiveWindow = it->id;
|
NextActiveWindowID = it->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mouse(X2)) {
|
if (Mouse(X2)) {
|
||||||
GotoForward(GetLastActiveLayoutSet().window);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
GotoForward(main.window);
|
||||||
}
|
}
|
||||||
if (Mouse(X1)) {
|
if (Mouse(X1)) {
|
||||||
GotoBackward(GetLastActiveLayoutSet().window);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
GotoBackward(main.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ctrl() && Shift() && Mouse(RIGHT)) {
|
if (Ctrl() && Shift() && Mouse(RIGHT)) {
|
||||||
@@ -199,8 +201,8 @@ void OnCommand(Event event) {
|
|||||||
|
|
||||||
} else if (Alt() && Mouse(RIGHT)) {
|
} else if (Alt() && Mouse(RIGHT)) {
|
||||||
} else if (Mouse(RIGHT)) {
|
} else if (Mouse(RIGHT)) {
|
||||||
Vec2I mouse = MouseVec2I();
|
Vec2I mouse = MouseVec2I();
|
||||||
BSet active = GetActiveSet();
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
bool mouse_in_document = AreOverlapping(mouse, active.window->document_rect);
|
bool mouse_in_document = AreOverlapping(mouse, active.window->document_rect);
|
||||||
if (mouse_in_document) {
|
if (mouse_in_document) {
|
||||||
Int p = ScreenSpaceToBufferPos(active.window, active.view, active.buffer, mouse);
|
Int p = ScreenSpaceToBufferPos(active.window, active.view, active.buffer, mouse);
|
||||||
@@ -235,7 +237,7 @@ void OnCommand(Event event) {
|
|||||||
Assert(ScrollbarSelected.id == -1);
|
Assert(ScrollbarSelected.id == -1);
|
||||||
Assert(DocumentSelected.id == -1);
|
Assert(DocumentSelected.id == -1);
|
||||||
|
|
||||||
BSet active = GetActiveSet();
|
BSet active = GetBSet(NextActiveWindowID); // using next to make sure mouse works on first click after switching the window
|
||||||
bool mouse_in_document = AreOverlapping(mouse, active.window->document_rect);
|
bool mouse_in_document = AreOverlapping(mouse, active.window->document_rect);
|
||||||
bool mouse_in_line_numbers = AreOverlapping(mouse, active.window->line_numbers_rect);
|
bool mouse_in_line_numbers = AreOverlapping(mouse, active.window->line_numbers_rect);
|
||||||
if (mouse_in_document || mouse_in_line_numbers) {
|
if (mouse_in_document || mouse_in_line_numbers) {
|
||||||
@@ -297,27 +299,27 @@ void OnCommand(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlPress(SDLK_W)) {
|
if (CtrlPress(SDLK_W)) {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
Command_KillWindow();
|
||||||
main.window->kill = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlAltPress(SDLK_P)) {
|
if (CtrlAltPress(SDLK_P)) {
|
||||||
|
} else if (CtrlShiftPress(SDLK_P)) {
|
||||||
|
Command_ShowCommandList();
|
||||||
} else if (CtrlPress(SDLK_P)) {
|
} else if (CtrlPress(SDLK_P)) {
|
||||||
Command_ShowBufferList();
|
Command_ShowBufferList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlPress(SDLK_0)) {
|
if (CtrlPress(SDLK_0)) {
|
||||||
Window *window = GetWindow(DebugWindowID);
|
Command_ToggleDebug();
|
||||||
window->visible = !window->visible;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlPress(SDLK_1)) {
|
if (CtrlPress(SDLK_1)) {
|
||||||
ActiveWindow = GetOverlappingWindow({0,0}, GetWindow(ActiveWindow))->id;
|
NextActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
||||||
}
|
}
|
||||||
if (CtrlPress(SDLK_2)) {
|
if (CtrlPress(SDLK_2)) {
|
||||||
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindow));
|
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID));
|
||||||
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
||||||
ActiveWindow = GetOverlappingWindow(p, GetWindow(ActiveWindow))->id;
|
NextActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
||||||
}
|
}
|
||||||
if (CtrlPress(SDLK_3)) {
|
if (CtrlPress(SDLK_3)) {
|
||||||
Window *first = GetOverlappingWindow({0,0});
|
Window *first = GetOverlappingWindow({0,0});
|
||||||
@@ -326,14 +328,14 @@ void OnCommand(Event event) {
|
|||||||
if (second) {
|
if (second) {
|
||||||
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
||||||
if (third) {
|
if (third) {
|
||||||
ActiveWindow = third->id;
|
NextActiveWindowID = third->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
BSet active = GetActiveSet();
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
Int buffer_change_id = active.buffer->change_id;
|
Int buffer_change_id = active.buffer->change_id;
|
||||||
|
|
||||||
bool skip = CallOnCommand(&event);
|
bool skip = CallOnCommand(&event);
|
||||||
@@ -364,15 +366,15 @@ void OnCommand(Event event) {
|
|||||||
} else if (AltShiftPress(SDLK_DOWN)) {
|
} else if (AltShiftPress(SDLK_DOWN)) {
|
||||||
Command_CreateCursorVertical(active.view, DIR_DOWN);
|
Command_CreateCursorVertical(active.view, DIR_DOWN);
|
||||||
} else if (CtrlShiftPress(SDLK_DOWN)) {
|
} else if (CtrlShiftPress(SDLK_DOWN)) {
|
||||||
Command_Move(active.view, DIR_DOWN, CTRL_PRESSED, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_DOWN, CTRL_PRESSED, SHIFT_PRESS);
|
||||||
} else if (AltPress(SDLK_DOWN)) {
|
} else if (AltPress(SDLK_DOWN)) {
|
||||||
Command_MoveLine(active.view, DIR_DOWN);
|
MoveCaretsLine(active.view, DIR_DOWN);
|
||||||
} else if (CtrlPress(SDLK_DOWN)) {
|
} else if (CtrlPress(SDLK_DOWN)) {
|
||||||
Command_Move(active.view, DIR_DOWN, CTRL_PRESSED);
|
MoveCarets(active.view, DIR_DOWN, CTRL_PRESSED);
|
||||||
} else if (ShiftPress(SDLK_DOWN)) {
|
} else if (ShiftPress(SDLK_DOWN)) {
|
||||||
Command_Move(active.view, DIR_DOWN, false, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_DOWN, false, SHIFT_PRESS);
|
||||||
} else if (Press(SDLK_DOWN)) {
|
} else if (Press(SDLK_DOWN)) {
|
||||||
Command_Move(active.view, DIR_DOWN);
|
MoveCarets(active.view, DIR_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlAltPress(SDLK_UP)) {
|
if (CtrlAltPress(SDLK_UP)) {
|
||||||
@@ -380,39 +382,39 @@ void OnCommand(Event event) {
|
|||||||
} else if (AltShiftPress(SDLK_UP)) {
|
} else if (AltShiftPress(SDLK_UP)) {
|
||||||
Command_CreateCursorVertical(active.view, DIR_UP);
|
Command_CreateCursorVertical(active.view, DIR_UP);
|
||||||
} else if (CtrlShiftPress(SDLK_UP)) {
|
} else if (CtrlShiftPress(SDLK_UP)) {
|
||||||
Command_Move(active.view, DIR_UP, CTRL_PRESSED, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_UP, CTRL_PRESSED, SHIFT_PRESS);
|
||||||
} else if (AltPress(SDLK_UP)) {
|
} else if (AltPress(SDLK_UP)) {
|
||||||
Command_MoveLine(active.view, DIR_UP);
|
MoveCaretsLine(active.view, DIR_UP);
|
||||||
} else if (CtrlPress(SDLK_UP)) {
|
} else if (CtrlPress(SDLK_UP)) {
|
||||||
Command_Move(active.view, DIR_UP, CTRL_PRESSED);
|
MoveCarets(active.view, DIR_UP, CTRL_PRESSED);
|
||||||
} else if (ShiftPress(SDLK_UP)) {
|
} else if (ShiftPress(SDLK_UP)) {
|
||||||
Command_Move(active.view, DIR_UP, false, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_UP, false, SHIFT_PRESS);
|
||||||
} else if (Press(SDLK_UP)) {
|
} else if (Press(SDLK_UP)) {
|
||||||
Command_Move(active.view, DIR_UP);
|
MoveCarets(active.view, DIR_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShiftPress(SDLK_LEFT)) {
|
if (CtrlShiftPress(SDLK_LEFT)) {
|
||||||
Command_Move(active.view, DIR_LEFT, CTRL_PRESSED, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_LEFT, CTRL_PRESSED, SHIFT_PRESS);
|
||||||
} else if (CtrlPress(SDLK_LEFT)) {
|
} else if (CtrlPress(SDLK_LEFT)) {
|
||||||
Command_Move(active.view, DIR_LEFT, CTRL_PRESSED);
|
MoveCarets(active.view, DIR_LEFT, CTRL_PRESSED);
|
||||||
} else if (ShiftPress(SDLK_LEFT)) {
|
} else if (ShiftPress(SDLK_LEFT)) {
|
||||||
Command_Move(active.view, DIR_LEFT, false, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_LEFT, false, SHIFT_PRESS);
|
||||||
} else if (AltPress(SDLK_LEFT)) {
|
} else if (AltPress(SDLK_LEFT)) {
|
||||||
ActiveWindow = SwitchWindow(DIR_LEFT)->id;
|
NextActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
||||||
} else if (Press(SDLK_LEFT)) {
|
} else if (Press(SDLK_LEFT)) {
|
||||||
Command_Move(active.view, DIR_LEFT);
|
MoveCarets(active.view, DIR_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShiftPress(SDLK_RIGHT)) {
|
if (CtrlShiftPress(SDLK_RIGHT)) {
|
||||||
Command_Move(active.view, DIR_RIGHT, CTRL_PRESSED, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_RIGHT, CTRL_PRESSED, SHIFT_PRESS);
|
||||||
} else if (CtrlPress(SDLK_RIGHT)) {
|
} else if (CtrlPress(SDLK_RIGHT)) {
|
||||||
Command_Move(active.view, DIR_RIGHT, CTRL_PRESSED);
|
MoveCarets(active.view, DIR_RIGHT, CTRL_PRESSED);
|
||||||
} else if (ShiftPress(SDLK_RIGHT)) {
|
} else if (ShiftPress(SDLK_RIGHT)) {
|
||||||
Command_Move(active.view, DIR_RIGHT, false, SHIFT_PRESS);
|
MoveCarets(active.view, DIR_RIGHT, false, SHIFT_PRESS);
|
||||||
} else if (AltPress(SDLK_RIGHT)) {
|
} else if (AltPress(SDLK_RIGHT)) {
|
||||||
ActiveWindow = SwitchWindow(DIR_RIGHT)->id;
|
NextActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
||||||
} else if (Press(SDLK_RIGHT)) {
|
} else if (Press(SDLK_RIGHT)) {
|
||||||
Command_Move(active.view, DIR_RIGHT);
|
MoveCarets(active.view, DIR_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShiftPress(SDLK_Z)) {
|
if (CtrlShiftPress(SDLK_Z)) {
|
||||||
@@ -428,50 +430,50 @@ void OnCommand(Event event) {
|
|||||||
} else if (CtrlPress(SDLK_X)) {
|
} else if (CtrlPress(SDLK_X)) {
|
||||||
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
||||||
Command_Copy(active.view);
|
Command_Copy(active.view);
|
||||||
Command_Replace(active.view, u"");
|
Replace(active.view, u"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlPress(SDLK_A)) {
|
if (CtrlPress(SDLK_A)) {
|
||||||
Command_SelectEntireBuffer(active.view);
|
SelectEntireBuffer(active.view);
|
||||||
active.view->update_scroll = false;
|
active.view->update_scroll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShiftPress(SDLK_PAGEUP)) {
|
if (ShiftPress(SDLK_PAGEUP)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsByPageSize(active.window, DIR_UP, SHIFT_PRESS);
|
MoveCursorByPageSize(active.window, DIR_UP, SHIFT_PRESS);
|
||||||
} else if (CtrlPress(SDLK_PAGEUP)) {
|
} else if (CtrlPress(SDLK_PAGEUP)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_SelectRangeOneCursor(active.view, MakeRange(0));
|
SelectRange(active.view, MakeRange(0));
|
||||||
} else if (Press(SDLK_PAGEUP)) {
|
} else if (Press(SDLK_PAGEUP)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsByPageSize(active.window, DIR_UP);
|
MoveCursorByPageSize(active.window, DIR_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShiftPress(SDLK_PAGEDOWN)) {
|
if (ShiftPress(SDLK_PAGEDOWN)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsByPageSize(active.window, DIR_DOWN, SHIFT_PRESS);
|
MoveCursorByPageSize(active.window, DIR_DOWN, SHIFT_PRESS);
|
||||||
} else if (CtrlPress(SDLK_PAGEDOWN)) {
|
} else if (CtrlPress(SDLK_PAGEDOWN)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_SelectRangeOneCursor(active.view, MakeRange(active.buffer->len));
|
SelectRange(active.view, MakeRange(active.buffer->len));
|
||||||
} else if (Press(SDLK_PAGEDOWN)) {
|
} else if (Press(SDLK_PAGEDOWN)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsByPageSize(active.window, DIR_DOWN);
|
MoveCursorByPageSize(active.window, DIR_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShiftPress(SDLK_HOME)) {
|
if (ShiftPress(SDLK_HOME)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsToSide(active.view, DIR_LEFT, SHIFT_PRESS);
|
MoveCursorToSide(active.view, DIR_LEFT, SHIFT_PRESS);
|
||||||
} else if (Press(SDLK_HOME)) {
|
} else if (Press(SDLK_HOME)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsToSide(active.view, DIR_LEFT);
|
MoveCursorToSide(active.view, DIR_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShiftPress(SDLK_END)) {
|
if (ShiftPress(SDLK_END)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsToSide(active.view, DIR_RIGHT, SHIFT_PRESS);
|
MoveCursorToSide(active.view, DIR_RIGHT, SHIFT_PRESS);
|
||||||
} else if (Press(SDLK_END)) {
|
} else if (Press(SDLK_END)) {
|
||||||
CheckpointBeforeGoto(active.window);
|
CheckpointBeforeGoto(active.window);
|
||||||
Command_MoveCursorsToSide(active.view, DIR_RIGHT);
|
MoveCursorToSide(active.view, DIR_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShiftPress(SDLK_TAB)) {
|
if (CtrlShiftPress(SDLK_TAB)) {
|
||||||
@@ -509,7 +511,7 @@ void OnCommand(Event event) {
|
|||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String string = event.text;
|
String string = event.text;
|
||||||
String16 string16 = ToString16(scratch, string);
|
String16 string16 = ToString16(scratch, string);
|
||||||
Command_Replace(active.view, string16);
|
Replace(active.view, string16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlPress(SDLK_D)) {
|
if (CtrlPress(SDLK_D)) {
|
||||||
@@ -536,14 +538,14 @@ void OnCommand(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShiftPress(SDLK_RETURN)) {
|
if (CtrlShiftPress(SDLK_RETURN)) {
|
||||||
Command_MoveCursorsToSide(active.view, DIR_LEFT);
|
MoveCursorToSide(active.view, DIR_LEFT);
|
||||||
Command_IdentedNewLine(active.view);
|
IdentedNewLine(active.view);
|
||||||
Command_Move(active.view, DIR_UP);
|
MoveCarets(active.view, DIR_UP);
|
||||||
} else if (CtrlPress(SDLK_RETURN)) {
|
} else if (CtrlPress(SDLK_RETURN)) {
|
||||||
Command_MoveCursorsToSide(active.view, DIR_RIGHT);
|
MoveCursorToSide(active.view, DIR_RIGHT);
|
||||||
Command_IdentedNewLine(active.view);
|
IdentedNewLine(active.view);
|
||||||
} else if (Press(SDLK_RETURN)) {
|
} else if (Press(SDLK_RETURN)) {
|
||||||
Command_IdentedNewLine(active.view);
|
IdentedNewLine(active.view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -566,8 +568,8 @@ void OnCommand(Event event) {
|
|||||||
|
|
||||||
Caret caret = active.view->carets[0];
|
Caret caret = active.view->carets[0];
|
||||||
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
||||||
Command_SelectEntireBuffer(active.view);
|
SelectEntireBuffer(active.view);
|
||||||
Command_Replace(active.view, GetString(temp_buffer));
|
Replace(active.view, GetString(temp_buffer));
|
||||||
active.view->carets[0] = caret;
|
active.view->carets[0] = caret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -618,11 +620,11 @@ void OnCommand(Event event) {
|
|||||||
active.view->carets.len = 1;
|
active.view->carets.len = 1;
|
||||||
active.view->carets[0] = MakeCaret(GetFront(active.view->carets[0]));
|
active.view->carets[0] = MakeCaret(GetFront(active.view->carets[0]));
|
||||||
|
|
||||||
if (active.window->lose_focus_on_escape && active.window->id == ActiveWindow) {
|
if (active.window->lose_focus_on_escape && active.window->id == ActiveWindowID) {
|
||||||
if (active.window->layout) {
|
if (active.window->layout) {
|
||||||
//
|
//
|
||||||
} else {
|
} else {
|
||||||
ActiveWindow = LastActiveLayoutWindowID;
|
NextActiveWindowID = LastActiveLayoutWindowID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -631,22 +633,3 @@ void OnCommand(Event event) {
|
|||||||
MergeCarets(active.buffer, &active.view->carets);
|
MergeCarets(active.buffer, &active.view->carets);
|
||||||
IF_DEBUG(AssertRanges(active.view->carets));
|
IF_DEBUG(AssertRanges(active.view->carets));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostCommandUpdate() {
|
|
||||||
For (Windows) {
|
|
||||||
if (it->sync_visibility_with_focus) {
|
|
||||||
if (it->id == ActiveWindow) {
|
|
||||||
it->visible = true;
|
|
||||||
} else {
|
|
||||||
it->visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ActiveWindow.id != LastActiveLayoutWindowID.id) {
|
|
||||||
Window *window = GetWindow(ActiveWindow);
|
|
||||||
if (window->layout) {
|
|
||||||
LastActiveLayoutWindowID = ActiveWindow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,9 +4,9 @@ int Lua_print(lua_State *L) {
|
|||||||
View *null_view = GetView(NullViewID);
|
View *null_view = GetView(NullViewID);
|
||||||
for (int i = 1; i <= nargs; i += 1) {
|
for (int i = 1; i <= nargs; i += 1) {
|
||||||
String string = lua_tostring(L, i);
|
String string = lua_tostring(L, i);
|
||||||
Command_Appendf(null_view, "%S ", string);
|
Appendf(null_view, "%S ", string);
|
||||||
}
|
}
|
||||||
Command_Appendf(null_view, "\n");
|
Appendf(null_view, "\n");
|
||||||
lua_pop(L, nargs);
|
lua_pop(L, nargs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -16,21 +16,15 @@ int Lua_Print(lua_State *L) {
|
|||||||
int nargs = lua_gettop(L);
|
int nargs = lua_gettop(L);
|
||||||
for (int i = 1; i <= nargs; i += 1) {
|
for (int i = 1; i <= nargs; i += 1) {
|
||||||
String string = lua_tostring(L, i);
|
String string = lua_tostring(L, i);
|
||||||
Command_Appendf(TraceView, "%S ", string);
|
Appendf(TraceView, "%S ", string);
|
||||||
}
|
}
|
||||||
Command_Appendf(TraceView, "\n");
|
Appendf(TraceView, "\n");
|
||||||
lua_pop(L, nargs);
|
lua_pop(L, nargs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_Kill(lua_State *L) {
|
|
||||||
BSet main = GetLastActiveLayoutSet();
|
|
||||||
KillProcess(main.view);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lua_GetLoadWord(lua_State *L) {
|
int Lua_GetLoadWord(lua_State *L) {
|
||||||
BSet active = GetActiveSet();
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
Range range = active.view->carets[0].range;
|
Range range = active.view->carets[0].range;
|
||||||
if (GetSize(range) == 0) {
|
if (GetSize(range) == 0) {
|
||||||
range = EncloseLoadWord(active.buffer, range.min);
|
range = EncloseLoadWord(active.buffer, range.min);
|
||||||
@@ -52,7 +46,7 @@ int Lua_BufferExists(lua_State *L) {
|
|||||||
|
|
||||||
int Lua_GetSelection(lua_State *L) {
|
int Lua_GetSelection(lua_State *L) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
String16 string16 = GetString(main.buffer, main.view->carets[0].range);
|
String16 string16 = GetString(main.buffer, main.view->carets[0].range);
|
||||||
String string = ToString(scratch, string16);
|
String string = ToString(scratch, string16);
|
||||||
lua_pushlstring(L, string.data, string.len);
|
lua_pushlstring(L, string.data, string.len);
|
||||||
@@ -61,7 +55,7 @@ int Lua_GetSelection(lua_State *L) {
|
|||||||
|
|
||||||
int Lua_GetEntireBuffer(lua_State *L) {
|
int Lua_GetEntireBuffer(lua_State *L) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
String16 string16 = GetString(main.buffer);
|
String16 string16 = GetString(main.buffer);
|
||||||
String string = ToString(scratch, string16);
|
String string = ToString(scratch, string16);
|
||||||
lua_pushlstring(L, string.data, string.len);
|
lua_pushlstring(L, string.data, string.len);
|
||||||
@@ -76,13 +70,13 @@ int Lua_GetClipboard(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Lua_GetFilename(lua_State *L) {
|
int Lua_GetFilename(lua_State *L) {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
lua_pushlstring(L, main.buffer->name.data, main.buffer->name.len);
|
lua_pushlstring(L, main.buffer->name.data, main.buffer->name.len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_GetLine(lua_State *L) {
|
int Lua_GetLine(lua_State *L) {
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
Caret caret = main.view->carets[0];
|
Caret caret = main.view->carets[0];
|
||||||
Int front = GetFront(caret);
|
Int front = GetFront(caret);
|
||||||
Int line = PosToLine(main.buffer, front);
|
Int line = PosToLine(main.buffer, front);
|
||||||
@@ -111,17 +105,11 @@ int Lua_GetExeDir(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Lua_GetMainDir(lua_State *L) {
|
int Lua_GetMainDir(lua_State *L) {
|
||||||
String name = Command_GetMainDir();
|
String name = GetMainDir();
|
||||||
lua_pushlstring(L, name.data, name.len);
|
lua_pushlstring(L, name.data, name.len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_KillWindow(lua_State *L) {
|
|
||||||
BSet set = GetLastActiveLayoutSet();
|
|
||||||
set.window->kill = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
int numkeys = 0;
|
int numkeys = 0;
|
||||||
@@ -348,7 +336,7 @@ OnOpenResult CallOnOpen(Allocator allocator, String path, String meta) {
|
|||||||
result.working_dir = working_dir;
|
result.working_dir = working_dir;
|
||||||
result.file_path = file_path;
|
result.file_path = file_path;
|
||||||
if (!IsAbsolute(result.file_path)) {
|
if (!IsAbsolute(result.file_path)) {
|
||||||
String dir = Command_GetMainDir();
|
String dir = GetMainDir();
|
||||||
result.file_path = Format(allocator, "%S/%S", dir, result.file_path);
|
result.file_path = Format(allocator, "%S/%S", dir, result.file_path);
|
||||||
}
|
}
|
||||||
if (col_string.len) {
|
if (col_string.len) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ luaL_Reg LuaFunctions[] = {
|
|||||||
{"print", Lua_print},
|
{"print", Lua_print},
|
||||||
{"Print", Lua_Print},
|
{"Print", Lua_Print},
|
||||||
{"SaveAll", Lua_SaveAll},
|
{"SaveAll", Lua_SaveAll},
|
||||||
{"Kill", Lua_Kill},
|
{"KillProcess", Lua_KillProcess},
|
||||||
{"GetLoadWord", Lua_GetLoadWord},
|
{"GetLoadWord", Lua_GetLoadWord},
|
||||||
{"BufferExists", Lua_BufferExists},
|
{"BufferExists", Lua_BufferExists},
|
||||||
{"GetSelection", Lua_GetSelection},
|
{"GetSelection", Lua_GetSelection},
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ WindowID SearchBarWindowID;
|
|||||||
ViewID SearchViewID;
|
ViewID SearchViewID;
|
||||||
BufferID SearchBufferID;
|
BufferID SearchBufferID;
|
||||||
|
|
||||||
WindowID ActiveWindow;
|
WindowID ActiveWindowID;
|
||||||
|
WindowID NextActiveWindowID;
|
||||||
WindowID LastActiveLayoutWindowID;
|
WindowID LastActiveLayoutWindowID;
|
||||||
WindowID ScrollbarSelected = {-1};
|
WindowID ScrollbarSelected = {-1};
|
||||||
WindowID DocumentSelected = {-1};
|
WindowID DocumentSelected = {-1};
|
||||||
@@ -140,7 +141,7 @@ inline View *GetView(ViewID id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsNull(Buffer *buffer) { return buffer->id.id == NullBufferID.id; }
|
inline bool IsNull(Buffer *buffer) { return buffer->id.id == NullBufferID.id; }
|
||||||
inline Window *GetActiveWind() { return GetWindow(ActiveWindow); }
|
inline Window *GetActiveWind() { return GetWindow(ActiveWindowID); }
|
||||||
|
|
||||||
Buffer *CreateBuffer(Allocator allocator, String name, Int size) {
|
Buffer *CreateBuffer(Allocator allocator, String name, Int size) {
|
||||||
Buffer *result = AllocBuffer(allocator, name, size);
|
Buffer *result = AllocBuffer(allocator, name, size);
|
||||||
@@ -244,15 +245,6 @@ BSet GetBSet(WindowID window_id) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BSet GetActiveSet() {
|
|
||||||
Window *window = GetWindow(ActiveWindow);
|
|
||||||
return GetBSet(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
BSet GetLastActiveLayoutSet() {
|
|
||||||
return GetBSet(LastActiveLayoutWindowID);
|
|
||||||
}
|
|
||||||
|
|
||||||
BSet GetConsoleSet() {
|
BSet GetConsoleSet() {
|
||||||
BSet result = {};
|
BSet result = {};
|
||||||
result.window = GetWindow(NullWindowID);
|
result.window = GetWindow(NullWindowID);
|
||||||
@@ -262,8 +254,8 @@ BSet GetConsoleSet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String Command_GetFilename() {
|
String Command_GetFilename() {
|
||||||
BSet set = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
return set.buffer->name;
|
return main.buffer->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GetDir(Buffer *buffer) {
|
String GetDir(Buffer *buffer) {
|
||||||
@@ -271,9 +263,9 @@ String GetDir(Buffer *buffer) {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Command_GetMainDir() {
|
String GetMainDir() {
|
||||||
BSet set = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
String name = ChopLastSlash(set.buffer->name);
|
String name = ChopLastSlash(main.buffer->name);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,6 +413,26 @@ bool BufferIsReferenced(BufferID buffer_id) {
|
|||||||
void GarbageCollect() {
|
void GarbageCollect() {
|
||||||
Allocator sys_allocator = GetSystemAllocator();
|
Allocator sys_allocator = GetSystemAllocator();
|
||||||
|
|
||||||
|
|
||||||
|
ActiveWindowID = NextActiveWindowID;
|
||||||
|
|
||||||
|
For (Windows) {
|
||||||
|
if (it->sync_visibility_with_focus) {
|
||||||
|
if (it->id == ActiveWindowID) {
|
||||||
|
it->visible = true;
|
||||||
|
} else {
|
||||||
|
it->visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ActiveWindowID.id != LastActiveLayoutWindowID.id) {
|
||||||
|
Window *window = GetWindow(ActiveWindowID);
|
||||||
|
if (window->layout) {
|
||||||
|
LastActiveLayoutWindowID = ActiveWindowID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
For(Buffers) {
|
For(Buffers) {
|
||||||
if (it->file_mod_time) {
|
if (it->file_mod_time) {
|
||||||
int64_t new_file_mod_time = GetFileModTime(it->name);
|
int64_t new_file_mod_time = GetFileModTime(it->name);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void UpdateProcesses() {
|
|||||||
|
|
||||||
String poll = PollStdout(scratch, &it, false);
|
String poll = PollStdout(scratch, &it, false);
|
||||||
if (poll.len) {
|
if (poll.len) {
|
||||||
Command_Append(view, poll, it.scroll_to_end);
|
Append(view, poll, it.scroll_to_end);
|
||||||
}
|
}
|
||||||
if (!IsValid(&it)) {
|
if (!IsValid(&it)) {
|
||||||
ReportDebugf("process %lld exit code = %d", it.id, it.exit_code);
|
ReportDebugf("process %lld exit code = %d", it.id, it.exit_code);
|
||||||
@@ -60,7 +60,7 @@ void KillProcess(View *view) {
|
|||||||
KillProcess(&it);
|
KillProcess(&it);
|
||||||
remove_item = true;
|
remove_item = true;
|
||||||
String string = "process was killed by user\n";
|
String string = "process was killed by user\n";
|
||||||
Command_Append(view, string, it.scroll_to_end);
|
Append(view, string, it.scroll_to_end);
|
||||||
// dont break because that will fuck with removal ...
|
// dont break because that will fuck with removal ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,7 +246,6 @@ void Update(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OnCommand(event);
|
OnCommand(event);
|
||||||
PostCommandUpdate();
|
|
||||||
UpdateProcesses();
|
UpdateProcesses();
|
||||||
CoUpdate(&event);
|
CoUpdate(&event);
|
||||||
ReloadLuaConfigs();
|
ReloadLuaConfigs();
|
||||||
|
|||||||
@@ -88,15 +88,14 @@ BSet Command_Open(String path, String meta = "");
|
|||||||
BSet Command_Open(String16 path, String meta = "");
|
BSet Command_Open(String16 path, String meta = "");
|
||||||
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
||||||
|
|
||||||
void Command_SelectEntireBuffer(View *view);
|
void SelectEntireBuffer(View *view);
|
||||||
void Command_Replace(View *view, String16 string);
|
void Replace(View *view, String16 string);
|
||||||
void Command_SelectRangeOneCursor(View *view, Range range);
|
void SelectRange(View *view, Range range);
|
||||||
void Command_Append(View *view, String16 string, bool scroll_to_end_if_cursor_on_last_line);
|
void Append(View *view, String16 string, bool scroll_to_end_if_cursor_on_last_line);
|
||||||
void Command_Append(View *view, String string, bool scroll_to_end_if_cursor_on_last_line);
|
void Append(View *view, String string, bool scroll_to_end_if_cursor_on_last_line);
|
||||||
Array<Edit> Command_ReplaceEx(Allocator scratch, View *view, String16 string);
|
Array<Edit> ReplaceEx(Allocator scratch, View *view, String16 string);
|
||||||
void Command_Eval(String string);
|
void Command_Eval(String string);
|
||||||
void Command_Eval(String16 string);
|
void Command_Eval(String16 string);
|
||||||
String Command_GetMainDir();
|
|
||||||
void ReportDebugf(const char *fmt, ...);
|
void ReportDebugf(const char *fmt, ...);
|
||||||
|
|
||||||
void ReplaceWithoutMovingCarets(Buffer *buffer, Range range, String16 string);
|
void ReplaceWithoutMovingCarets(Buffer *buffer, Range range, String16 string);
|
||||||
@@ -106,7 +105,7 @@ void Command_Paste(View *view);
|
|||||||
void ReportConsolef(const char *fmt, ...);
|
void ReportConsolef(const char *fmt, ...);
|
||||||
void ReportErrorf(const char *fmt, ...);
|
void ReportErrorf(const char *fmt, ...);
|
||||||
void ReportWarningf(const char *fmt, ...);
|
void ReportWarningf(const char *fmt, ...);
|
||||||
void Command_Appendf(View *view, const char *fmt, ...);
|
void Appendf(View *view, const char *fmt, ...);
|
||||||
|
|
||||||
Buffer *CreateBuffer(Allocator allocator, String name, Int size = 4096);
|
Buffer *CreateBuffer(Allocator allocator, String name, Int size = 4096);
|
||||||
View *CreateView(BufferID active_buffer);
|
View *CreateView(BufferID active_buffer);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ void UpdateDebugBuffer() {
|
|||||||
View *view = GetView(window->active_view);
|
View *view = GetView(window->active_view);
|
||||||
if (view->active_buffer.id == buffer->id.id) return;
|
if (view->active_buffer.id == buffer->id.id) return;
|
||||||
|
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String s = Format(scratch, "wid: %d\nvid: %d\nbid: %d\nframe: %lld\n", (int)main.window->id.id, (int)main.view->id.id, (int)main.buffer->id.id, (long long)FrameID);
|
String s = Format(scratch, "wid: %d\nvid: %d\nbid: %d\nframe: %lld\n", (int)main.window->id.id, (int)main.view->id.id, (int)main.buffer->id.id, (long long)FrameID);
|
||||||
@@ -48,7 +48,7 @@ void StatusBarUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
BSet main = GetLastActiveLayoutSet();
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
BSet title = GetBSet(status_bar_window);
|
BSet title = GetBSet(status_bar_window);
|
||||||
title.view->scroll.y = 0;
|
title.view->scroll.y = 0;
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ void StatusBarUpdate() {
|
|||||||
bool found_separator = Seek(buffer_string, u" |", &replace_range.max);
|
bool found_separator = Seek(buffer_string, u" |", &replace_range.max);
|
||||||
|
|
||||||
// Parse the title and line
|
// Parse the title and line
|
||||||
if (title.window->id == ActiveWindow) {
|
if (title.window->id == ActiveWindowID) {
|
||||||
if (title.buffer->change_id == title.window->status_bar_last_buffer_change_id) {
|
if (title.buffer->change_id == title.window->status_bar_last_buffer_change_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,8 +88,8 @@ void StatusBarUpdate() {
|
|||||||
|
|
||||||
// add separator at the end of buffer
|
// add separator at the end of buffer
|
||||||
if (!found_separator) {
|
if (!found_separator) {
|
||||||
Command_SelectRangeOneCursor(title.view, GetBufferEndAsRange(title.buffer));
|
SelectRange(title.view, GetBufferEndAsRange(title.buffer));
|
||||||
Array<Edit> edits = Command_ReplaceEx(scratch, title.view, u" |");
|
Array<Edit> edits = ReplaceEx(scratch, title.view, u" |");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -105,10 +105,10 @@ void StatusBarUpdate() {
|
|||||||
String16 string = ToString16(scratch, s);
|
String16 string = ToString16(scratch, s);
|
||||||
String16 string_to_replace = GetString(title.buffer, replace_range);
|
String16 string_to_replace = GetString(title.buffer, replace_range);
|
||||||
if (string_to_replace != string) {
|
if (string_to_replace != string) {
|
||||||
Command_SelectRangeOneCursor(title.view, replace_range);
|
SelectRange(title.view, replace_range);
|
||||||
Array<Edit> edits = Command_ReplaceEx(scratch, title.view, string);
|
Array<Edit> edits = ReplaceEx(scratch, title.view, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command_SelectRangeOneCursor(title.view, MakeRange(0));
|
SelectRange(title.view, MakeRange(0));
|
||||||
ResetHistory(title.buffer);
|
ResetHistory(title.buffer);
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ Int GetExpandingBarSize(Window *window) {
|
|||||||
void InitWindows() {
|
void InitWindows() {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
|
|
||||||
|
CreateWind();
|
||||||
CreateWind();
|
CreateWind();
|
||||||
|
|
||||||
// COMMAND BAR
|
// COMMAND BAR
|
||||||
@@ -34,6 +35,7 @@ void InitWindows() {
|
|||||||
window->sync_visibility_with_focus = true;
|
window->sync_visibility_with_focus = true;
|
||||||
window->lose_focus_on_escape = true;
|
window->lose_focus_on_escape = true;
|
||||||
window->jump_history = false;
|
window->jump_history = false;
|
||||||
|
view->fuzzy_search = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SEARCH BAR
|
// SEARCH BAR
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void DrawWindow(Window *window, Event &event) {
|
|||||||
Rect2 screen_rect = Rect0Size(event.xwindow, event.ywindow);
|
Rect2 screen_rect = Rect0Size(event.xwindow, event.ywindow);
|
||||||
SetScissor(screen_rect);
|
SetScissor(screen_rect);
|
||||||
|
|
||||||
bool is_active = window->id == ActiveWindow;
|
bool is_active = window->id == ActiveWindowID;
|
||||||
bool active_layed_out_doc = window->id == LastActiveLayoutWindowID;
|
bool active_layed_out_doc = window->id == LastActiveLayoutWindowID;
|
||||||
|
|
||||||
Color color_whitespace_during_selection = ColorWhitespaceDuringSelection;
|
Color color_whitespace_during_selection = ColorWhitespaceDuringSelection;
|
||||||
|
|||||||
Reference in New Issue
Block a user