Hook code cleanup
This commit is contained in:
@@ -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) {
|
||||
ProfileFunction();
|
||||
if (with.len == 0) return 0;
|
||||
@@ -175,12 +146,39 @@ void OpenCommand(BSet active) {
|
||||
Open(string);
|
||||
}
|
||||
|
||||
void Command_OpenCommand() {
|
||||
if (ActiveWindowID != CommandWindowID) {
|
||||
return;
|
||||
}
|
||||
void Command_CommandWindowOpen() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user