LogBuffer and NullBuffer separation, More indicators in status as new line as sep, eval multiple carets with Open, :Errors
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,6 +6,7 @@ src/external/SDL/
|
||||
build/
|
||||
package/
|
||||
|
||||
project.te
|
||||
*.rdbg
|
||||
*.spall
|
||||
*.sublime-workspace
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
:OpenCode
|
||||
@@ -1,32 +1,17 @@
|
||||
! 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?
|
||||
|
||||
|
||||
- Buffer edit history separate from caret history (tagging history blocks with carets???)
|
||||
- We need regex for: [FormatCode matching, IsCode matching,
|
||||
- Macros
|
||||
- Window position: vscode opens in fullscreen and then remembers what position it was close in (could be a config option)
|
||||
- On Linux: Try to implement is_debugger_present()
|
||||
|
||||
- Maybe IPC for te.exe when it's already open and file arguments are passed it should perhaps open a buffer in current window??
|
||||
|
||||
Use session 4
|
||||
- Add <<File>> <<ProjectDirectory>> template strings to Open (Then remove SEtWorkdirhere)
|
||||
- :Set Filename to name current buffer ??? :O and others like that!!
|
||||
|
||||
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
|
||||
- Make the equivalent of SearchOpenBuffers but for cmds like !@git grep -n "@>"
|
||||
- Add Bool variable
|
||||
- RegisterCommand should_appear_in_listing variable
|
||||
|
||||
Use session 3:
|
||||
- Maybe status view, commit changes (like to buffer name or line) on enter?
|
||||
|
||||
How to go about search/replace, opening code and other considerations
|
||||
- Search and replace sign Find@>ReplaceWith
|
||||
- We can use sed + find to search and replace, the automatic reopen should do the job
|
||||
|
||||
Use session 2
|
||||
- Guide on the first page for new users with links to configs, tutorials
|
||||
|
||||
Debug session:
|
||||
@@ -48,13 +33,10 @@ New UI Session
|
||||
|
||||
- Try to add Tracking Allocator and rewrite the app, free all memory at the end of the app and check all is well
|
||||
|
||||
backlog
|
||||
FEATURE Some decl/function indexing in fuzzy format
|
||||
ISSUE? Fix jump scroll, the query ends up the last line on screen, kind of wacky
|
||||
FEATURE dump text editor state to file, restore state
|
||||
- Search and replace
|
||||
- word complete
|
||||
- Search all buffers in 10X style, incrementally searched results popping up on every key press (maybe we need coroutine library in C so this is easier?)
|
||||
- escapeing multiple cursor after ctrl + d should put the cursor where it was (probably will need to swap secondary and primary cursor for new cursor
|
||||
- draw indentation levels like in sublime (those lines) - we render chars one by one so seems relatively easy to figure out if whitespace belongs to beginning of line (make sure to add max value like 40 because of big files)
|
||||
- code sections, visual demarkation if beginning of line has a very specific text + goto next / goto prev section hotkey!
|
||||
|
||||
@@ -1506,12 +1506,12 @@ Buffer *BufferOpenFile(String path) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool BufferIsReferenced(BufferID buffer_id) {
|
||||
if (buffer_id == NullBufferID) {
|
||||
bool BufferIsReferenced(Buffer *buffer) {
|
||||
if (buffer->special) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (FindView(buffer_id, NULL)) {
|
||||
if (FindView(buffer->id, NULL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void ReportErrorf(const char *fmt, ...) {
|
||||
BREAK();
|
||||
}
|
||||
|
||||
View *view = GetView(NullViewID);
|
||||
View *view = GetView(LogViewID);
|
||||
if (view) {
|
||||
Appendf(view, "%S\n", string);
|
||||
}
|
||||
@@ -113,27 +113,21 @@ void ReportErrorf(const char *fmt, ...) {
|
||||
void ReportConsolef(const char *fmt, ...) {
|
||||
Scratch scratch;
|
||||
STRING_FORMAT(scratch, fmt, string);
|
||||
View *view = GetView(NullViewID);
|
||||
View *view = GetView(LogViewID);
|
||||
Appendf(view, "%S\n", string);
|
||||
}
|
||||
|
||||
void ReportWarningf(const char *fmt, ...) {
|
||||
ErrorCount += 1;
|
||||
Scratch scratch;
|
||||
STRING_FORMAT(scratch, fmt, string);
|
||||
if (BreakOnError) {
|
||||
BREAK();
|
||||
}
|
||||
View *null_view = GetView(NullViewID);
|
||||
View *null_view = GetView(LogViewID);
|
||||
Appendf(null_view, "%S\n", string);
|
||||
}
|
||||
|
||||
void CMD_OpenLoadWord() {
|
||||
Scratch scratch;
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
String16 load_word = FetchLoadWord(active.view);
|
||||
Open(load_word);
|
||||
} RegisterCommand(CMD_OpenLoadWord, "ctrl-q | f12", "Open a link under the caret (file link, url, command) or open the selection");
|
||||
|
||||
void CMD_CenterView() {
|
||||
CenterView(PrimaryWindowID);
|
||||
} RegisterCommand(CMD_CenterView, "", "");
|
||||
@@ -183,7 +177,7 @@ void ApplyFormattingTool(Buffer *buffer, String tool) {
|
||||
if (exec_result.exit_code == 0) {
|
||||
ReplaceWithoutMovingCarets(buffer, GetRange(buffer), string16);
|
||||
} else {
|
||||
View *view = GetView(NullViewID);
|
||||
View *view = GetView(LogViewID);
|
||||
Append(view, string16, true);
|
||||
}
|
||||
}
|
||||
@@ -461,6 +455,11 @@ void CMD_ToggleFullscreen() {
|
||||
} RegisterCommand(CMD_ToggleFullscreen, "f11", "Switches between the fullscreen and non-fulscreen mode");
|
||||
|
||||
void CMD_OpenLogs() {
|
||||
Buffer *buffer = GetBuffer(NullBufferID);
|
||||
ErrorCount = 0;
|
||||
Buffer *buffer = GetBuffer(LogBufferID);
|
||||
Open(buffer->name);
|
||||
} RegisterCommand(CMD_OpenLogs, "", "Opens the text editor logs");
|
||||
} RegisterCommand(CMD_OpenLogs, "", "Opens the text editor logs and clear error counter");
|
||||
|
||||
void CMD_Errors() {
|
||||
CMD_OpenLogs();
|
||||
} RegisterCommand(CMD_Errors, "", "Opens the text editor logs and clear error counter");
|
||||
@@ -1,28 +1,3 @@
|
||||
String16 FetchFuzzyViewLoadLine(View *view) {
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Range range = view->carets[0].range;
|
||||
String16 string = GetString(buffer, range);
|
||||
if (GetSize(range) == 0) {
|
||||
Int line = PosToLine(buffer, range.min);
|
||||
if (line == 0) {
|
||||
line = ClampTop(1ll, buffer->line_starts.len - 1ll);
|
||||
}
|
||||
string = GetLineStringWithoutNL(buffer, line);
|
||||
|
||||
Int idx = 0;
|
||||
String16 delim = u"||>";
|
||||
if (Seek(string, delim, &idx, SeekFlag_None)) {
|
||||
string = Skip(string, idx + delim.len);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
void OpenCommand(BSet active) {
|
||||
String16 string = FetchFuzzyViewLoadLine(active.view);
|
||||
Open(string);
|
||||
}
|
||||
|
||||
float NewFuzzyRate(String16 s, String16 p) {
|
||||
float score = 0;
|
||||
// try to do this: https://github.com/junegunn/fzf/blob/master/src/algo/algo.go
|
||||
@@ -124,13 +99,62 @@ void UpdateFuzzySearchView() {
|
||||
}
|
||||
}
|
||||
|
||||
void SetFuzzy(View *view) {
|
||||
AddCommand(&view->commands, "Open", OpenKeySet, [](){
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
String16 FetchFuzzyViewLoadLine(View *view) {
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Range range = view->carets[0].range;
|
||||
String16 string = GetString(buffer, range);
|
||||
if (GetSize(range) == 0) {
|
||||
Int line = PosToLine(buffer, range.min);
|
||||
if (line == 0) {
|
||||
line = ClampTop(1ll, buffer->line_starts.len - 1ll);
|
||||
}
|
||||
string = GetLineStringWithoutNL(buffer, line);
|
||||
|
||||
Int idx = 0;
|
||||
String16 delim = u"||>";
|
||||
if (Seek(string, delim, &idx, SeekFlag_None)) {
|
||||
string = Skip(string, idx + delim.len);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
void CMD_OpenLoadWord() {
|
||||
Scratch scratch;
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
For (active.view->carets) {
|
||||
Range range = it.range;
|
||||
if (GetSize(range) == 0) {
|
||||
range = EncloseLoadWord(active.buffer, GetFront(it));
|
||||
}
|
||||
String16 load_word = GetString(active.buffer, range);
|
||||
Open(load_word);
|
||||
}
|
||||
} RegisterCommand(CMD_OpenLoadWord, "ctrl-q | f12", "Open a link under the caret (file link, url, command) or open the selection");
|
||||
|
||||
void CMD_OpenForFuzzyView() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
if (active.view->carets.len == 1) {
|
||||
String16 string = FetchFuzzyViewLoadLine(active.view);
|
||||
Open(string);
|
||||
});
|
||||
} else {
|
||||
CMD_OpenLoadWord();
|
||||
}
|
||||
}
|
||||
|
||||
void CMD_OpenAndSetGotoNext() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
String16 string = FetchFuzzyViewLoadLine(active.view);
|
||||
main.window->active_goto_list = active.view->id;
|
||||
main.window->goto_list_pos = active.view->carets[0].range.min;
|
||||
Open(string);
|
||||
}
|
||||
|
||||
void SetFuzzy(View *view) {
|
||||
AddCommand(&view->commands, "Open", OpenKeySet, CMD_OpenForFuzzyView);
|
||||
view->update_hook = UpdateFuzzySearchView;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ bool RunGCThisFrame;
|
||||
bool SearchCaseSensitive = false;
|
||||
bool SearchWordBoundary = false;
|
||||
bool BreakOnError = false;
|
||||
Int ErrorCount;
|
||||
|
||||
Allocator SysAllocator = {SystemAllocatorProc};
|
||||
String ConfigDir;
|
||||
@@ -28,7 +29,9 @@ Array<Window *> Windows;
|
||||
Array<View *> Views;
|
||||
Array<Buffer *> Buffers;
|
||||
|
||||
// First window
|
||||
BufferID LogBufferID;
|
||||
ViewID LogViewID;
|
||||
|
||||
BufferID NullBufferID;
|
||||
ViewID NullViewID;
|
||||
WindowID NullWindowID;
|
||||
|
||||
@@ -12,10 +12,6 @@ void CMD_ShowCommands() {
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For (GlobalCommands) {
|
||||
if (it.name == "OpenCommand") {
|
||||
continue;
|
||||
}
|
||||
// RawAppendf(command_bar.buffer, "\n:%-30S <|| :Set %-30S '%-30S'", it.name, it.name, it.binding);
|
||||
RawAppendf(command_bar.buffer, "\n:%-30S <|| ", it.name);
|
||||
if (it.docs.len) {
|
||||
RawAppendf(command_bar.buffer, "%S", it.docs);
|
||||
|
||||
@@ -59,12 +59,12 @@ void CMD_EvalCommandsLineByLine() {
|
||||
BufferID LoadConfig(String config_path) {
|
||||
ReportConsolef("Loading config %S...", config_path);
|
||||
Window *window = GetWindow(NullWindowID);
|
||||
ViewID active_view_before = window->active_view;
|
||||
View *view = WindowOpenBufferView(window, config_path);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
buffer->special = true;
|
||||
EvalCommandsLineByLine({window, view, buffer});
|
||||
if (window->active_view == view->id) {
|
||||
window->active_view = NullViewID;
|
||||
window->active_view = active_view_before;
|
||||
}
|
||||
return buffer->id;
|
||||
}
|
||||
|
||||
@@ -2131,7 +2131,7 @@ bool RDBG_InitConnection(mco_coro *co) {
|
||||
|
||||
String session_name = Format(CoCurr->arena, "te%llu", GetTimeNanos());
|
||||
String remedy_string = Format(CoCurr->arena, "%S --servername %S", RemedyBGPath, session_name);
|
||||
Exec(NullViewID, true, remedy_string, GetPrimaryDirectory());
|
||||
Exec(LogViewID, true, remedy_string, GetPrimaryDirectory());
|
||||
MemoryZero(&RDBG_Ctx, sizeof(RDBG_Ctx));
|
||||
RDBG_Ctx.cmd.data = command_buf;
|
||||
RDBG_Ctx.cmd.capacity = sizeof(command_buf);
|
||||
@@ -2157,23 +2157,27 @@ bool RDBG_InitConnection(mco_coro *co) {
|
||||
}
|
||||
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
|
||||
|
||||
rdbg_Id cfg_id;
|
||||
char *exe = file.data;
|
||||
char *args = NULL;
|
||||
char *work_dir = ProjectDirectory.data;
|
||||
char *env = NULL;
|
||||
AddSessionConfig(&RDBG_Ctx, exe, args, work_dir, env, true, true, &res, &cfg_id);
|
||||
if (ContextHadError(&RDBG_Ctx)) {
|
||||
ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error);
|
||||
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
|
||||
return true;
|
||||
}
|
||||
if (EndsWith(file, ".rdbg")) {
|
||||
OpenSession(&RDBG_Ctx, file.data, &res);
|
||||
} else {
|
||||
rdbg_Id cfg_id;
|
||||
char *exe = file.data;
|
||||
char *args = NULL;
|
||||
char *work_dir = ProjectDirectory.data;
|
||||
char *env = NULL;
|
||||
AddSessionConfig(&RDBG_Ctx, exe, args, work_dir, env, true, true, &res, &cfg_id);
|
||||
if (ContextHadError(&RDBG_Ctx)) {
|
||||
ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error);
|
||||
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
|
||||
return true;
|
||||
}
|
||||
|
||||
SetActiveSessionConfig(&RDBG_Ctx, cfg_id, &res);
|
||||
if (ContextHadError(&RDBG_Ctx)) {
|
||||
ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error);
|
||||
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
|
||||
return true;
|
||||
SetActiveSessionConfig(&RDBG_Ctx, cfg_id, &res);
|
||||
if (ContextHadError(&RDBG_Ctx)) {
|
||||
ReportErrorf("Remedy error: %s", RDBG_Ctx.last_error);
|
||||
MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -79,15 +79,7 @@ void CMD_SearchOpenBuffers() {
|
||||
NextActiveWindowID = main.window->id;
|
||||
JumpTempBuffer(&main);
|
||||
main.buffer->no_history = true;
|
||||
AddCommand(&main.view->commands, "Open", OpenKeySet, []() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
String16 string = FetchFuzzyViewLoadLine(active.view);
|
||||
main.window->active_goto_list = active.view->id;
|
||||
main.window->goto_list_pos = active.view->carets[0].range.min;
|
||||
Open(string);
|
||||
});
|
||||
AddCommand(&main.view->commands, "Open", OpenKeySet, CMD_OpenAndSetGotoNext);
|
||||
main.view->update_hook = UpdateSearchOpenBuffersView;
|
||||
if (string.len) {
|
||||
SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0));
|
||||
|
||||
@@ -29,58 +29,57 @@ void LayoutStatusWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
||||
|
||||
void UpdateStatusWindow() {
|
||||
ProfileFunction();
|
||||
Window *status_bar_window = GetWindow(StatusWindowID, NULL);
|
||||
Scratch scratch;
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
BSet title = GetBSet(status_bar_window);
|
||||
BSet title = GetBSet(StatusWindowID);
|
||||
title.view->scroll.y = 0;
|
||||
if (title.window->id == ActiveWindowID) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
Vec2I doc_rect = GetSize(title.window->document_rect);
|
||||
Int width_in_chars = doc_rect.x / title.window->font->char_spacing;
|
||||
|
||||
char buff[1024];
|
||||
for (int i = 0; i < 1024; i += 1) buff[i] = ' ';
|
||||
|
||||
RawReplaceText(title.buffer, GetRange(title.buffer), u"");
|
||||
RawAppendf(title.buffer, "%.*s", width_in_chars - 1, buff);
|
||||
RawAppendf(title.buffer, "@");
|
||||
return;
|
||||
#endif
|
||||
|
||||
String16 buffer_string = GetString(title.buffer);
|
||||
Range replace_range = {0, title.buffer->len};
|
||||
bool found_separator = Seek(buffer_string, u" |", &replace_range.max);
|
||||
|
||||
// Parse the title and line
|
||||
if (title.window->id == ActiveWindowID) {
|
||||
if (title.buffer->change_id == title.buffer->begin_frame_change_id) {
|
||||
return;
|
||||
}
|
||||
String16 buffer_name = GetString(title.buffer, replace_range);
|
||||
buffer_name = Trim(buffer_name);
|
||||
|
||||
Int column = ChopNumber(&buffer_name);
|
||||
if (column == -1) return;
|
||||
|
||||
Chop(&buffer_name, u":");
|
||||
Int line = ChopNumber(&buffer_name);
|
||||
if (line == -1) {
|
||||
line = column;
|
||||
column = 0;
|
||||
}
|
||||
Chop(&buffer_name, u":");
|
||||
|
||||
Int buffer_pos = XYToPos(main.buffer, {column, line});
|
||||
Caret &caret = main.view->carets[0];
|
||||
if (GetFront(caret) != buffer_pos) {
|
||||
caret = MakeCaret(buffer_pos);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Seek(buffer_string, u"\n", &replace_range.max);
|
||||
|
||||
Caret caret = main.view->carets[0];
|
||||
XY xy = PosToXY(main.buffer, GetFront(caret));
|
||||
|
||||
// add separator at the end of buffer
|
||||
if (!found_separator) {
|
||||
SelectRange(title.view, GetBufferEndAsRange(title.buffer));
|
||||
ReplaceEx(scratch, title.view, u" | :Prev :Next :Close");
|
||||
String indicators = "";
|
||||
if (main.buffer->dirty) {
|
||||
indicators = Format(scratch, "%S!", indicators);
|
||||
}
|
||||
if (SearchCaseSensitive) {
|
||||
indicators = Format(scratch, "%SC", indicators);
|
||||
}
|
||||
if (SearchWordBoundary) {
|
||||
indicators = Format(scratch, "%SW", indicators);
|
||||
}
|
||||
|
||||
// replace data up to separator with filename and stuff
|
||||
const char *reopen = main.buffer->changed_on_disk ? " :Reopen" : "";
|
||||
const char *case_sens = SearchCaseSensitive ? " C" : "";
|
||||
const char *word_bound = SearchWordBoundary ? " W" : "";
|
||||
const char *dirty = main.buffer->dirty ? " !" : "";
|
||||
String s = Format(scratch, "%S:%lld:%lld%s%s%s", main.buffer->name, (long long)xy.line + 1ll, (long long)xy.col + 1ll, dirty, case_sens, word_bound, reopen);
|
||||
String commands = Format(scratch, ":Errors[%d]", ErrorCount);
|
||||
if (main.buffer->changed_on_disk) {
|
||||
commands = Format(scratch, "%S :Reopen");
|
||||
}
|
||||
For (ActiveProcesses) {
|
||||
if (it.view_id == main.view->id.id) {
|
||||
commands = Format(scratch, "%S :KillProcess", commands);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String s = Format(scratch, "%S:%lld:%lld %S | :Prev :Next :Close %S", main.buffer->name, (long long)xy.line + 1ll, (long long)xy.col + 1ll, indicators, commands);
|
||||
For (ActiveProcesses) {
|
||||
if (it.view_id == main.view->id.id) {
|
||||
s = Format(scratch, "%S %lld :KillProcess", s, (long long)it.id);
|
||||
|
||||
@@ -506,7 +506,7 @@ void GarbageCollect() {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ref = ViewIsReferenced(it->id);
|
||||
bool ref = ViewIsReferenced(it);
|
||||
if (ref) {
|
||||
continue;
|
||||
}
|
||||
@@ -519,6 +519,7 @@ void GarbageCollect() {
|
||||
#if PLUGIN_RECORD_GC
|
||||
RawAppendf(GCInfoBuffer, "View %d %S\n", (int)it->id.id, buffer ? buffer->name : String{"NULL"});
|
||||
#endif
|
||||
Assert(it->special == false);
|
||||
Dealloc(&it->commands);
|
||||
Dealloc(it);
|
||||
remove_item = true;
|
||||
@@ -536,7 +537,7 @@ void GarbageCollect() {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ref = BufferIsReferenced(it->id);
|
||||
bool ref = BufferIsReferenced(it);
|
||||
if (ref) {
|
||||
continue;
|
||||
}
|
||||
@@ -545,6 +546,7 @@ void GarbageCollect() {
|
||||
#if PLUGIN_RECORD_GC
|
||||
RawAppendf(GCInfoBuffer, "Buff %d %S\n", (int)it->id.id, it->name);
|
||||
#endif
|
||||
Assert(it->special == false);
|
||||
remove_item = true;
|
||||
DeallocBuffer(it);
|
||||
}
|
||||
@@ -968,12 +970,19 @@ int main(int argc, char **argv)
|
||||
{
|
||||
Allocator sys_allocator = GetSystemAllocator();
|
||||
Scratch scratch;
|
||||
Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "logs", ""));
|
||||
Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "scratch", ""));
|
||||
null_buffer->special = true;
|
||||
View *null_view = CreateView(null_buffer->id);
|
||||
null_view->special = true;
|
||||
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
|
||||
|
||||
Buffer *logs_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "logs", ""));
|
||||
logs_buffer->special = true;
|
||||
LogBufferID = logs_buffer->id;
|
||||
View *logs_view = CreateView(logs_buffer->id);
|
||||
logs_view->special = true;
|
||||
LogViewID = logs_view->id;
|
||||
|
||||
#if PLUGIN_RECORD_GC
|
||||
GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "gc"));
|
||||
GCInfoBuffer->special = true;
|
||||
|
||||
@@ -331,7 +331,7 @@ BSet Open(Window *window, String path, ResolveOpenMeta meta, bool set_active = t
|
||||
Exec(set.view->id, false, o.path, GetPrimaryDirectory());
|
||||
} else if (o.kind == OpenKind_BackgroundExec) {
|
||||
// this shouldn't change the focus/window/view
|
||||
Exec(NullViewID, false, o.path, GetPrimaryDirectory());
|
||||
Exec(LogViewID, false, o.path, GetPrimaryDirectory());
|
||||
} else if (o.kind == OpenKind_Command) {
|
||||
EvalCommand(o.path);
|
||||
}
|
||||
|
||||
@@ -76,16 +76,16 @@ bool ViewIsActive(ViewID id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
API bool ViewIsReferenced(ViewID view) {
|
||||
if (view == NullViewID) {
|
||||
API bool ViewIsReferenced(View *view) {
|
||||
if (view->special) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ViewIsCrumb(view)) {
|
||||
if (ViewIsCrumb(view->id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ViewIsActive(view);
|
||||
return ViewIsActive(view->id);
|
||||
}
|
||||
|
||||
void Close(ViewID id) {
|
||||
@@ -110,7 +110,9 @@ String16 FetchLoadWord(View *view) {
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Caret caret = view->carets[0];
|
||||
Range range = caret.range;
|
||||
if (GetSize(caret.range) == 0) range = EncloseLoadWord(buffer, GetFront(caret));
|
||||
if (GetSize(caret.range) == 0) {
|
||||
range = EncloseLoadWord(buffer, GetFront(caret));
|
||||
}
|
||||
String16 string = GetString(buffer, range);
|
||||
return string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user