Underline enclose word of main cursor and fix Enclose word

This commit is contained in:
Krzosa Karol
2024-08-03 08:45:49 +02:00
parent e4a248bb60
commit 6c975b98a1
7 changed files with 26 additions and 3 deletions

View File

@@ -374,6 +374,7 @@ void GenerateConfig() {
Array<Var> colors = {};
colors.add({"Text", "GruvboxDark0Hard"});
colors.add({"TextUnderline", "GruvboxDark0Hard"});
colors.add({"Background", "GruvboxLight0Hard"});
colors.add({"InactiveWindow", "0x0000000F"});
colors.add({"TextLineNumbers", "GruvboxDark4"});

View File

@@ -86,7 +86,7 @@ Int MoveOnWhitespaceBoundaryForward(Buffer &buffer, Int pos) {
}
Int MoveOnWhitespaceBoundaryBackward(Buffer &buffer, Int pos) {
pos = Clamp(pos - 1, (Int)0, buffer.len);
pos = Clamp(pos, (Int)0, buffer.len);
bool standing_on_whitespace = IsWhitespace(buffer.str[pos]);
bool standing_on_symbol = IsSymbol(buffer.str[pos]);
bool standing_on_word = !standing_on_whitespace && !standing_on_symbol;

View File

@@ -621,7 +621,7 @@ void WindowCommand(Event event, Window *window, View *view) {
*c = ChangeFront(*c, p);
} else if (mouse_in_document && Mouse(LEFT) && event.mouse_double_click) {
Caret *c = &view->carets[0];
if (InBounds({c->range.min, c->range.max + 1}, p)) {
if (InBounds({c->range.min - 1, c->range.max + 1}, p)) {
c->range = EncloseWord(*buffer, p);
view->selection_anchor = c->range;
} else {

View File

@@ -38,6 +38,7 @@ local GruvboxFadedAqua = 0x427b58ff
local GruvboxFadedOrange = 0xaf3a03ff
Color = {}
Color.Text = GruvboxDark0Hard
Color.TextUnderline = GruvboxDark0Hard
Color.Background = GruvboxLight0Hard
Color.InactiveWindow = 0x0000000F
Color.TextLineNumbers = GruvboxDark4
@@ -197,6 +198,7 @@ end
)==";
void ReloadStyle() {
ColorText = GetColor("Text", ColorText);
ColorTextUnderline = GetColor("TextUnderline", ColorTextUnderline);
ColorBackground = GetColor("Background", ColorBackground);
ColorInactiveWindow = GetColor("InactiveWindow", ColorInactiveWindow);
ColorTextLineNumbers = GetColor("TextLineNumbers", ColorTextLineNumbers);

View File

@@ -36,6 +36,7 @@ Color GruvboxFadedPurple = {0x8f, 0x3f, 0x71, 0xff};
Color GruvboxFadedAqua = {0x42, 0x7b, 0x58, 0xff};
Color GruvboxFadedOrange = {0xaf, 0x3a, 0x03, 0xff};
Color ColorText = GruvboxDark0Hard;
Color ColorTextUnderline = GruvboxDark0Hard;
Color ColorBackground = GruvboxLight0Hard;
Color ColorInactiveWindow = {0x00, 0x00, 0x00, 0x0F};
Color ColorTextLineNumbers = GruvboxDark4;

View File

@@ -4,7 +4,6 @@
- don't trim lines with cursor or selection on it
- search backwards
- underline the word which can be loaded / executed
- load selected string or auto enclosed word when midclick?, ctrl + click, ctrl + e?
- experiment with using multiple cursors to select command and it's input
- search as a command to execute which is going to be in the title bar

View File

@@ -167,6 +167,26 @@ void DrawWindow(Window *window) {
}
}
{
Caret caret = view->carets[0];
if (GetSize(caret.range) == 0) {
Int pos = caret.range.min;
if (pos < buffer->len && !IsWhitespace(buffer->str[pos])) {
Range range = EncloseWord(*buffer, pos);
XY xy_min = PosToXY(*buffer, range.min);
XY xy_max = PosToXY(*buffer, range.max);
Vec2I min = {xy_min.col * FontCharSpacing, (xy_min.line + 1) * FontLineSpacing - 2};
Vec2I max = {xy_max.col * FontCharSpacing, (xy_max.line + 1) * FontLineSpacing};
Rect2I rect = {min, max};
rect -= view->scroll;
rect += window->document_rect.min;
DrawRect(rect, ColorTextUnderline);
}
}
}
if (window->fuzzy_search) {
Caret it = view->carets[0];
Int front = GetFront(it);