Ctrl-f fills with currently selected

This commit is contained in:
Krzosa Karol
2025-12-26 11:57:09 +01:00
parent 5c46844747
commit 509db7af46
5 changed files with 18 additions and 4 deletions

View File

@@ -1,7 +1,9 @@
- What precise workflow do I need for me to be viable to use this? - What precise workflow do I need for me to be viable to use this?
- From a user (novice) point of view, how does it look like? - From a user (novice) point of view, how does it look like?
- Open with seek string (open at pattern) filename:32 filename:/^Window$/
- ctrl+f should insert selected text into search
- Do we need constrained jump history????? So that we can finally collect garbage buffers at some point. Or maybe only constrained to garbage buffers
- build console window - build console window
- Show what process/coroutines are running and allow to kill (active process buffer?) - Show what process/coroutines are running and allow to kill (active process buffer?)
- Database idea: use special buffers to store information - Database idea: use special buffers to store information

View File

@@ -103,6 +103,10 @@ API Int GetMin(Caret caret) {
return result; return result;
} }
API Int GetSize(Caret caret) {
return GetSize(caret.range);
}
API Caret MakeCaret(Int pos) { API Caret MakeCaret(Int pos) {
Caret result = {}; Caret result = {};
result.range.min = result.range.max = pos; result.range.min = result.range.max = pos;

View File

@@ -35,8 +35,7 @@ String GetMainDir() {
void JumpGarbageBuffer(BSet *set, String buffer_name = "") { void JumpGarbageBuffer(BSet *set, String buffer_name = "") {
CheckpointBeforeGoto(set->window); CheckpointBeforeGoto(set->window);
if (buffer_name.len == 0) { if (buffer_name.len == 0) {
String current_dir = ChopLastSlash(set->buffer->name); buffer_name = GetUniqueBufferName(GetDir(set->buffer), "temp");
buffer_name = GetUniqueBufferName(current_dir, "temp");
} }
set->view = WindowOpenBufferView(set->window, buffer_name); set->view = WindowOpenBufferView(set->window, buffer_name);
set->buffer = GetBuffer(set->view->active_buffer); set->buffer = GetBuffer(set->view->active_buffer);

View File

@@ -160,7 +160,7 @@ void Command_ShowBufferList() {
ActiveWindowID = command_bar.window->id; ActiveWindowID = command_bar.window->id;
ResetBuffer(command_bar.buffer); ResetBuffer(command_bar.buffer);
For (Buffers) { For (Buffers) {
if (it->special) { if (it->special || it->garbage) {
continue; continue;
} }
RawAppendf(command_bar.buffer, "\n%S", it->name); RawAppendf(command_bar.buffer, "\n%S", it->name);

View File

@@ -33,10 +33,19 @@ void SearchWindowLayout(Rect2I *rect, Int wx, Int wy) {
} }
void Command_Search() { void Command_Search() {
BSet main = GetBSet(ActiveWindowID);
String16 string = {};
if (main.view->carets.len == 1 && GetSize(main.view->carets[0]) > 0) {
string = GetString(main.buffer, main.view->carets[0].range);
}
BSet set = GetBSet(SearchWindowID); BSet set = GetBSet(SearchWindowID);
set.window->visible = true; set.window->visible = true;
ActiveWindowID = SearchWindowID; ActiveWindowID = SearchWindowID;
SelectEntireBuffer(set.view); SelectEntireBuffer(set.view);
if (string.len > 0) {
Replace(set.view, string);
SelectEntireBuffer(set.view);
}
} RegisterCommand(Command_Search, "ctrl-f"); } RegisterCommand(Command_Search, "ctrl-f");
void SearchWindowFindNext(bool forward = true) { void SearchWindowFindNext(bool forward = true) {