Improving the design

This commit is contained in:
krzosa
2025-12-24 08:49:01 +01:00
parent 28308f58b2
commit 938edcc321
9 changed files with 55 additions and 45 deletions

View File

@@ -1,7 +1,6 @@
- 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?
- Optimization:
- Show what process/coroutines are running and allow to kill (active process buffer?)
- ctrl + p like in VSCode (without special buffers)
- Maybe 2 windows?

View File

@@ -658,6 +658,7 @@ void Coro_OpenCode(mco_coro *co) {
if (it.filename == ".git") {
continue;
}
ProfileScopeEx(it.filename);
if (it.is_directory) {
Add(&dirs, it.absolute_path);

View File

@@ -1,7 +1,19 @@
typedef void CoroutineProc(mco_coro *co);
void CoRemove(String name) {
IterRemove(ActiveCoroutines) {
IterRemovePrepare(ActiveCoroutines);
if (it.name == name) {
mco_destroy(it.co);
remove_item = true;
}
}
}
#define CoAdd(x) CoAddEx(x, #x)
mco_coro *CoAddEx(CoroutineProc *proc, String name) {
CoRemove(name);
mco_desc desc = mco_desc_init(proc, 0);
mco_coro *coro = NULL;
@@ -56,13 +68,3 @@ Event *CoYield(mco_coro *co) {
return event;
}
void CoRemove(String name) {
IterRemove(ActiveCoroutines) {
IterRemovePrepare(ActiveCoroutines);
if (it.name == name) {
mco_destroy(it.co);
remove_item = true;
}
}
}

View File

@@ -119,25 +119,20 @@ void DrawWindow(Window *window, Event &event) {
Color color_text = ColorText;
if (window->draw_darker) {
if (is_active) {
color_background = ColorTitleBarActiveBackground;
} else {
color_background = ColorTitleBarBackground;
}
color_background = ColorTitleBarBackground;
color_selection = ColorTitleBarSelection;
color_text = ColorTitleBarText;
color_line_highlight = ColorTitleBarBackground;
color_line_highlight = ColorTitleBarLineHighlight;
}
DrawRect(window->total_rect, color_background);
if (window->draw_darker) {
Rect2I rect = window->total_rect;
DrawRect(CutTop(&rect, 1), ColorResizerOutline);
}
Rect2I combined_document_line_number = window->document_rect;
if (window->draw_line_numbers) combined_document_line_number.min.x = window->line_numbers_rect.min.x;
if (window->draw_line_numbers) {
combined_document_line_number.min.x = window->line_numbers_rect.min.x;
}
SetScissor(combined_document_line_number);
BeginProfileScope(draw_caret_selection);
Rect2I visible = GetVisibleCells(window);
@@ -287,6 +282,12 @@ void DrawWindow(Window *window, Event &event) {
DrawRect(window->total_rect, {255, 255, 255, 25});
}
if (window->draw_darker) {
SetScissor(window->total_rect);
Rect2I rect = window->total_rect;
DrawRect(CutTop(&rect, 1), ColorTitleBarOutline);
}
// darken the inactive windows
if (!is_active) {
ProfileScope(DarkenInactiveRect);
@@ -295,8 +296,9 @@ void DrawWindow(Window *window, Event &event) {
}
// Draw resizer rect
{
if (GetSize(window->resizer_rect).x > 0){
Rect2I rect = window->resizer_rect;
SetScissor(window->resizer_rect);
DrawRect(rect, ColorResizerBackground);
DrawRect(CutRight(&rect, 1), ColorResizerOutline);
}

View File

@@ -128,7 +128,7 @@ Color GruvboxFadedOrange = {0xaf, 0x3a, 0x03, 0xff};
RegisterVariable(Color, ColorText, GruvboxDark0Hard);
RegisterVariable(Color, ColorLoadTextHighlight, {0x00, 0x00, 0x00, 0x0F});
RegisterVariable(Color, ColorBackground, GruvboxLight0Hard);
RegisterVariable(Color, ColorInactiveWindow, {0x00, 0x00, 0x00, 0x0F});
RegisterVariable(Color, ColorInactiveWindow, {0x00, 0x00, 0x00, 0x1F});
RegisterVariable(Color, ColorTextLineNumbers, GruvboxDark4);
RegisterVariable(Color, ColorLineHighlight, GruvboxLight0Soft);
RegisterVariable(Color, ColorMainCaret, GruvboxDark0Hard);
@@ -137,14 +137,14 @@ RegisterVariable(Color, ColorSelection, GruvboxLight1);
RegisterVariable(Color, ColorWhitespaceDuringSelection, GruvboxLight4);
RegisterVariable(Color, ColorMouseUnderline, GruvboxDark0Hard);
RegisterVariable(Color, ColorCaretUnderline, GruvboxGray245);
RegisterVariable(Color, ColorFuzzySearchLineHighlight, GruvboxDark0);
RegisterVariable(Color, ColorScrollbarBackground, GruvboxLight2);
RegisterVariable(Color, ColorScrollbarScroller, GruvboxLight1);
RegisterVariable(Color, ColorScrollbarScrollerSelected, GruvboxLight0Hard);
RegisterVariable(Color, ColorTitleBarText, GruvboxDark2);
RegisterVariable(Color, ColorTitleBarBackground, GruvboxLight1);
RegisterVariable(Color, ColorTitleBarActiveBackground, {0xfe, 0xfe, 0xfe, 0xfe});
RegisterVariable(Color, ColorTitleBarText, GruvboxDark0Hard);
RegisterVariable(Color, ColorTitleBarBackground, GruvboxLight0Hard);
RegisterVariable(Color, ColorTitleBarSelection, GruvboxLight3);
RegisterVariable(Color, ColorTitleBarLineHighlight, GruvboxLight0Soft);
RegisterVariable(Color, ColorTitleBarOutline, GruvboxLight3);
RegisterVariable(Color, ColorResizerBackground, GruvboxLight0Hard);
RegisterVariable(Color, ColorResizerOutline, GruvboxLight3);
RegisterVariable(Int, ConfigWaitForEvents, 1);

View File

@@ -121,9 +121,9 @@ void InitWindows() {
CreateWind();
CommandWindowInit();
SearchWindowInit();
StatusWindowInit();
DebugWindowInit();
SearchWindowInit();
}
void CalcNiceties(Window *n) {
@@ -151,9 +151,9 @@ void LayoutWindows(int16_t wx, int16_t wy) {
Rect2I screen_rect = RectI0Size(wx, wy);
CommandWindowLayout(&screen_rect, wx, wy);
SearchWindowLayout(&screen_rect, wx, wy);
StatusWindowLayout(&screen_rect, wx, wy);
DebugWindowLayout(&screen_rect, wx, wy);
SearchWindowLayout(&screen_rect, wx, wy);
// Column layout
Int c = 0;

View File

@@ -9,7 +9,7 @@ void CommandWindowInit() {
window->draw_line_numbers = false;
window->draw_scrollbar = false;
window->draw_darker = true;
window->draw_line_highlight = false;
window->draw_line_highlight = true;
window->layout = false;
window->visible = false;
window->sync_visibility_with_focus = true;
@@ -27,8 +27,6 @@ void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
n->document_rect = n->total_rect = CutBottom(rect, barsize);
}
const Int FuzzyCloserWordBegin = 5;
const Int FuzzyConsecutiveMultiplier = 3;
Int FuzzyRate(String16 string, String16 with) {
ProfileFunction();
if (with.len == 0) return 0;
@@ -36,20 +34,18 @@ Int FuzzyRate(String16 string, String16 with) {
Int consecutive = 0;
Int with_i = 0;
for (Int i = 0; i < string.len; i++) {
if (string.data[i] == with[with_i]) {
Int closer_begin = ClampBottom((Int)0, FuzzyCloserWordBegin - i);
points += closer_begin;
consecutive++;
if (ToLowerCase(string.data[i]) == ToLowerCase(with[with_i])) {
consecutive += 1;
with_i += 1;
} else {
points += consecutive * FuzzyConsecutiveMultiplier;
with_i = 0;
points += consecutive * consecutive;
consecutive = 0;
with_i = 0;
}
if (with_i >= with.len) with_i = 0;
}
points += consecutive * FuzzyConsecutiveMultiplier;
points += consecutive * consecutive;
return points;
}
@@ -145,7 +141,7 @@ void Command_ShowDebugBufferList() {
ActiveWindowID = command_bar.window->id;
ResetBuffer(command_bar.buffer);
For (Buffers) {
RawAppendf(command_bar.buffer, "\n%-80S || %S", SkipToLastSlash(it->name), it->name);
RawAppendf(command_bar.buffer, "\n%S", it->name);
}
command_bar.view->update_scroll = true;
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
@@ -167,7 +163,7 @@ void Command_ShowBufferList() {
if (it->special) {
continue;
}
RawAppendf(command_bar.buffer, "\n%-80S || %S", SkipToLastSlash(it->name), it->name);
RawAppendf(command_bar.buffer, "\n%S", it->name);
}
command_bar.view->update_scroll = true;
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));

View File

@@ -11,13 +11,17 @@ void SearchWindowInit() {
window->draw_line_numbers = false;
window->draw_scrollbar = false;
window->draw_darker = true;
window->draw_line_highlight = false;
window->draw_line_highlight = true;
window->layout = false;
window->visible = false;
window->lose_visibility_on_escape = true;
}
void SearchWindowLayout(Rect2I *rect, Int wx, Int wy) {
Window *command_window = GetWindow(CommandWindowID);
if (command_window->visible) {
return;
}
Window *n = GetWindow(SearchWindowID);
Rect2I copy_rect = *rect;
if (!n->visible) {

View File

@@ -6,15 +6,21 @@ void StatusWindowInit() {
View *view = CreateView(buffer->id);
view->special = true;
window->active_view = view->id;
window->font = &SecondaryFont;
// window->font = &SecondaryFont;
window->draw_line_numbers = false;
window->draw_scrollbar = false;
window->draw_line_highlight = false;
window->draw_line_highlight = true;
window->draw_darker = true;
window->layout = false;
window->jump_history = false;
window->lose_focus_on_escape = true;
}
void StatusWindowLayout(Rect2I *rect, Int wx, Int wy) {
Window *command_window = GetWindow(CommandWindowID);
if (command_window->visible) {
return;
}
Window *n = GetWindow(StatusBarWindowID);
Rect2I copy_rect = *rect;
if (!n->visible) {