Info bar and exec bar
This commit is contained in:
@@ -361,7 +361,7 @@ void HandleActiveWindowBindings(Window *window) {
|
|||||||
ReplaceText(buffer, {0, buffer->len}, GetString(*temp_buffer));
|
ReplaceText(buffer, {0, buffer->len}, GetString(*temp_buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->fuzzy_search) {
|
if (window->execute_line) {
|
||||||
if (Press(KEY_ENTER)) {
|
if (Press(KEY_ENTER)) {
|
||||||
Int line = PosToLine(*buffer, GetFront(view.carets[0]));
|
Int line = PosToLine(*buffer, GetFront(view.carets[0]));
|
||||||
Range range = GetLineRange(*buffer, line);
|
Range range = GetLineRange(*buffer, line);
|
||||||
@@ -531,3 +531,26 @@ void ChangeActiveWindowAndScroll(Array<Int> &order) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReplaceInfobarData() {
|
||||||
|
Window *window = GetWindow(InfoBarWindowID);
|
||||||
|
View *view = GetView(window->active_view);
|
||||||
|
Buffer *buffer = GetBuffer(view->buffer_id);
|
||||||
|
|
||||||
|
XY xy = {};
|
||||||
|
String name = {};
|
||||||
|
{
|
||||||
|
Window *window = GetActiveWindow();
|
||||||
|
View *view = GetActiveView(window);
|
||||||
|
Buffer *buffer = GetBuffer(view->buffer_id);
|
||||||
|
Scratch scratch;
|
||||||
|
Caret caret = view->carets[0];
|
||||||
|
xy = PosToXY(*buffer, GetFront(caret));
|
||||||
|
name = buffer->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Scratch scratch;
|
||||||
|
String s = Format(scratch, "line: %5lld col: %5lld name: %.*s", (long long)xy.line + 1ll, (long long)xy.col + 1ll, FmtString(name));
|
||||||
|
String16 string = ToString16(scratch, s);
|
||||||
|
ReplaceText(buffer, {0, buffer->len}, string);
|
||||||
|
}
|
||||||
@@ -114,12 +114,32 @@ int main(void) {
|
|||||||
View *v = CreateView(b->id);
|
View *v = CreateView(b->id);
|
||||||
AddView(w, v->id);
|
AddView(w, v->id);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
Window *w = CreateWindow();
|
||||||
|
w->draw_scrollbar = false;
|
||||||
|
w->draw_line_numbers = false;
|
||||||
|
Buffer *b = CreateBuffer(sys_allocator, "*infobar*");
|
||||||
|
View *v = CreateView(b->id);
|
||||||
|
AddView(w, v->id);
|
||||||
|
InfoBarWindowID = w->id;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Window *w = CreateWindow();
|
||||||
|
w->draw_scrollbar = false;
|
||||||
|
w->draw_line_numbers = false;
|
||||||
|
w->execute_line = true;
|
||||||
|
Buffer *b = CreateBuffer(sys_allocator, "*execbar*");
|
||||||
|
View *v = CreateView(b->id);
|
||||||
|
AddView(w, v->id);
|
||||||
|
ExecBarWindowID = w->id;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
Window *w = CreateWindow();
|
Window *w = CreateWindow();
|
||||||
w->draw_scrollbar = false;
|
w->draw_scrollbar = false;
|
||||||
w->draw_line_numbers = false;
|
w->draw_line_numbers = false;
|
||||||
w->visible = false;
|
w->visible = false;
|
||||||
w->fuzzy_search = true;
|
w->fuzzy_search = true;
|
||||||
|
w->execute_line = true;
|
||||||
Buffer *b = CreateBuffer(sys_allocator, "*commands*");
|
Buffer *b = CreateBuffer(sys_allocator, "*commands*");
|
||||||
View *v = CreateView(b->id);
|
View *v = CreateView(b->id);
|
||||||
ReplaceText(b, GetEndAsRange(*b), L"\n");
|
ReplaceText(b, GetEndAsRange(*b), L"\n");
|
||||||
@@ -160,7 +180,17 @@ int main(void) {
|
|||||||
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int i = 3;
|
int i = 3;
|
||||||
|
Windows[i].total_rect = CutLeft(&infobar_rect, GetSize(infobar_rect).x / 2);
|
||||||
|
Windows[i].document_rect = Windows[i].total_rect;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int i = 4;
|
||||||
|
Windows[i].total_rect = infobar_rect;
|
||||||
|
Windows[i].document_rect = Windows[i].total_rect;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int i = 5;
|
||||||
Rect2 screen_rect = GetScreenRectF();
|
Rect2 screen_rect = GetScreenRectF();
|
||||||
Vec2 size = GetSize(screen_rect);
|
Vec2 size = GetSize(screen_rect);
|
||||||
CutTop(&screen_rect, size.y * 0.05f);
|
CutTop(&screen_rect, size.y * 0.05f);
|
||||||
@@ -180,29 +210,13 @@ int main(void) {
|
|||||||
Array<Int> order = GetWindowZOrder(scratch);
|
Array<Int> order = GetWindowZOrder(scratch);
|
||||||
HandleGlobalCommands();
|
HandleGlobalCommands();
|
||||||
ChangeActiveWindowAndScroll(order);
|
ChangeActiveWindowAndScroll(order);
|
||||||
|
ReplaceInfobarData();
|
||||||
For(IterateInReverse(&order)) {
|
For(IterateInReverse(&order)) {
|
||||||
Window &window = Windows[it];
|
Window &window = Windows[it];
|
||||||
HandleWindowBindings(&window);
|
HandleWindowBindings(&window);
|
||||||
DrawWindow(window);
|
DrawWindow(window);
|
||||||
}
|
}
|
||||||
SetMouseCursor();
|
SetMouseCursor();
|
||||||
|
|
||||||
{
|
|
||||||
Rect2I r = infobar_rect;
|
|
||||||
DrawRectangleRec(ToRectangle(r), ColorScrollbarBackground);
|
|
||||||
{
|
|
||||||
Window *window = GetActiveWindow();
|
|
||||||
View *view = GetActiveView(window);
|
|
||||||
Buffer *buffer = GetBuffer(view->buffer_id);
|
|
||||||
Vec2 p = ToVec2(r.min);
|
|
||||||
Scratch scratch;
|
|
||||||
Caret caret = view->carets[0];
|
|
||||||
XY xy = PosToXY(*buffer, GetFront(caret));
|
|
||||||
String s = Format(scratch, "-- line: %lld col: %lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll);
|
|
||||||
String16 string = ToString16(scratch, s);
|
|
||||||
DrawString(MenuFont, string, p, MenuFontSize, 1, ColorText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ struct Window {
|
|||||||
bool draw_scrollbar : 1;
|
bool draw_scrollbar : 1;
|
||||||
bool draw_line_numbers : 1;
|
bool draw_line_numbers : 1;
|
||||||
bool visible : 1;
|
bool visible : 1;
|
||||||
|
|
||||||
bool fuzzy_search : 1;
|
bool fuzzy_search : 1;
|
||||||
|
bool execute_line : 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,6 +85,8 @@ WindowID NullWindowID = {0};
|
|||||||
BufferID NullBufferID = {0};
|
BufferID NullBufferID = {0};
|
||||||
ViewID NullViewID = {0};
|
ViewID NullViewID = {0};
|
||||||
WindowID CommandWindowID = {0};
|
WindowID CommandWindowID = {0};
|
||||||
|
WindowID InfoBarWindowID = {0};
|
||||||
|
WindowID ExecBarWindowID = {0};
|
||||||
|
|
||||||
Array<Buffer> Buffers = {};
|
Array<Buffer> Buffers = {};
|
||||||
Array<View> Views = {};
|
Array<View> Views = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user