Only one infobar
This commit is contained in:
@@ -205,14 +205,17 @@ Range EncloseWord(Buffer &buffer, Int pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HandleGlobalCommands() {
|
void HandleGlobalCommands() {
|
||||||
|
Window *command_window = GetWindow(CommandWindowID);
|
||||||
|
if (!IsActive(command_window)) {
|
||||||
|
command_window->visible = false;
|
||||||
|
}
|
||||||
if (CtrlPress(KEY_P)) {
|
if (CtrlPress(KEY_P)) {
|
||||||
Window *window = GetWindow(CommandWindowID);
|
if (command_window->visible) {
|
||||||
if (window->visible) {
|
|
||||||
SetActiveWindow(LastActiveWindow);
|
SetActiveWindow(LastActiveWindow);
|
||||||
} else {
|
} else {
|
||||||
SetActiveWindow(window->id);
|
SetActiveWindow(command_window->id);
|
||||||
}
|
}
|
||||||
window->visible = !window->visible;
|
command_window->visible = !command_window->visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlPress(KEY_ONE)) {
|
if (CtrlPress(KEY_ONE)) {
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ void HandleActiveWindowBindings(Window *window) {
|
|||||||
Range range = GetLineRange(*buffer, line);
|
Range range = GetLineRange(*buffer, line);
|
||||||
String16 string = GetString(*buffer, range);
|
String16 string = GetString(*buffer, range);
|
||||||
EvalString(string);
|
EvalString(string);
|
||||||
} else if (window->banish_new_lines == false && Press(KEY_ENTER)) {
|
} else if (Press(KEY_ENTER)) {
|
||||||
Command_Replace(&view, L"\n");
|
Command_Replace(&view, L"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ int LuaOpenFile(lua_State *L) {
|
|||||||
String string = text;
|
String string = text;
|
||||||
Buffer *buffer = OpenFile(string);
|
Buffer *buffer = OpenFile(string);
|
||||||
View *view = CreateView(buffer->id);
|
View *view = CreateView(buffer->id);
|
||||||
Window *window = GetWindow({1});
|
Window *window = GetWindow(LastActiveWindow);
|
||||||
AddView(window, view->id);
|
AddView(window, view->id);
|
||||||
window->active_view = view->id;
|
window->active_view = view->id;
|
||||||
SetActiveWindow(window->id);
|
SetActiveWindow(window->id);
|
||||||
@@ -27,6 +27,6 @@ void EvalString(String16 string16) {
|
|||||||
if (luaL_dostring(LuaState, string.data) != LUA_OK) {
|
if (luaL_dostring(LuaState, string.data) != LUA_OK) {
|
||||||
// @todo:
|
// @todo:
|
||||||
const char *text = lua_tostring(LuaState, -1);
|
const char *text = lua_tostring(LuaState, -1);
|
||||||
printf("lua error: %s", text);
|
printf("lua error: %s\n", text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,8 @@
|
|||||||
#include "lua_api.cpp"
|
#include "lua_api.cpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- Open file (utf8->utf16), process determine line endings, tabs to spaces?, Save file (utf16->utf8)
|
- Save file (utf16->utf8)
|
||||||
- line endings
|
- reuse buffers!!
|
||||||
- resize windows
|
- resize windows
|
||||||
- command window
|
- command window
|
||||||
- maybe use lua and have there be lua commands that you choose with cursor
|
- maybe use lua and have there be lua commands that you choose with cursor
|
||||||
@@ -40,8 +40,6 @@
|
|||||||
- We can actually combine this with command window and lua, it's just going to be a buffer of
|
- We can actually combine this with command window and lua, it's just going to be a buffer of
|
||||||
- open "asd/asd/asd/asd"
|
- open "asd/asd/asd/asd"
|
||||||
|
|
||||||
- Make only one infobar!!
|
|
||||||
|
|
||||||
- Ctrl + F
|
- Ctrl + F
|
||||||
|
|
||||||
- word completion
|
- word completion
|
||||||
@@ -120,7 +118,6 @@ int main(void) {
|
|||||||
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->draw_infobar = false;
|
|
||||||
w->visible = false;
|
w->visible = false;
|
||||||
Buffer *b = CreateBuffer(sys_allocator);
|
Buffer *b = CreateBuffer(sys_allocator);
|
||||||
View *v = CreateView(b->id);
|
View *v = CreateView(b->id);
|
||||||
@@ -134,13 +131,13 @@ int main(void) {
|
|||||||
FrameID += 1;
|
FrameID += 1;
|
||||||
|
|
||||||
Rect2I screen_rect = GetScreenRect();
|
Rect2I screen_rect = GetScreenRect();
|
||||||
|
Rect2I infobar_rect = CutBottom(&screen_rect, (Int)MenuFontSize);
|
||||||
float line_numbers_size = MeasureTextEx(MainFont, "12345", (float)FontSize, (float)FontSpacing).x;
|
float line_numbers_size = MeasureTextEx(MainFont, "12345", (float)FontSize, (float)FontSpacing).x;
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)GetSize(screen_rect).x * 0.33));
|
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)GetSize(screen_rect).x * 0.33));
|
||||||
Windows[i].document_rect = Windows[i].total_rect;
|
Windows[i].document_rect = Windows[i].total_rect;
|
||||||
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, 10);
|
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, 10);
|
||||||
if (Windows[i].draw_infobar) Windows[i].infobar_rect = CutBottom(&Windows[i].document_rect, (Int)MenuFontSize);
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -148,7 +145,6 @@ int main(void) {
|
|||||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)GetSize(screen_rect).x * 0.5));
|
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)GetSize(screen_rect).x * 0.5));
|
||||||
Windows[i].document_rect = Windows[i].total_rect;
|
Windows[i].document_rect = Windows[i].total_rect;
|
||||||
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, 10);
|
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, 10);
|
||||||
if (Windows[i].draw_infobar) Windows[i].infobar_rect = CutBottom(&Windows[i].document_rect, (Int)MenuFontSize);
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -156,7 +152,6 @@ int main(void) {
|
|||||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)GetSize(screen_rect).x * 1.0));
|
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)GetSize(screen_rect).x * 1.0));
|
||||||
Windows[i].document_rect = Windows[i].total_rect;
|
Windows[i].document_rect = Windows[i].total_rect;
|
||||||
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, 10);
|
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, 10);
|
||||||
if (Windows[i].draw_infobar) Windows[i].infobar_rect = CutBottom(&Windows[i].document_rect, (Int)MenuFontSize);
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -186,6 +181,23 @@ int main(void) {
|
|||||||
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();
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ struct Window {
|
|||||||
|
|
||||||
Rect2I total_rect;
|
Rect2I total_rect;
|
||||||
Rect2I scrollbar_rect;
|
Rect2I scrollbar_rect;
|
||||||
Rect2I infobar_rect;
|
|
||||||
Rect2I line_numbers_rect;
|
Rect2I line_numbers_rect;
|
||||||
Rect2I document_rect;
|
Rect2I document_rect;
|
||||||
|
|
||||||
@@ -62,9 +61,7 @@ struct Window {
|
|||||||
bool mouse_selecting : 1;
|
bool mouse_selecting : 1;
|
||||||
bool draw_scrollbar : 1;
|
bool draw_scrollbar : 1;
|
||||||
bool draw_line_numbers : 1;
|
bool draw_line_numbers : 1;
|
||||||
bool draw_infobar : 1;
|
|
||||||
bool visible : 1;
|
bool visible : 1;
|
||||||
bool banish_new_lines : 1; // @todo: custom new line handler? custom vertical handler! (choosing options with cursor)
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,10 +72,6 @@ struct Scroller {
|
|||||||
Int line_count;
|
Int line_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
Rect2I GetVisibleCells(Window &window);
|
|
||||||
void AfterEdit(View *view, Array<Edit> edits);
|
|
||||||
Scroller ComputeScrollerRect(Window &window);
|
|
||||||
|
|
||||||
WindowID WindowIDs = {0};
|
WindowID WindowIDs = {0};
|
||||||
BufferID BufferIDs = {0};
|
BufferID BufferIDs = {0};
|
||||||
ViewID ViewIDs = {0};
|
ViewID ViewIDs = {0};
|
||||||
@@ -136,3 +129,6 @@ inline View *GetActiveView(Window *window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EvalString(String16 string16);
|
void EvalString(String16 string16);
|
||||||
|
Rect2I GetVisibleCells(Window &window);
|
||||||
|
void AfterEdit(View *view, Array<Edit> edits);
|
||||||
|
Scroller ComputeScrollerRect(Window &window);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Window *CreateWindow() {
|
|||||||
w->visible = true;
|
w->visible = true;
|
||||||
w->draw_scrollbar = true;
|
w->draw_scrollbar = true;
|
||||||
w->draw_line_numbers = true;
|
w->draw_line_numbers = true;
|
||||||
w->draw_infobar = true;
|
|
||||||
w->id = AllocWindowID();
|
w->id = AllocWindowID();
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
@@ -49,7 +48,9 @@ Array<Int> GetWindowZOrder(Allocator allocator) {
|
|||||||
|
|
||||||
void SetActiveWindow(WindowID window) {
|
void SetActiveWindow(WindowID window) {
|
||||||
if (LastFrameIDWhenSwitchedActiveWindow != FrameID) {
|
if (LastFrameIDWhenSwitchedActiveWindow != FrameID) {
|
||||||
|
if (ActiveWindow.id != CommandWindowID.id) {
|
||||||
LastActiveWindow = ActiveWindow;
|
LastActiveWindow = ActiveWindow;
|
||||||
|
}
|
||||||
ActiveWindow = window;
|
ActiveWindow = window;
|
||||||
LastFrameIDWhenSwitchedActiveWindow = FrameID;
|
LastFrameIDWhenSwitchedActiveWindow = FrameID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,21 +214,6 @@ void DrawWindow(Window &window) {
|
|||||||
EndScissorMode();
|
EndScissorMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw info bar
|
|
||||||
if (window.draw_infobar) {
|
|
||||||
Rect2I r = window.infobar_rect;
|
|
||||||
DrawRectangleRec(ToRectangle(r), ColorScrollbarBackground);
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsActive(&window)) {
|
if (!IsActive(&window)) {
|
||||||
DrawRectangleRec(ToRectangle(window.total_rect), {0, 0, 0, 30});
|
DrawRectangleRec(ToRectangle(window.total_rect), {0, 0, 0, 30});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user