Don't draw carets when inactive, todo update

This commit is contained in:
Krzosa Karol
2024-07-28 21:43:33 +02:00
parent 12b459507a
commit c48abbf5c9
7 changed files with 53 additions and 152 deletions

View File

@@ -180,9 +180,13 @@ int CompileNewPlatform() {
return result;
}
char *ToColor(const char *value) {
S8_String f = Fmt("{0x%.*s, 0x%.*s, 0x%.*s, 0x%.*s}", 2, value + 2, 2, value + 4, 2, value + 6, 2, value + 8);
return f.str;
char *C(const char *value) {
if (value[0] == '0' && value[1] == 'x') {
S8_String f = Fmt("{0x%.*s, 0x%.*s, 0x%.*s, 0x%.*s}", 2, value + 2, 2, value + 4, 2, value + 6, 2, value + 8);
return f.str;
} else {
return (char *)value;
}
}
S8_String LuaScript = R"==(
@@ -354,12 +358,10 @@ void GenerateConfig() {
gruvbox.add({"GruvboxFadedAqua" , "0x427b58ff"});
gruvbox.add({"GruvboxFadedOrange" , "0xaf3a03ff"});
gruvbox.add({"_InactiveWindowColor" , "0x0000000F"});
Array<Color> colors = {};
colors.add({"Text" , "GruvboxDark0Hard"});
colors.add({"Background" , "GruvboxLight0Hard"});
colors.add({"InactiveWindow" , "_InactiveWindowColor"});
colors.add({"InactiveWindow" , "0x0000000F"});
// colors.add({"TabText" , "GruvboxDark0Hard"});
// colors.add({"TabBackground" , "GruvboxLight0Hard"});
// colors.add({"TabBackgroundInactive" , "GruvboxLight2"});
@@ -379,8 +381,8 @@ void GenerateConfig() {
MA_Scratch scratch;
Array<S8_String> sb = {MA_GetAllocator(scratch)};
{
For(gruvbox) sb.add(Fmt("Color %s = %s;", it.name, ToColor(it.value)));
For(colors) sb.add(Fmt("Color Color%s = %s;", it.name, it.value));
For(gruvbox) sb.add(Fmt("Color %s = %s;", it.name, C(it.value)));
For(colors) sb.add(Fmt("Color Color%s = %s;", it.name, C(it.value)));
}
sb.add("String BaseLuaConfig = R\"==(");
{

View File

@@ -1,106 +0,0 @@
Color GruvboxDark0Hard = {0x1d, 0x20, 0x21, 0xff};
Color GruvboxDark0 = {0x28, 0x28, 0x28, 0xff};
Color GruvboxDark0Soft = {0x32, 0x30, 0x2f, 0xff};
Color GruvboxDark1 = {0x3c, 0x38, 0x36, 0xff};
Color GruvboxDark2 = {0x50, 0x49, 0x45, 0xff};
Color GruvboxDark3 = {0x66, 0x5c, 0x54, 0xff};
Color GruvboxDark4 = {0x7c, 0x6f, 0x64, 0xff};
Color GruvboxGray245 = {0x92, 0x83, 0x74, 0xff};
Color GruvboxGray244 = {0x92, 0x83, 0x74, 0xff};
Color GruvboxLight0Hard = {0xf9, 0xf5, 0xd7, 0xff};
Color GruvboxLight0 = {0xfb, 0xf1, 0xc7, 0xff};
Color GruvboxLight0Soft = {0xf2, 0xe5, 0xbc, 0xff};
Color GruvboxLight1 = {0xeb, 0xdb, 0xb2, 0xff};
Color GruvboxLight2 = {0xd5, 0xc4, 0xa1, 0xff};
Color GruvboxLight3 = {0xbd, 0xae, 0x93, 0xff};
Color GruvboxLight4 = {0xa8, 0x99, 0x84, 0xff};
Color GruvboxBrightRed = {0xfb, 0x49, 0x34, 0xff};
Color GruvboxBrightGreen = {0xb8, 0xbb, 0x26, 0xff};
Color GruvboxBrightYellow = {0xfa, 0xbd, 0x2f, 0xff};
Color GruvboxBrightBlue = {0x83, 0xa5, 0x98, 0xff};
Color GruvboxBrightPurple = {0xd3, 0x86, 0x9b, 0xff};
Color GruvboxBrightAqua = {0x8e, 0xc0, 0x7c, 0xff};
Color GruvboxBrightOrange = {0xfe, 0x80, 0x19, 0xff};
Color GruvboxNeutralRed = {0xcc, 0x24, 0x1d, 0xff};
Color GruvboxNeutralGreen = {0x98, 0x97, 0x1a, 0xff};
Color GruvboxNeutralYellow = {0xd7, 0x99, 0x21, 0xff};
Color GruvboxNeutralBlue = {0x45, 0x85, 0x88, 0xff};
Color GruvboxNeutralPurple = {0xb1, 0x62, 0x86, 0xff};
Color GruvboxNeutralAqua = {0x68, 0x9d, 0x6a, 0xff};
Color GruvboxNeutralOrange = {0xd6, 0x5d, 0x0e, 0xff};
Color GruvboxFadedRed = {0x9d, 0x00, 0x06, 0xff};
Color GruvboxFadedGreen = {0x79, 0x74, 0x0e, 0xff};
Color GruvboxFadedYellow = {0xb5, 0x76, 0x14, 0xff};
Color GruvboxFadedBlue = {0x07, 0x66, 0x78, 0xff};
Color GruvboxFadedPurple = {0x8f, 0x3f, 0x71, 0xff};
Color GruvboxFadedAqua = {0x42, 0x7b, 0x58, 0xff};
Color GruvboxFadedOrange = {0xaf, 0x3a, 0x03, 0xff};
Color ColorText = GruvboxDark0Hard;
Color ColorBackground = GruvboxLight0Hard;
Color ColorTextLineNumbers = GruvboxDark4;
Color ColorScrollbarBackground = GruvboxLight2;
Color ColorScrollbarScroller = GruvboxLight1;
Color ColorScrollbarScrollerSelected = GruvboxLight0Hard;
Color ColorLineHighlight = GruvboxLight1;
Color ColorMainCaret = GruvboxDark0Hard;
Color ColorSubCaret = GruvboxGray245;
Color ColorSelection = GruvboxLight1;
Color ColorWhitespaceDuringSelection = GruvboxLight2;
String BaseLuaConfig = R"==(
local GruvboxDark0Hard = 0x1d2021ff
local GruvboxDark0 = 0x282828ff
local GruvboxDark0Soft = 0x32302fff
local GruvboxDark1 = 0x3c3836ff
local GruvboxDark2 = 0x504945ff
local GruvboxDark3 = 0x665c54ff
local GruvboxDark4 = 0x7c6f64ff
local GruvboxGray245 = 0x928374ff
local GruvboxGray244 = 0x928374ff
local GruvboxLight0Hard = 0xf9f5d7ff
local GruvboxLight0 = 0xfbf1c7ff
local GruvboxLight0Soft = 0xf2e5bcff
local GruvboxLight1 = 0xebdbb2ff
local GruvboxLight2 = 0xd5c4a1ff
local GruvboxLight3 = 0xbdae93ff
local GruvboxLight4 = 0xa89984ff
local GruvboxBrightRed = 0xfb4934ff
local GruvboxBrightGreen = 0xb8bb26ff
local GruvboxBrightYellow = 0xfabd2fff
local GruvboxBrightBlue = 0x83a598ff
local GruvboxBrightPurple = 0xd3869bff
local GruvboxBrightAqua = 0x8ec07cff
local GruvboxBrightOrange = 0xfe8019ff
local GruvboxNeutralRed = 0xcc241dff
local GruvboxNeutralGreen = 0x98971aff
local GruvboxNeutralYellow = 0xd79921ff
local GruvboxNeutralBlue = 0x458588ff
local GruvboxNeutralPurple = 0xb16286ff
local GruvboxNeutralAqua = 0x689d6aff
local GruvboxNeutralOrange = 0xd65d0eff
local GruvboxFadedRed = 0x9d0006ff
local GruvboxFadedGreen = 0x79740eff
local GruvboxFadedYellow = 0xb57614ff
local GruvboxFadedBlue = 0x076678ff
local GruvboxFadedPurple = 0x8f3f71ff
local GruvboxFadedAqua = 0x427b58ff
local GruvboxFadedOrange = 0xaf3a03ff
Color = {}
Color.Text = GruvboxDark0Hard
Color.Background = GruvboxLight0Hard
Color.TextLineNumbers = GruvboxDark4
Color.ScrollbarBackground = GruvboxLight2
Color.ScrollbarScroller = GruvboxLight1
Color.ScrollbarScrollerSelected = GruvboxLight0Hard
Color.LineHighlight = GruvboxLight1
Color.MainCaret = GruvboxDark0Hard
Color.SubCaret = GruvboxGray245
Color.Selection = GruvboxLight1
Color.WhitespaceDuringSelection = GruvboxLight2
)==";

View File

@@ -289,10 +289,12 @@ void ReplaceInfobarData() {
String16 buffer_string = GetString(*buffer);
Range replace_range = {0, buffer->len};
if (!Seek(buffer_string, L" |", &replace_range.max)) {
ReplaceText(buffer, GetEndAsRange(*buffer), L" |");
// ReplaceText(buffer, GetEndAsRange(*buffer), L" |");
}
String s = Format(scratch, " Line %lld Column %lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll);
// 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, {});

View File

@@ -35,10 +35,9 @@ Color GruvboxFadedBlue = {0x07, 0x66, 0x78, 0xff};
Color GruvboxFadedPurple = {0x8f, 0x3f, 0x71, 0xff};
Color GruvboxFadedAqua = {0x42, 0x7b, 0x58, 0xff};
Color GruvboxFadedOrange = {0xaf, 0x3a, 0x03, 0xff};
Color _InactiveWindowColor = {0x00, 0x00, 0x00, 0x0F};
Color ColorText = GruvboxDark0Hard;
Color ColorBackground = GruvboxLight0Hard;
Color ColorInactiveWindow = _InactiveWindowColor;
Color ColorInactiveWindow = {0x00, 0x00, 0x00, 0x0F};
Color ColorTextLineNumbers = GruvboxDark4;
Color ColorScrollbarBackground = GruvboxLight2;
Color ColorScrollbarScroller = GruvboxLight1;
@@ -86,11 +85,10 @@ local GruvboxFadedBlue = 0x076678ff
local GruvboxFadedPurple = 0x8f3f71ff
local GruvboxFadedAqua = 0x427b58ff
local GruvboxFadedOrange = 0xaf3a03ff
local _InactiveWindowColor = 0x0000000F
Color = {}
Color.Text = GruvboxDark0Hard
Color.Background = GruvboxLight0Hard
Color.InactiveWindow = _InactiveWindowColor
Color.InactiveWindow = 0x0000000F
Color.TextLineNumbers = GruvboxDark4
Color.ScrollbarBackground = GruvboxLight2
Color.ScrollbarScroller = GruvboxLight1

View File

@@ -1,18 +1,33 @@
- Save file (utf16->utf8)
- make sure we only save file buffers
- resize windows
- color the line number with line highlight
- Windows
- Remove view children, replace with view history
- layouting, resize windows
- column based, choose number of columns and then evenly split - we can adjust sizes using mouse
- maybe we can use first line number to use the window?
- try to incorporate the acme square which allows you to put windows wherever and also scale the border
- not sure if wouldn't need the infobars for every window then to align things
- is this even practical if we have tab based design?
- this would allow to create new windows just like that to inform user and so on
- window borders as flag
- plumbing
- add rule which first tries to look for open buffers and then if that fails we go look for files
- move all logic to config files
- execution
- experiment with using multiple cursors to select command and it's input
-
- mouse
- open selected string or auto enclosed word when right clicking or middle (this needs to be also handled on keyboard level)
- file lister
- page up and down should also scroll and leave you in exactly same scroll
- laying out windows, more choice
- window borders
- file dock on left side
- We can actually combine this with command window and lua, it's just going to be a buffer of
- open "asd/asd/asd/asd"
- word completion
- Colored strings
- Set scroll centered
- file lister
- Remove view children, replace with view history
- font cache and on demand unicode loads
@@ -20,16 +35,3 @@
- Search and replace
- Search result buffer
- Move open fully to config so that user can easily modify the plumbing
function Open(s)
o = ApplyRules(s)
if o.kind == "text" then
open_buffer(o.file_path, o.line, o.col)
elseif o.kind == "url" then
open_web(o.url)
end
end

View File

@@ -103,6 +103,7 @@ void InitWindows(View *null_view) {
}
void LayoutWindows() {
float ScrollBarSize = (10.f * DPIScale);
Rect2I screen_rect = GetScreenRectI();
Rect2I infobar_rect = CutBottom(&screen_rect, (Int)FontLineSpacing);
float line_numbers_size = (float)FontCharSpacing * 10;
@@ -120,14 +121,14 @@ void LayoutWindows() {
int i = 0;
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex * 0.5));
Windows[i].document_rect = Windows[i].total_rect;
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)(10.f * DPIScale));
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)ScrollBarSize);
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
}
{
int i = 1;
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex));
Windows[i].document_rect = Windows[i].total_rect;
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)(10.f * DPIScale));
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)ScrollBarSize);
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
}
{

View File

@@ -155,12 +155,14 @@ void DrawWindow(Window *window) {
DrawVisibleText(window);
BeginProfileScope(draw_carets);
For(view->carets) {
Int front = GetFront(it);
XY fxy = PosToXY(*buffer, front);
if (fxy.col >= visible.min.x && fxy.col < visible.max.x && fxy.line >= visible.min.y && fxy.line <= visible.max.y) {
bool main_caret = &it == &view->carets.data[0];
DrawCaret(window, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret);
if (is_active) {
For(view->carets) {
Int front = GetFront(it);
XY fxy = PosToXY(*buffer, front);
if (fxy.col >= visible.min.x && fxy.col < visible.max.x && fxy.line >= visible.min.y && fxy.line <= visible.max.y) {
bool main_caret = &it == &view->carets.data[0];
DrawCaret(window, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret);
}
}
}
EndProfileScope();