Search now has title bar, title bars now have history

This commit is contained in:
Krzosa Karol
2024-08-02 14:51:40 +02:00
parent 48dc808dcb
commit 7fc8e6e8bb
4 changed files with 28 additions and 27 deletions

View File

@@ -369,7 +369,7 @@ void GenerateConfig() {
colors.add({"Selection" , "GruvboxLight1"});
colors.add({"WhitespaceDuringSelection", "GruvboxLight4"});
colors.add({"FuzzySearchLineHighlight", "GruvboxLight4"});
colors.add({"FuzzySearchLineHighlight", "GruvboxDark0"});
colors.add({"ScrollbarBackground" , "GruvboxLight2"});
colors.add({"ScrollbarScroller" , "GruvboxLight1"});

View File

@@ -175,13 +175,6 @@ void Command_EvalLua(View *view, String16 string) {
}
}
void Command_EvalLuaLine(View *view) {
Buffer *buffer = GetBuffer(view->active_buffer);
Int line = PosToLine(*buffer, GetFront(view->carets[0]));
String16 string = GetLineStringWithoutNL(*buffer, line);
Command_EvalLua(view, string);
}
// Merge carets that overlap, this needs to be handled before any edits to
// make sure overlapping edits won't happen.
//
@@ -348,15 +341,18 @@ void ReplaceTitleBarData(Window *window) {
String16 buffer_string = GetString(*buffer);
Range replace_range = {0, buffer->len};
if (!Seek(buffer_string, L" |", &replace_range.max)) {
ReplaceText(buffer, GetEndAsRange(*buffer), L" |");
Command_SelectRangeOneCursor(view, GetEndAsRange(*buffer));
Command_Replace(view, L" |");
}
// String s = Format(scratch, " %lld:%lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll);
String s = Format(scratch, "%.*s:%lld:%lld", FmtString(last_buffer->name), (long long)xy.line + 1ll, (long long)xy.col + 1ll);
String16 string = ToString16(scratch, s);
ReplaceText(buffer, replace_range, string);
Command_SelectRangeOneCursor(view, {});
String s = Format(scratch, "%.*s:%lld:%lld", FmtString(last_buffer->name), (long long)xy.line + 1ll, (long long)xy.col + 1ll);
String16 string = ToString16(scratch, s);
String16 string_to_replace = GetString(*buffer, replace_range);
if (string_to_replace != string) {
Command_SelectRangeOneCursor(view, replace_range);
Command_Replace(view, string);
Command_SelectRangeOneCursor(view, {});
}
}
void WindowCommand(Event event, Window *window, View *view) {

View File

@@ -44,7 +44,7 @@ Color ColorMainCaret = GruvboxDark0Hard;
Color ColorSubCaret = GruvboxGray245;
Color ColorSelection = GruvboxLight1;
Color ColorWhitespaceDuringSelection = GruvboxLight4;
Color ColorFuzzySearchLineHighlight = GruvboxLight4;
Color ColorFuzzySearchLineHighlight = GruvboxDark0;
Color ColorScrollbarBackground = GruvboxLight2;
Color ColorScrollbarScroller = GruvboxLight1;
Color ColorScrollbarScrollerSelected = GruvboxLight0Hard;
@@ -99,7 +99,7 @@ Color.MainCaret = GruvboxDark0Hard
Color.SubCaret = GruvboxGray245
Color.Selection = GruvboxLight1
Color.WhitespaceDuringSelection = GruvboxLight4
Color.FuzzySearchLineHighlight = GruvboxLight4
Color.FuzzySearchLineHighlight = GruvboxDark0
Color.ScrollbarBackground = GruvboxLight2
Color.ScrollbarScroller = GruvboxLight1
Color.ScrollbarScrollerSelected = GruvboxLight0Hard

View File

@@ -29,9 +29,8 @@ Array<Int> GetWindowZOrder(Allocator allocator) {
}
Window *CreateInfobar(Window *parent_window) {
Window *window = CreateWindow();
window->draw_scrollbar = false;
// window->draw_line_numbers = false;
Window *window = CreateWindow();
window->draw_scrollbar = false;
window->dont_save_in_active_window_history = true;
window->deactivate_on_escape = true;
window->is_title_bar = true;
@@ -41,8 +40,7 @@ Window *CreateInfobar(Window *parent_window) {
String name = Format(sys_allocator, "*infobar%d", ++InfobarCount);
Buffer *b = CreateBuffer(sys_allocator, name);
b->no_history = true;
View *v = CreateView(b->id);
View *v = CreateView(b->id);
window->active_view = v->id;
SetActiveView(window, v->id);
@@ -186,6 +184,8 @@ void InitWindows(View *null_view) {
Buffer *b = CreateBuffer(sys_allocator, "*search*");
View *v = CreateView(b->id);
SetActiveView(w, v->id);
CreateInfobar(w);
SetVisibility(w, false);
SearchWindowID = w->id;
}
@@ -233,11 +233,16 @@ void LayoutWindows() {
}
}
Window *search_window = GetWindow(SearchWindowID);
if (search_window->visible) {
Rect2I rect = CutBottom(&screen_rect, FontLineSpacing);
search_window->total_rect = rect;
search_window->document_rect = search_window->total_rect;
{
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;