diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-05 16:49:17 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-05 16:49:17 -0500 |
commit | edbad154a65f47dc77dbb901801651e28c4f5e55 (patch) | |
tree | 544d1e29f7507622a0a58c906fea0ddf500393af | |
parent | e37ef801a6304f602fdff195b2c46098cf7f5994 (diff) |
fix :shell with no files open, write cwd to session
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | main.c | 21 | ||||
-rw-r--r-- | session.c | 6 |
3 files changed, 20 insertions, 12 deletions
@@ -11,8 +11,9 @@ I'll release installers after testing it a bit more to try to find any bugs ther ## Why? There are a lot of text editors out there. ted doesn't do anything new. -But in the modern world of text editors running browsers internally, it can be nice to have -a simple editor that starts up practically instantaneously, and performs well on reasonably-sized files. +I made ted because I wanted a simple editor that starts up practically instantaneously, +and performs well on reasonably-sized files. I've also added features I find to be particularly useful, +while still keeping it relatively simple. ## Supported features (more coming soon) @@ -779,7 +779,7 @@ int main(int argc, char **argv) { strcpy(ted->window_title, "ted"); - if (ted->nodes_used[0]) { + { float const padding = settings->padding; float x1 = padding, y = window_height-padding, x2 = window_width-padding; Node *node = &ted->nodes[0]; @@ -796,15 +796,18 @@ int main(int argc, char **argv) { y -= padding; } - float y1 = padding; - node_frame(ted, node, rect4(x1, y1, x2, y)); - if (ted->autocomplete) { - autocomplete_frame(ted); + if (ted->nodes_used[0]) { + float y1 = padding; + node_frame(ted, node, rect4(x1, y1, x2, y)); + if (ted->autocomplete) { + autocomplete_frame(ted); + } + } else { + ted->autocomplete = false; + text_utf8_anchored(font, "Press Ctrl+O to open a file or Ctrl+N to create a new one.", + window_width * 0.5f, window_height * 0.5f, colors[COLOR_TEXT_SECONDARY], ANCHOR_MIDDLE); + text_render(font); } - } else { - text_utf8_anchored(font, "Press Ctrl+O to open a file or Ctrl+N to create a new one.", - window_width * 0.5f, window_height * 0.5f, colors[COLOR_TEXT_SECONDARY], ANCHOR_MIDDLE); - text_render(font); } // stop dragging tab if mouse was released @@ -1,5 +1,5 @@ #define SESSION_FILENAME "session.txt" -#define SESSION_VERSION "\x7fTED0001" +#define SESSION_VERSION "\x7fTED0002" static void session_write_node(Ted *ted, FILE *fp, u16 node_idx) { Node *node = &ted->nodes[node_idx]; @@ -95,6 +95,8 @@ static void session_read_buffer(Ted *ted, FILE *fp) { static void session_write_file(Ted *ted, FILE *fp) { fwrite(SESSION_VERSION, 1, sizeof SESSION_VERSION, fp); + write_cstr(fp, ted->cwd); + write_u16(fp, ted->active_node ? (u16)(ted->active_node - ted->nodes) : U16_MAX); // active node idx write_u16(fp, ted->active_buffer ? (u16)(ted->active_buffer - ted->buffers) : U16_MAX); // active buffer idx @@ -123,6 +125,8 @@ static void session_read_file(Ted *ted, FILE *fp) { return; // wrong version } + read_cstr(fp, ted->cwd, sizeof ted->cwd); + u16 active_node_idx = read_u16(fp); u16 active_buffer_idx = read_u16(fp); |