Hook code cleanup
This commit is contained in:
@@ -11,7 +11,6 @@ How to go about search/replace, opening code and other considerations
|
|||||||
|
|
||||||
Use session 2
|
Use session 2
|
||||||
- Need configs I can't change browser or vcvarsall currently, maybe syntax like :Set InternetBrowser "firefox"
|
- Need configs I can't change browser or vcvarsall currently, maybe syntax like :Set InternetBrowser "firefox"
|
||||||
- BUILD annoying: Console or use the other window / the window which is already being used
|
|
||||||
- Tutorial
|
- Tutorial
|
||||||
- When jumping should center the view!!!
|
- When jumping should center the view!!!
|
||||||
|
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ BSet ExecBuild(String cmd) {
|
|||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
SelectRange(build.view, Range{});
|
SelectRange(build.view, Range{});
|
||||||
ResetBuffer(build.buffer);
|
ResetBuffer(build.buffer);
|
||||||
Exec(build.view->id, false, cmd, WorkDir); // NOTE: IN CASE WE MOVE THIS TO CONSOLE WINDOW, MAKE SURE TO SWITCH HERE the scrolling
|
Exec(build.view->id, true, cmd, WorkDir);
|
||||||
main.window->active_goto_list = build.view->id;
|
main.window->active_goto_list = build.view->id;
|
||||||
main.window->goto_list_pos = 0;
|
main.window->goto_list_pos = 0;
|
||||||
return build;
|
return build;
|
||||||
@@ -949,9 +949,6 @@ void Command_MakeFontSmaller() {
|
|||||||
|
|
||||||
void Command_Open() {
|
void Command_Open() {
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
if (active.window->id == CommandWindowID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Open(FetchLoadWord(active.view));
|
Open(FetchLoadWord(active.view));
|
||||||
} RegisterCommand(Command_Open, "ctrl-q");
|
} RegisterCommand(Command_Open, "ctrl-q");
|
||||||
|
|
||||||
@@ -1172,12 +1169,9 @@ void Command_InsertNewLineDown() {
|
|||||||
} RegisterCommand(Command_InsertNewLineDown, "ctrl-enter");
|
} RegisterCommand(Command_InsertNewLineDown, "ctrl-enter");
|
||||||
|
|
||||||
void Command_NewLine() {
|
void Command_NewLine() {
|
||||||
if (ActiveWindowID == CommandWindowID || ActiveWindowID == SearchWindowID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
IdentedNewLine(active.view);
|
IdentedNewLine(active.view);
|
||||||
} RegisterCommand(Command_NewLine, "enter");
|
} RegisterCommand(Command_NewLine, "enter | shift-enter");
|
||||||
|
|
||||||
void Command_CreateCaretOnNextFind() {
|
void Command_CreateCaretOnNextFind() {
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
|
|||||||
@@ -1,32 +1,3 @@
|
|||||||
void CommandWindowInit() {
|
|
||||||
Window *window = CreateWind();
|
|
||||||
CommandWindowID = window->id;
|
|
||||||
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "command_bar"));
|
|
||||||
buffer->special = true;
|
|
||||||
View *view = CreateView(buffer->id);
|
|
||||||
view->special = true;
|
|
||||||
window->active_view = view->id;
|
|
||||||
window->draw_line_numbers = false;
|
|
||||||
window->draw_scrollbar = false;
|
|
||||||
window->draw_darker = true;
|
|
||||||
window->draw_line_highlight = true;
|
|
||||||
window->layout = false;
|
|
||||||
window->visible = false;
|
|
||||||
window->sync_visibility_with_focus = true;
|
|
||||||
window->lose_focus_on_escape = true;
|
|
||||||
window->jump_history = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
|
||||||
Window *n = GetWindow(CommandWindowID);
|
|
||||||
Rect2I copy_rect = *rect;
|
|
||||||
if (!n->visible) {
|
|
||||||
rect = ©_rect;
|
|
||||||
}
|
|
||||||
Int barsize = Clamp((Int)n->font->line_spacing*10, (Int)0, (Int)wx - 100);
|
|
||||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t FuzzyRate(String16 string, String16 with) {
|
int32_t FuzzyRate(String16 string, String16 with) {
|
||||||
ProfileFunction();
|
ProfileFunction();
|
||||||
if (with.len == 0) return 0;
|
if (with.len == 0) return 0;
|
||||||
@@ -175,12 +146,39 @@ void OpenCommand(BSet active) {
|
|||||||
Open(string);
|
Open(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_OpenCommand() {
|
void Command_CommandWindowOpen() {
|
||||||
if (ActiveWindowID != CommandWindowID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BSet active = GetBSet(ActiveWindowID);
|
BSet active = GetBSet(ActiveWindowID);
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
NextActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
OpenCommand(active);
|
OpenCommand(active);
|
||||||
} RegisterCommand(Command_OpenCommand, "ctrl-q | enter");
|
}
|
||||||
|
|
||||||
|
void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||||
|
Window *n = GetWindow(CommandWindowID);
|
||||||
|
Rect2I copy_rect = *rect;
|
||||||
|
if (!n->visible) {
|
||||||
|
rect = ©_rect;
|
||||||
|
}
|
||||||
|
Int barsize = Clamp((Int)n->font->line_spacing*10, (Int)0, (Int)wx - 100);
|
||||||
|
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandWindowInit() {
|
||||||
|
Window *window = CreateWind();
|
||||||
|
CommandWindowID = window->id;
|
||||||
|
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "command_bar"));
|
||||||
|
buffer->special = true;
|
||||||
|
View *view = CreateView(buffer->id);
|
||||||
|
view->special = true;
|
||||||
|
window->active_view = view->id;
|
||||||
|
window->draw_line_numbers = false;
|
||||||
|
window->draw_scrollbar = false;
|
||||||
|
window->draw_darker = true;
|
||||||
|
window->draw_line_highlight = true;
|
||||||
|
window->layout = false;
|
||||||
|
window->visible = false;
|
||||||
|
window->sync_visibility_with_focus = true;
|
||||||
|
window->lose_focus_on_escape = true;
|
||||||
|
window->jump_history = false;
|
||||||
|
AddHook(&view->hooks, "Open", "ctrl-q | enter", Command_CommandWindowOpen);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,34 +1,3 @@
|
|||||||
void SearchWindowInit() {
|
|
||||||
Window *window = CreateWind();
|
|
||||||
SearchWindowID = window->id;
|
|
||||||
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "search"));
|
|
||||||
buffer->special = true;
|
|
||||||
SearchBufferID = buffer->id;
|
|
||||||
View *view = CreateView(buffer->id);
|
|
||||||
view->special = true;
|
|
||||||
SearchViewID = view->id;
|
|
||||||
window->active_view = view->id;
|
|
||||||
window->draw_line_numbers = false;
|
|
||||||
window->draw_scrollbar = false;
|
|
||||||
window->draw_darker = true;
|
|
||||||
window->draw_line_highlight = false;
|
|
||||||
window->layout = false;
|
|
||||||
window->visible = false;
|
|
||||||
window->lose_visibility_on_escape = true;
|
|
||||||
window->jump_history = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
|
||||||
Window *n = GetWindow(SearchWindowID);
|
|
||||||
Rect2I copy_rect = *rect;
|
|
||||||
if (!n->visible) {
|
|
||||||
rect = ©_rect;
|
|
||||||
}
|
|
||||||
Int barsize = GetExpandingBarSize(n);
|
|
||||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
|
||||||
n->line_numbers_rect = CutLeft(&n->document_rect, n->font->char_spacing * 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Command_Search() {
|
void Command_Search() {
|
||||||
BSet main = GetBSet(ActiveWindowID);
|
BSet main = GetBSet(ActiveWindowID);
|
||||||
String16 string = {};
|
String16 string = {};
|
||||||
@@ -54,18 +23,12 @@ void SearchWindowFindNext(bool forward = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Command_SearchNextInSearch() {
|
void Command_SearchNextInSearch() {
|
||||||
if (ActiveWindowID != SearchWindowID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SearchWindowFindNext(true);
|
SearchWindowFindNext(true);
|
||||||
} RegisterCommand(Command_SearchNextInSearch, "enter");
|
}
|
||||||
|
|
||||||
void Command_SearchPrevInSearch() {
|
void Command_SearchPrevInSearch() {
|
||||||
if (ActiveWindowID != SearchWindowID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SearchWindowFindNext(false);
|
SearchWindowFindNext(false);
|
||||||
} RegisterCommand(Command_SearchPrevInSearch, "shift-enter");
|
}
|
||||||
|
|
||||||
void Command_SearchNext() {
|
void Command_SearchNext() {
|
||||||
SearchWindowFindNext(true);
|
SearchWindowFindNext(true);
|
||||||
@@ -96,15 +59,6 @@ void Command_SearchAll() {
|
|||||||
set.window->visible = false;
|
set.window->visible = false;
|
||||||
} RegisterCommand(Command_SearchAll, "alt-f3");
|
} RegisterCommand(Command_SearchAll, "alt-f3");
|
||||||
|
|
||||||
void Command_SearchAllInSearch() {
|
|
||||||
if (ActiveWindowID != SearchWindowID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SearchAll();
|
|
||||||
BSet set = GetBSet(SearchWindowID);
|
|
||||||
set.window->visible = false;
|
|
||||||
} RegisterCommand(Command_SearchAllInSearch, "alt-enter");
|
|
||||||
|
|
||||||
void Command_ToggleCaseSensitiveSearch() {
|
void Command_ToggleCaseSensitiveSearch() {
|
||||||
SearchCaseSensitive = !SearchCaseSensitive;
|
SearchCaseSensitive = !SearchCaseSensitive;
|
||||||
} RegisterCommand(Command_ToggleCaseSensitiveSearch, "alt-c");
|
} RegisterCommand(Command_ToggleCaseSensitiveSearch, "alt-c");
|
||||||
@@ -123,3 +77,37 @@ void SearchWindowUpdate() {
|
|||||||
Find(main.view, seek, true);
|
Find(main.view, seek, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||||
|
Window *n = GetWindow(SearchWindowID);
|
||||||
|
Rect2I copy_rect = *rect;
|
||||||
|
if (!n->visible) {
|
||||||
|
rect = ©_rect;
|
||||||
|
}
|
||||||
|
Int barsize = GetExpandingBarSize(n);
|
||||||
|
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||||
|
n->line_numbers_rect = CutLeft(&n->document_rect, n->font->char_spacing * 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchWindowInit() {
|
||||||
|
Window *window = CreateWind();
|
||||||
|
SearchWindowID = window->id;
|
||||||
|
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "search"));
|
||||||
|
buffer->special = true;
|
||||||
|
SearchBufferID = buffer->id;
|
||||||
|
View *view = CreateView(buffer->id);
|
||||||
|
view->special = true;
|
||||||
|
SearchViewID = view->id;
|
||||||
|
window->active_view = view->id;
|
||||||
|
window->draw_line_numbers = false;
|
||||||
|
window->draw_scrollbar = false;
|
||||||
|
window->draw_darker = true;
|
||||||
|
window->draw_line_highlight = false;
|
||||||
|
window->layout = false;
|
||||||
|
window->visible = false;
|
||||||
|
window->lose_visibility_on_escape = true;
|
||||||
|
window->jump_history = false;
|
||||||
|
AddHook(&view->hooks, "SearchAll", "alt-enter", Command_SearchAll);
|
||||||
|
AddHook(&view->hooks, "SearchPrevInSearch", "shift-enter", Command_SearchPrevInSearch);
|
||||||
|
AddHook(&view->hooks, "SearchNextInSearch", "enter", Command_SearchNextInSearch);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user