Remove search window

This commit is contained in:
Krzosa Karol
2024-08-09 16:28:50 +02:00
parent 65ef0b1b0f
commit 93cfe71c21
7 changed files with 26 additions and 93 deletions

View File

@@ -225,7 +225,7 @@ function SkipLineAndColumn(s)
return line, col, s
end
local function SkipSlashes(s)
function SkipSlashes(s)
found_slash = false
while s:sub(1,1) == '/' or s:sub(1,1) == '\\' do
s = s:sub(2)
@@ -234,7 +234,7 @@ local function SkipSlashes(s)
return s, found_slash
end
local function SkipDrive(s)
function SkipDrive(s)
local i, j = s:find("^%a:")
if not i then return s, nil, true end
@@ -247,7 +247,7 @@ local function SkipDrive(s)
return new_s, drive, true
end
local function SkipPathCell(s)
function SkipPathCell(s)
local i, j = s:find("^[%w_%.-% +]+")
if not i then return s, nil, false end
@@ -258,7 +258,7 @@ local function SkipPathCell(s)
return new_s, word, found_slash
end
local function SkipPath(s)
function SkipPath(s)
local input_s = s
local s, drive, ok = SkipDrive(s)
if not ok then return s end
@@ -325,6 +325,9 @@ function ApplyRules(s)
end
function OnUpdate()
-- @todo: implement coroutine dispatch here
-- probably also want constatnly rerunning jobs with a set wake up time
-- @warning: make sure to not rewrite the thread list when rerunning this file
end
)==";

View File

@@ -457,19 +457,6 @@ bool GlobalCommand(Event event) {
run_window_command = false;
}
if (Ctrl(SDLK_F)) {
Window *search_window = GetWindow(SearchWindowID);
if (search_window->visible) {
SetActiveWindow(GetLastActiveWindow());
} else {
SetActiveWindow(search_window->id);
View *view = GetActiveView(search_window);
Command_SelectEntireBuffer(view);
Command_Replace(view, {});
}
run_window_command = false;
}
if (Ctrl(SDLK_1)) {
Window *window = GetLayoutWindow(0);
if (window) SetActiveWindow(window->id);

View File

@@ -768,29 +768,6 @@ void WindowCommand(Event event, Window *window, View *view) {
view->carets[0] = caret;
}
if (window->id == SearchWindowID) {
Window *seek_window = GetWindow(GetLastActiveWindow());
View *seek_view = GetView(seek_window->active_view);
Buffer *seek_buffer = GetBuffer(seek_view->active_buffer);
String16 needle = GetString(*buffer);
if (search) {
seek_view->carets[0] = FindInBuffer(seek_buffer, needle, seek_view->carets[0]);
seek_view->carets.len = 1;
}
if (Alt(SDLK_RETURN)) {
Command_SelectAll(seek_view, needle);
SetActiveWindow(seek_window->id);
} else if (Ctrl(SDLK_RETURN)) {
Caret caret = FindInBuffer(seek_buffer, needle, seek_view->carets[0], true);
Insert(&seek_view->carets, caret, 0);
MergeCarets(seek_view);
} else if (Press(SDLK_RETURN)) {
Caret caret = FindInBuffer(seek_buffer, needle, seek_view->carets[0], true);
seek_view->carets.len = 1;
seek_view->carets[0] = caret;
}
}
if (view->fuzzy_search && search) {
Scratch scratch;
String16 first_line_string = GetLineStringWithoutNL(*buffer, 0);
@@ -826,7 +803,6 @@ void WindowCommand(Event event, Window *window, View *view) {
Command_SelectRangeOneCursor(view, GetLineRangeWithoutNL(*buffer, 0));
Command_Replace(view, {});
}
} else if (window->id == SearchWindowID) {
} else {
if (CtrlShift(SDLK_RETURN)) {
Command_MoveCursorsToSide(view, DIR_LEFT);

View File

@@ -114,7 +114,7 @@ function SkipLineAndColumn(s)
return line, col, s
end
local function SkipSlashes(s)
function SkipSlashes(s)
found_slash = false
while s:sub(1,1) == '/' or s:sub(1,1) == '\\' do
s = s:sub(2)
@@ -123,7 +123,7 @@ local function SkipSlashes(s)
return s, found_slash
end
local function SkipDrive(s)
function SkipDrive(s)
local i, j = s:find("^%a:")
if not i then return s, nil, true end
@@ -136,7 +136,7 @@ local function SkipDrive(s)
return new_s, drive, true
end
local function SkipPathCell(s)
function SkipPathCell(s)
local i, j = s:find("^[%w_%.-% +]+")
if not i then return s, nil, false end
@@ -147,7 +147,7 @@ local function SkipPathCell(s)
return new_s, word, found_slash
end
local function SkipPath(s)
function SkipPath(s)
local input_s = s
local s, drive, ok = SkipDrive(s)
if not ok then return s end
@@ -214,6 +214,9 @@ function ApplyRules(s)
end
function OnUpdate()
-- @todo: implement coroutine dispatch here
-- probably also want constatnly rerunning jobs with a set wake up time
-- @warning: make sure to not rewrite the thread list when rerunning this file
end

View File

@@ -38,7 +38,7 @@ String GetUniqueBufferName(Allocator allocator, String working_dir, String p
void ExecInNewBuffer(String cmd, String working_dir) {
Scratch scratch;
CheckpointBeforeGoto(GetLastActiveWindow());
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+CMD");
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+cmd-");
Window *window = GetWindow(GetLastActiveWindow());
View *view = WindowOpenBufferView(window, buffer_name);
Buffer *buffer = GetBuffer(view->active_buffer);
@@ -138,7 +138,7 @@ int LuaListBuffers(lua_State *L) {
Scratch scratch;
Array<String> strings = {scratch};
For(Buffers) {
if (StartsWith(it.name, "+Titlebar")) continue;
if (StartsWith(it.name, "+titlebar")) continue;
String string = Format(scratch, "%.*s", FmtString(it.name));
Add(&strings, string);
}
@@ -159,7 +159,7 @@ int LuaGetBufferList(lua_State *L) {
int i = 1;
For(Buffers) {
if (StartsWith(it.name, "+Titlebar")) continue;
if (StartsWith(it.name, "+titlebar")) continue;
lua_pushinteger(L, i++);
lua_pushlstring(L, it.name.data, it.name.len);
lua_settable(L, -3); /* 3rd element from the stack top */

View File

@@ -10,7 +10,6 @@ WindowID NullWindowID;
BufferID NullBufferID;
ViewID NullViewID;
WindowID CommandWindowID;
WindowID SearchWindowID;
WindowID PopupWindowID;
WindowID DebugWindowID;
WindowID ConsoleWindowID;

View File

@@ -47,7 +47,7 @@ Window *CreateTitlebar(WindowID parent_window_id) {
static int TitlebarCount;
Allocator sys_allocator = GetSystemAllocator();
String name = Format(sys_allocator, "+Titlebar%d", ++TitlebarCount);
String name = Format(sys_allocator, "+titlebar%d", ++TitlebarCount);
Buffer *b = CreateBuffer(sys_allocator, name);
View *v = CreateView(b->id);
@@ -73,7 +73,7 @@ Int GetTitleBarSize(Window *window) {
void AddColumnWindow() {
Window *window = CreateWindow();
window->is_column = true;
View *view = OpenBufferView("+Scratch");
View *view = OpenBufferView("+scratch");
window->active_view = view->id;
CreateTitlebar(window->id);
}
@@ -82,7 +82,7 @@ void AddRowWindow() {
Window *window = CreateWindow();
WindowID window_id = window->id;
View *view = OpenBufferView("+Scratch");
View *view = OpenBufferView("+scratch");
window->active_view = view->id;
CreateTitlebar(window->id);
@@ -121,7 +121,7 @@ String BuffCWD(String string) {
void InitScratchBuffer() {
Allocator sys_allocator = GetSystemAllocator();
Buffer *null_buffer = CreateBuffer(sys_allocator, BuffCWD("+Scratch"));
Buffer *null_buffer = CreateBuffer(sys_allocator, BuffCWD("+scratch"));
View *null_view = CreateView(null_buffer->id);
}
@@ -138,7 +138,7 @@ void InitWindows() {
WindowID window_id = window->id;
window->is_column = true;
// window->draw_line_numbers = false;
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("+TestBuffer"));
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("+test_buffer"));
View *view = CreateView(buffer->id);
// LoadTextA(buffer);
LoadUnicode(buffer);
@@ -157,7 +157,7 @@ void InitWindows() {
window->absolute_position = true;
window->dont_save_in_active_window_history = true;
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("+Console"));
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("+console"));
// buffer->no_history = true;
View *view = CreateView(buffer->id);
@@ -180,7 +180,7 @@ void InitWindows() {
window->visible = false;
window->z = 2;
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("+Debug"));
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("+debug"));
DebugBufferID = buffer->id;
buffer->no_history = true;
@@ -203,7 +203,7 @@ void InitWindows() {
w->absolute_position = true;
w->dont_save_in_active_window_history = true;
w->deactivate_on_escape = true;
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("+Commands"));
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("+commands"));
View *v = CreateView(b->id);
v->fuzzy_search = true;
@@ -217,27 +217,6 @@ void InitWindows() {
CommandWindowID = window_id;
}
{
Window *w = CreateWindow();
WindowID window_id = w->id;
w->draw_scrollbar = false;
w->draw_line_numbers = false;
w->visible = false;
w->absolute_position = true;
w->dont_save_in_active_window_history = true;
w->invisible_when_inactive = true;
w->deactivate_on_escape = true;
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("+Search"));
View *v = CreateView(b->id);
w->active_view = v->id;
CreateTitlebar(window_id);
SetVisibility(window_id, false);
SearchBufferID = b->id;
SearchWindowID = window_id;
}
{
Window *w = CreateWindow();
WindowID window_id = w->id;
@@ -250,7 +229,7 @@ void InitWindows() {
w->absolute_position = true;
w->deactivate_on_escape = true;
w->z = 2;
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("+Popup"));
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("+popup"));
b->no_history = true;
View *v = CreateView(b->id);
w->active_view = v->id;
@@ -285,20 +264,6 @@ void LayoutWindows() {
}
}
{
Window *window = GetWindow(SearchWindowID);
if (window->visible) {
Rect2I rect = CutBottom(&screen_rect, FontLineSpacing);
window->total_rect = rect;
Window *title_bar_window = GetWindow(window->title_bar_window);
title_bar_window->total_rect = CutLeft(&window->total_rect, (Int)(FontCharSpacing * 14));
title_bar_window->document_rect = title_bar_window->total_rect;
window->document_rect = window->total_rect;
}
}
Scratch scratch;
Array<VisualColumn> columns = GetVisualColumns(scratch);