Remove titlebar modification, small refactor
This commit is contained in:
@@ -289,7 +289,7 @@ end
|
|||||||
function MatchWindowsPath(_s)
|
function MatchWindowsPath(_s)
|
||||||
local s, file_path, drive = SkipPath(_s)
|
local s, file_path, drive = SkipPath(_s)
|
||||||
if not drive then
|
if not drive then
|
||||||
local d = GetActiveMainWindowBufferName()
|
local d = GetActiveMainWindowBufferDir()
|
||||||
file_path = d..'/'..file_path
|
file_path = d..'/'..file_path
|
||||||
end
|
end
|
||||||
local line, col, s = SkipLineAndColumn(s)
|
local line, col, s = SkipLineAndColumn(s)
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ bool GlobalCommand(Event event) {
|
|||||||
if (!window->visible) continue;
|
if (!window->visible) continue;
|
||||||
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
|
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
|
||||||
if (mouse_in_document) {
|
if (mouse_in_document) {
|
||||||
SetActiveWindow(window->id);
|
ActiveWindow = window->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -472,17 +472,17 @@ bool GlobalCommand(Event event) {
|
|||||||
|
|
||||||
if (Ctrl(SDLK_1)) {
|
if (Ctrl(SDLK_1)) {
|
||||||
Window *window = GetLayoutWindow(0);
|
Window *window = GetLayoutWindow(0);
|
||||||
if (window) SetActiveWindow(window->id);
|
if (window) ActiveWindow = window->id;
|
||||||
run_window_command = false;
|
run_window_command = false;
|
||||||
}
|
}
|
||||||
if (Ctrl(SDLK_2)) {
|
if (Ctrl(SDLK_2)) {
|
||||||
Window *window = GetLayoutWindow(1);
|
Window *window = GetLayoutWindow(1);
|
||||||
if (window) SetActiveWindow(window->id);
|
if (window) ActiveWindow = window->id;
|
||||||
run_window_command = false;
|
run_window_command = false;
|
||||||
}
|
}
|
||||||
if (Ctrl(SDLK_3)) {
|
if (Ctrl(SDLK_3)) {
|
||||||
Window *window = GetLayoutWindow(2);
|
Window *window = GetLayoutWindow(2);
|
||||||
if (window) SetActiveWindow(window->id);
|
if (window) ActiveWindow = window->id;
|
||||||
run_window_command = false;
|
run_window_command = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,5 +561,5 @@ void ReportWarningf(const char *fmt, ...) {
|
|||||||
}
|
}
|
||||||
CheckpointBeforeGoto(window->id);
|
CheckpointBeforeGoto(window->id);
|
||||||
window->active_view = NullViewID;
|
window->active_view = NullViewID;
|
||||||
SetActiveWindow(window->id);
|
ActiveWindow = window->id;
|
||||||
}
|
}
|
||||||
@@ -682,7 +682,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
|
|
||||||
if (Press(SDLK_ESCAPE)) {
|
if (Press(SDLK_ESCAPE)) {
|
||||||
if (window->deactivate_on_escape) {
|
if (window->deactivate_on_escape) {
|
||||||
SetActiveWindow(GetActiveMainWindowID());
|
ActiveWindow = GetActiveMainWindowID();
|
||||||
} else {
|
} else {
|
||||||
view->carets.len = 1;
|
view->carets.len = 1;
|
||||||
}
|
}
|
||||||
@@ -890,7 +890,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
Window *titlebar = GetTitlebarWindow(window->id);
|
Window *titlebar = GetTitlebarWindow(window->id);
|
||||||
View *titlebar_view = GetView(titlebar->active_view);
|
View *titlebar_view = GetView(titlebar->active_view);
|
||||||
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
||||||
SetActiveWindow(titlebar->id);
|
ActiveWindow = titlebar->id;
|
||||||
|
|
||||||
String16 buffer_string = GetString(*titlebar_buffer);
|
String16 buffer_string = GetString(*titlebar_buffer);
|
||||||
if (Seek(buffer_string, L" |", &buffer_string.len)) {
|
if (Seek(buffer_string, L" |", &buffer_string.len)) {
|
||||||
@@ -908,7 +908,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
Window *titlebar = GetTitlebarWindow(window->id);
|
Window *titlebar = GetTitlebarWindow(window->id);
|
||||||
View *titlebar_view = GetView(titlebar->active_view);
|
View *titlebar_view = GetView(titlebar->active_view);
|
||||||
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
Buffer *titlebar_buffer = GetBuffer(titlebar_view->active_buffer);
|
||||||
SetActiveWindow(titlebar->id);
|
ActiveWindow = titlebar->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShift(SDLK_W)) {
|
if (CtrlShift(SDLK_W)) {
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ end
|
|||||||
function MatchWindowsPath(_s)
|
function MatchWindowsPath(_s)
|
||||||
local s, file_path, drive = SkipPath(_s)
|
local s, file_path, drive = SkipPath(_s)
|
||||||
if not drive then
|
if not drive then
|
||||||
local d = GetActiveMainWindowBufferName()
|
local d = GetActiveMainWindowBufferDir()
|
||||||
file_path = d..'/'..file_path
|
file_path = d..'/'..file_path
|
||||||
end
|
end
|
||||||
local line, col, s = SkipLineAndColumn(s)
|
local line, col, s = SkipLineAndColumn(s)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void ExecInNewBuffer(String cmd, String working_dir) {
|
|||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
view->carets[0] = MakeCaret({});
|
view->carets[0] = MakeCaret({});
|
||||||
Exec(view->id, false, cmd, working_dir);
|
Exec(view->id, false, cmd, working_dir);
|
||||||
SetActiveWindow(window->id);
|
ActiveWindow = window->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open(String path) {
|
void Open(String path) {
|
||||||
@@ -69,7 +69,7 @@ void Open(String path) {
|
|||||||
view->carets[0] = MakeCaret(pos);
|
view->carets[0] = MakeCaret(pos);
|
||||||
}
|
}
|
||||||
UpdateScroll(window, true);
|
UpdateScroll(window, true);
|
||||||
SetActiveWindow(window->id);
|
ActiveWindow = window->id;
|
||||||
} else if (FieldString(LuaState, "kind") == "exec") {
|
} else if (FieldString(LuaState, "kind") == "exec") {
|
||||||
String cmd = FieldString(LuaState, "cmd");
|
String cmd = FieldString(LuaState, "cmd");
|
||||||
String working_dir = FieldString(LuaState, "working_dir");
|
String working_dir = FieldString(LuaState, "working_dir");
|
||||||
|
|||||||
@@ -126,11 +126,6 @@ View *CreateView(BufferID active_buffer) {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo: remove function
|
|
||||||
void SetActiveWindow(WindowID window) {
|
|
||||||
ActiveWindow = window;
|
|
||||||
}
|
|
||||||
|
|
||||||
View *FindView(BufferID buffer_id) {
|
View *FindView(BufferID buffer_id) {
|
||||||
For(Views) {
|
For(Views) {
|
||||||
View *view = it.o;
|
View *view = it.o;
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ struct Scroller {
|
|||||||
Int line_count;
|
Int line_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ActiveSet {
|
||||||
|
Window *window;
|
||||||
|
View *view;
|
||||||
|
Buffer *buffer;
|
||||||
|
};
|
||||||
|
|
||||||
// @WARNING: be careful about using this, should only be used for debugging
|
// @WARNING: be careful about using this, should only be used for debugging
|
||||||
// the problem with this is that we want events to be reproducible.
|
// the problem with this is that we want events to be reproducible.
|
||||||
// We eat as many events as we can in a frame, we abstract the frame and so on.
|
// We eat as many events as we can in a frame, we abstract the frame and so on.
|
||||||
|
|||||||
@@ -57,59 +57,10 @@ void UpdateDebugBuffer() {
|
|||||||
// Append(buffer, ToString16(scratch, window_list));
|
// Append(buffer, ToString16(scratch, window_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyTitleBarChangesToWindow(Window *window, View *view, Buffer *buffer) {
|
|
||||||
String16 buffer_string = GetString(*buffer);
|
|
||||||
Range replace_range = {0, buffer->len};
|
|
||||||
if (Seek(buffer_string, L" |", &replace_range.max)) {
|
|
||||||
}
|
|
||||||
buffer_string = GetString(*buffer, replace_range);
|
|
||||||
buffer_string = Trim(buffer_string);
|
|
||||||
|
|
||||||
Int column = ChopNumber(&buffer_string);
|
|
||||||
if (column == -1) return;
|
|
||||||
|
|
||||||
Int line = ChopNumber(&buffer_string);
|
|
||||||
if (line == -1) {
|
|
||||||
line = column;
|
|
||||||
column = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window *last_window = GetWindow(window->title_bar_window);
|
|
||||||
View *last_view = GetActiveView(last_window);
|
|
||||||
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
|
||||||
Scratch scratch;
|
|
||||||
|
|
||||||
String filepath = ToString(scratch, buffer_string);
|
|
||||||
if (filepath != last_buffer->name && !BufferNameExists(filepath)) {
|
|
||||||
filepath = GetAbsolutePath(scratch, filepath);
|
|
||||||
Buffer *find_buffer = GetBufferStrict(filepath);
|
|
||||||
if (find_buffer) {
|
|
||||||
ReportWarningf("couldn't set name for buffer: %.*s, there is already buffer with that name", FmtString(filepath));
|
|
||||||
} else {
|
|
||||||
String new_name = Intern(&GlobalInternTable, filepath);
|
|
||||||
last_buffer->name = new_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Int buffer_pos = XYToPos(*last_buffer, {column, line});
|
|
||||||
|
|
||||||
Caret &caret = last_view->carets[0];
|
|
||||||
if (GetFront(caret) != buffer_pos) {
|
|
||||||
caret = MakeCaret(buffer_pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
window->title_bar_last_buffer_change_id = buffer->change_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReplaceTitleBarData(Window *window) {
|
void ReplaceTitleBarData(Window *window) {
|
||||||
View *view = GetView(window->active_view);
|
View *view = GetView(window->active_view);
|
||||||
view->scroll.y = 0;
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
if (IsActive(window)) {
|
view->scroll.y = 0;
|
||||||
if (buffer->change_id != window->title_bar_last_buffer_change_id) {
|
|
||||||
ApplyTitleBarChangesToWindow(window, view, buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Window *last_window = GetWindow(window->title_bar_window);
|
Window *last_window = GetWindow(window->title_bar_window);
|
||||||
View *last_view = GetActiveView(last_window);
|
View *last_view = GetActiveView(last_window);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
- garbage collect the buffers, views - store them in free list on destroy
|
- garbage collect the buffers, views - store them in free list on destroy
|
||||||
- adding items to directory should create files on save - it should ask the user (syntax: dir/ | file)
|
- adding items to directory should create files on save - it should ask the user (syntax: dir/ | file)
|
||||||
- refresh the directory - whem opening up again?
|
- refresh the directory - when opening up again?
|
||||||
- refresh the file content, periodically check file timestamp for changes and update if neccessary
|
- refresh the file content, periodically check file timestamp for changes and update if neccessary
|
||||||
- ask user if he really wants to quit even though he has an unsaved buffer - popup window
|
- ask user if he really wants to quit even though he has an unsaved buffer - popup window
|
||||||
- add plumb rules for some web stuff
|
- add plumb rules for some web stuff
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ void InitWindows() {
|
|||||||
SetVisibility(window_id, false);
|
SetVisibility(window_id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetActiveWindow({0});
|
ActiveWindow = {0};
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutWindows() {
|
void LayoutWindows() {
|
||||||
|
|||||||
Reference in New Issue
Block a user