Trace buffer vs Debug buffer, print Buffer info, Add SaveAll
This commit is contained in:
@@ -391,9 +391,19 @@ function KeybindsBasic(e)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
FKey = {"build.bat", "", "", "", "", "", "", "", "", "", "", ""}
|
function BasicBuild()
|
||||||
|
SaveAll()
|
||||||
|
if OS_VALUE == OS_WINDOWS then
|
||||||
|
return "build.bat"
|
||||||
|
else
|
||||||
|
return "./build.sh"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
FKey = {BasicBuild, "", "", "", "", "", "", "", "", "", "", ""}
|
||||||
FKeySDLK = {SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12}
|
FKeySDLK = {SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12}
|
||||||
|
|
||||||
|
|
||||||
function KeybindsFKeys(e)
|
function KeybindsFKeys(e)
|
||||||
for i = #FKey,1,-1 do
|
for i = #FKey,1,-1 do
|
||||||
if FKey[i] ~= "" then
|
if FKey[i] ~= "" then
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ int main() {
|
|||||||
Add(&array, String{"\n)==\";\n"});
|
Add(&array, String{"\n)==\";\n"});
|
||||||
String result = Merge(scratch, array, "");
|
String result = Merge(scratch, array, "");
|
||||||
WriteFile("../src/text_editor/generated_config.cpp", result);
|
WriteFile("../src/text_editor/generated_config.cpp", result);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -226,9 +226,7 @@ void ReportWarningf(const char *fmt, ...) {
|
|||||||
void ReportDebugf(const char *fmt, ...) {
|
void ReportDebugf(const char *fmt, ...) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
Buffer *buffer = GetBuffer(DebugBufferID);
|
Command_Appendf(TraceView, "%.*s\n", FmtString(string));
|
||||||
ReplaceWithoutMovingCarets(buffer, GetEndAsRange(buffer), ToString16(scratch, string));
|
|
||||||
ReplaceWithoutMovingCarets(buffer, GetEndAsRange(buffer), ToString16(scratch, "\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_MoveCursorsByPageSize(Window *window, int direction, bool shift = false) {
|
void Command_MoveCursorsByPageSize(Window *window, int direction, bool shift = false) {
|
||||||
@@ -696,6 +694,18 @@ int Lua_Save(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Command_SaveAll() {
|
||||||
|
for (Buffer *it = FirstBuffer; it; it = it->next) {
|
||||||
|
if (it->file_mod_time) {
|
||||||
|
SaveBuffer(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int Lua_SaveAll(lua_State *L) {
|
||||||
|
Command_SaveAll();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Command_KillSelectedLines(View *view) {
|
void Command_KillSelectedLines(View *view) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
|||||||
@@ -392,9 +392,19 @@ function KeybindsBasic(e)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
FKey = {"build.bat", "", "", "", "", "", "", "", "", "", "", ""}
|
function BasicBuild()
|
||||||
|
SaveAll()
|
||||||
|
if OS_VALUE == OS_WINDOWS then
|
||||||
|
return "build.bat"
|
||||||
|
else
|
||||||
|
return "./build.sh"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
FKey = {BasicBuild, "", "", "", "", "", "", "", "", "", "", ""}
|
||||||
FKeySDLK = {SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12}
|
FKeySDLK = {SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12}
|
||||||
|
|
||||||
|
|
||||||
function KeybindsFKeys(e)
|
function KeybindsFKeys(e)
|
||||||
for i = #FKey,1,-1 do
|
for i = #FKey,1,-1 do
|
||||||
if FKey[i] ~= "" then
|
if FKey[i] ~= "" then
|
||||||
|
|||||||
@@ -14,12 +14,11 @@ int Lua_print(lua_State *L) {
|
|||||||
int Lua_Print(lua_State *L) {
|
int Lua_Print(lua_State *L) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
int nargs = lua_gettop(L);
|
int nargs = lua_gettop(L);
|
||||||
View *view = GetView(DebugViewID);
|
|
||||||
for (int i = 1; i <= nargs; i += 1) {
|
for (int i = 1; i <= nargs; i += 1) {
|
||||||
String string = lua_tostring(L, i);
|
String string = lua_tostring(L, i);
|
||||||
Command_Appendf(view, "%.*s ", FmtString(string));
|
Command_Appendf(TraceView, "%.*s ", FmtString(string));
|
||||||
}
|
}
|
||||||
Command_Appendf(view, "\n");
|
Command_Appendf(TraceView, "\n");
|
||||||
lua_pop(L, nargs);
|
lua_pop(L, nargs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
luaL_Reg LuaFunctions[] = {
|
luaL_Reg LuaFunctions[] = {
|
||||||
{"print", Lua_print},
|
{"print", Lua_print},
|
||||||
{"Print", Lua_Print},
|
{"Print", Lua_Print},
|
||||||
|
{"SaveAll", Lua_SaveAll},
|
||||||
{"Kill", Lua_Kill},
|
{"Kill", Lua_Kill},
|
||||||
{"GetLoadWord", Lua_GetLoadWord},
|
{"GetLoadWord", Lua_GetLoadWord},
|
||||||
{"BufferExists", Lua_BufferExists},
|
{"BufferExists", Lua_BufferExists},
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ Buffer *LuaConfigBuffer;
|
|||||||
Buffer *GCInfoBuffer;
|
Buffer *GCInfoBuffer;
|
||||||
Buffer *EventBuffer;
|
Buffer *EventBuffer;
|
||||||
Buffer *ScratchBuffer;
|
Buffer *ScratchBuffer;
|
||||||
|
Buffer *TraceBuffer;
|
||||||
|
View *TraceView;
|
||||||
|
|
||||||
String WorkDir;
|
String WorkDir;
|
||||||
RandomSeed UniqueBufferNameSeed = {};
|
RandomSeed UniqueBufferNameSeed = {};
|
||||||
@@ -74,6 +76,8 @@ void InitScratchBuffer() {
|
|||||||
View *null_view = CreateView(null_buffer->id);
|
View *null_view = CreateView(null_buffer->id);
|
||||||
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
|
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
|
||||||
|
|
||||||
|
TraceBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "trace"));
|
||||||
|
TraceView = CreateView(TraceBuffer->id);
|
||||||
GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "gc"));
|
GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "gc"));
|
||||||
EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "events"));
|
EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "events"));
|
||||||
ScratchBuffer = BufferOpenFile(GetUniqueBufferName(WorkDir, "scratch"));
|
ScratchBuffer = BufferOpenFile(GetUniqueBufferName(WorkDir, "scratch"));
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ void Update(Event event) {
|
|||||||
UpdateCo(&event);
|
UpdateCo(&event);
|
||||||
ReloadLuaConfigs();
|
ReloadLuaConfigs();
|
||||||
CallLuaOnUpdate(&event);
|
CallLuaOnUpdate(&event);
|
||||||
|
UpdateDebugBuffer();
|
||||||
GarbageCollect();
|
GarbageCollect();
|
||||||
|
|
||||||
For(IterateInReverse(&order)) {
|
For(IterateInReverse(&order)) {
|
||||||
|
|||||||
@@ -15,8 +15,32 @@ void UpdateDebugBuffer() {
|
|||||||
float xmouse, ymouse;
|
float xmouse, ymouse;
|
||||||
SDL_GetMouseState(&xmouse, &ymouse);
|
SDL_GetMouseState(&xmouse, &ymouse);
|
||||||
RawAppendf(buffer, "mouse: [%f, %f]\n", xmouse, ymouse);
|
RawAppendf(buffer, "mouse: [%f, %f]\n", xmouse, ymouse);
|
||||||
RawAppendf(buffer, "C:/Work/text_editor/src/text_editor/text_editor.cpp\n");
|
|
||||||
RawAppendf(buffer, "config dir: %.*s\n", FmtString(ConfigDir));
|
RawAppendf(buffer, "BufferID id = %d\n", main.buffer->id.id);
|
||||||
|
RawAppendf(buffer, "Buffer *next = %zu\n", main.buffer->next);
|
||||||
|
RawAppendf(buffer, "Buffer *prev = %zu\n", main.buffer->prev);
|
||||||
|
RawAppendf(buffer, "String name = %.*s\n", FmtString(main.buffer->name));
|
||||||
|
RawAppendf(buffer, "Int change_id = %lld\n", (long long)main.buffer->change_id);
|
||||||
|
RawAppendf(buffer, "Int user_change_id = %lld\n", (long long)main.buffer->user_change_id);
|
||||||
|
RawAppendf(buffer, "Int file_mod_time = %lld\n", (long long)main.buffer->file_mod_time);
|
||||||
|
RawAppendf(buffer, "\n");
|
||||||
|
|
||||||
|
RawAppendf(buffer, "U16 *data = %zu\n", main.buffer->data);
|
||||||
|
RawAppendf(buffer, "Int len = %lld\n", (long long)main.buffer->len);
|
||||||
|
RawAppendf(buffer, "Int cap = %lld\n", (long long)main.buffer->cap);
|
||||||
|
RawAppendf(buffer, "Array<Int> line_starts = {len = %lld, cap = %lld, data = %zu}\n", (long long)main.buffer->line_starts.len, (long long)main.buffer->line_starts.cap, main.buffer->line_starts.data);
|
||||||
|
RawAppendf(buffer, "\n");
|
||||||
|
|
||||||
|
RawAppendf(buffer, "Array<HistoryEntry> undo_stack = {len = %lld, cap = %lld, data = %zu}\n", (long long)main.buffer->undo_stack.len, (long long)main.buffer->undo_stack.cap, main.buffer->undo_stack.data);
|
||||||
|
RawAppendf(buffer, "Array<HistoryEntry> redo_stack = {len = %lld, cap = %lld, data = %zu}\n", (long long)main.buffer->redo_stack.len, (long long)main.buffer->redo_stack.cap, main.buffer->redo_stack.data);
|
||||||
|
RawAppendf(buffer, "int edit_phase = %d", main.buffer->edit_phase);
|
||||||
|
RawAppendf(buffer, "\n");
|
||||||
|
|
||||||
|
RawAppendf(buffer, "int no_history = %d\n", main.buffer->no_history);
|
||||||
|
RawAppendf(buffer, "int no_line_starts = %d\n", main.buffer->no_line_starts);
|
||||||
|
RawAppendf(buffer, "int dirty = %d\n", main.buffer->dirty);
|
||||||
|
RawAppendf(buffer, "int changed_on_disk = %d\n", main.buffer->changed_on_disk);
|
||||||
|
RawAppendf(buffer, "int garbage = %d\n", main.buffer->garbage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplaceTitleBarData(Window *window) {
|
void ReplaceTitleBarData(Window *window) {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ FEATURE Select all searched occurences
|
|||||||
DESIGN Indicate maybe on the console border that a process is running in the console! also maybe exit code when exits
|
DESIGN Indicate maybe on the console border that a process is running in the console! also maybe exit code when exits
|
||||||
PLATFORM Fix windows build
|
PLATFORM Fix windows build
|
||||||
|
|
||||||
|
ISSUE What to do / how should Reopen work after we delete the file on disk in some other program?
|
||||||
|
|
||||||
- Changing window properties by changing the window name?
|
- Changing window properties by changing the window name?
|
||||||
- commands for scrolling: center, cursor_at_bottom_of_screen, cursor_at_top
|
- commands for scrolling: center, cursor_at_bottom_of_screen, cursor_at_top
|
||||||
- Add metadata to Lua bindings so that we would get a better listing (function args?, what else?)
|
- Add metadata to Lua bindings so that we would get a better listing (function args?, what else?)
|
||||||
|
|||||||
Reference in New Issue
Block a user