Search bar anchor

This commit is contained in:
Krzosa Karol
2025-05-12 08:53:42 +02:00
parent a79f11d137
commit 872c46c43d
6 changed files with 23 additions and 22 deletions

View File

@@ -50,3 +50,12 @@ void WriteStdin(Process *process, String string);
void CloseStdin(Process *process);
double get_time_in_micros(void);
enum MakeDirResult {
MakeDirResult_Success,
MakeDirResult_Exists,
MakeDirResult_NotFound,
MakeDirResult_ErrorOther,
};
MakeDirResult MakeDir(String path);

View File

@@ -276,13 +276,6 @@ int64_t GetFileModTime(String file) {
}
}
enum MakeDirResult {
MakeDirResult_Success,
MakeDirResult_Exists,
MakeDirResult_NotFound,
MakeDirResult_ErrorOther,
};
MakeDirResult MakeDir(String path) {
Scratch scratch;
MakeDirResult result = MakeDirResult_Success;

View File

@@ -248,7 +248,6 @@ void Command_MoveCursorsByPageSize(Window *window, int direction, bool shift = f
BSet set = GetBSet(window);
CheckpointBeforeGoto(window);
Rect2I visible_cells_rect = GetVisibleCells(window);
Int y = GetSize(visible_cells_rect).y - 2;
if (direction == DIR_UP) y = -y;

View File

@@ -446,10 +446,12 @@ void OnCommand(Event event) {
} else if (AltShiftPress(SDLK_DOWN)) {
Command_CreateCursorVertical(active.view, DIR_DOWN);
} else if (CtrlShiftPress(SDLK_DOWN)) {
CheckpointBeforeGoto(active.window);
Command_Move(active.view, DIR_DOWN, CTRL_PRESSED, SHIFT_PRESSED);
} else if (AltPress(SDLK_DOWN)) {
Command_MoveLine(active.view, DIR_DOWN);
} else if (CtrlPress(SDLK_DOWN)) {
CheckpointBeforeGoto(active.window);
Command_Move(active.view, DIR_DOWN, CTRL_PRESSED);
} else if (ShiftPress(SDLK_DOWN)) {
Command_Move(active.view, DIR_DOWN, false, SHIFT_PRESSED);
@@ -462,10 +464,12 @@ void OnCommand(Event event) {
} else if (AltShiftPress(SDLK_UP)) {
Command_CreateCursorVertical(active.view, DIR_UP);
} else if (CtrlShiftPress(SDLK_UP)) {
CheckpointBeforeGoto(active.window);
Command_Move(active.view, DIR_UP, CTRL_PRESSED, SHIFT_PRESSED);
} else if (AltPress(SDLK_UP)) {
Command_MoveLine(active.view, DIR_UP);
} else if (CtrlPress(SDLK_UP)) {
CheckpointBeforeGoto(active.window);
Command_Move(active.view, DIR_UP, CTRL_PRESSED);
} else if (ShiftPress(SDLK_UP)) {
Command_Move(active.view, DIR_UP, false, SHIFT_PRESSED);
@@ -593,11 +597,15 @@ void OnCommand(Event event) {
Scratch scratch;
String16 search_string = GetSearchString(main.window);
Caret caret = FindPrev(main.buffer, search_string, main.view->carets[0]);
BSet search = GetBSet(main.window->search_bar_window);
search.window->search_bar_anchor = caret;
Command_SelectRangeOneCursor(main.view, caret);
} else if (Press(SDLK_F3)) {
Scratch scratch;
String16 search_string = GetSearchString(main.window);
Caret caret = FindNext(main.buffer, search_string, main.view->carets[0]);
BSet search = GetBSet(main.window->search_bar_window);
search.window->search_bar_anchor = caret;
Command_SelectRangeOneCursor(main.view, caret);
}
@@ -619,6 +627,7 @@ void OnCommand(Event event) {
}
Command_SelectEntireBuffer(search.view);
search.window->visible = 1;
search.window->search_bar_anchor = main.view->carets[0];
ActiveWindow = search.window->id;
}
}
@@ -719,6 +728,7 @@ void OnCommand(Event event) {
}
if (active.window->is_search_bar && buffer_change_id != active.buffer->change_id) {
main.view->carets[0] = active.window->search_bar_anchor;
Command_Find(main.view, GetSearchString(main.window), true);
}

View File

@@ -1,6 +1,6 @@
struct Window; struct View; struct WindowSplit;
struct ViewID { Int id; View *o; };
struct WindowID { Int id; Window *o; }; // @todo: change name of object to something scary
struct WindowID { Int id; Window *o; };
struct View {
@@ -47,6 +47,7 @@ struct Window {
ViewID active_goto_list;
Int goto_list_pos;
Caret search_bar_anchor;
double mouse_scroller_offset;
int z;
@@ -93,15 +94,6 @@ struct BSet {
Buffer *buffer;
};
enum MakeDirResult {
MakeDirResult_Success,
MakeDirResult_Exists,
MakeDirResult_NotFound,
MakeDirResult_ErrorOther,
};
MakeDirResult MakeDir(String path);
// @WARNING: be careful about using this, should only be used for debugging
// the problem with this is that we want events to be reproducible.
// We eat as many events as we can in a frame, we abstract the frame and so on.

View File

@@ -8,6 +8,7 @@
- Lua OnCommand should be able to comunicate that we don't want C handling and do only the Lua handling
- Easily programmable F1-F12 commands
- Lua namespaces for different kinds of commands (by ids, using main_set, using active_set)?
- List all files in project, exclude by lua pattern
- Set window layout using project file
- Split command
@@ -17,19 +18,16 @@
- Set active window using id
- Fix jump scroll, the query ends up the last line on screen, kind of wacky
- Fix Ctrl+1 Ctrl+2 (choosing window)
- Fix search, should have an anchor
- Use project file as working dir instead of scratch buffer path, separate project dir and project file
- Remedybg integration
- GetLine()
- in lua start debugging, jump to line, start debugger on file
- Enclose scope
- save all relevant buffers and build
- maybe most of the bindings should be in lua, but actual code in C
- maybe less code should be in lua ?? Lua code is very dodgey to change
- LoadWord, EncloseWord configurable?
- dump text editor state to file, restore state
- help menu popup when for example in process buffer, on tile bar buffer and stuff like that
- proper lister
- ask user if he really wants to quit even though he has an unsaved buffer - popup window | we could just show ForceClose() in the titlebar