From 1b3d8e3135444823cf6d26373becfca17415ed2c Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 25 May 2017 15:39:17 -0400 Subject: [PATCH] diagnostic messages printed to tags region now steal focus --- TODO.md | 23 ++++++++++++++--------- tests/xedit.c | 10 +++++----- xedit.c | 21 ++++++++++----------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/TODO.md b/TODO.md index 541018e..8d69291 100644 --- a/TODO.md +++ b/TODO.md @@ -2,15 +2,26 @@ Up Next: +* ctrl+d with no selection does word selection instead of context +* add config option to change default tab style +* Diagnostic messages should order options so most frequent is closest to cursor +* get rid of edit wrapper script +* Add a way to CD using a builtin +* Ctrl+Shift+N to set a mark, Ctrl+N to jump to a mark * Make Fn keys execute nth command in the tags buffers * move by words is inconsistent. Example: var infoId = 'readerinfo'+reader.id; -* Add a way to CD using a builtin -* diagnostic messages should steal focus. -* Ctrl+Shift+N to set a mark, Ctrl+N to jump to a mark +* rename to tide The Future: +* Ctrl+Shift+g to jump to undo a goto line action +* Shortcut to warp cursor to middle of current screen. +* Find shortcut should select previous word if current char is newline +* diagnostic messages can stack up if deselected and not resolved +* highlight all matches of search term +* Ctrl+Shift+Enter copies indent of wrong line + * use transaction ids to only mark buffer dirty when it really is * refactor selection handling to buf.c to prepare for multiple selections. * 100% coverage with unit and unit-integration tests @@ -23,12 +34,6 @@ The Future: * implement command diffing logic to optimize the undo/redo log * Status line should omit characters from beginning of path to make file path fit -* Ctrl+Shift+g to jump to undo a goto line action -* Shortcut to warp cursor to middle of current screen. -* Find shortcut should select previous word if current char is newline -* diagnostic messages can stack up if deselected and not resolved -* highlight all matches of search term - # Auxillary Programs * Visual diff tool diff --git a/tests/xedit.c b/tests/xedit.c index 652bc1c..4423cc1 100644 --- a/tests/xedit.c +++ b/tests/xedit.c @@ -23,7 +23,7 @@ Display* XDisplay; static void initialize(void) { ShellCmd[0] = "/bin/sh"; - win_window("edit", onerror); + win_window("edit", ondiagmsg); XDisplay = XOpenDisplay(NULL); win_setkeys(Bindings); //win_setmouse(&MouseHandlers); @@ -796,19 +796,19 @@ TEST_SUITE(UnitTests) { TEST(Save should save changes to disk with crlf line endings) { setup_view(TAGS, "", CRLF, 0); - view_init(win_view(EDIT), "testdocs/crlf.txt", onerror); + view_init(win_view(EDIT), "testdocs/crlf.txt", ondiagmsg); CHECK(verify_text(EDIT, "this file\r\nuses\r\ndos\r\nline\r\nendings\r\n")); exec("Save"); - view_init(win_view(EDIT), "testdocs/crlf.txt", onerror); + view_init(win_view(EDIT), "testdocs/crlf.txt", ondiagmsg); CHECK(verify_text(EDIT, "this file\r\nuses\r\ndos\r\nline\r\nendings\r\n")); } TEST(Save should save changes to disk with lf line endings) { setup_view(TAGS, "", CRLF, 0); - view_init(win_view(EDIT), "testdocs/lf.txt", onerror); + view_init(win_view(EDIT), "testdocs/lf.txt", ondiagmsg); CHECK(verify_text(EDIT, "this file\nuses\nunix\nline\nendings\n")); exec("Save"); - view_init(win_view(EDIT), "testdocs/lf.txt", onerror); + view_init(win_view(EDIT), "testdocs/lf.txt", ondiagmsg); CHECK(verify_text(EDIT, "this file\nuses\nunix\nline\nendings\n")); } diff --git a/xedit.c b/xedit.c index dcd6d5f..e044406 100644 --- a/xedit.c +++ b/xedit.c @@ -103,8 +103,9 @@ static void exec(char* cmd) { /* Action Callbacks ******************************************************************************/ -static void onerror(char* msg) { +static void ondiagmsg(char* msg) { view_append(win_view(TAGS), msg); + win_setregion(TAGS); } static void trim_whitespace(void) { @@ -140,18 +141,15 @@ static void quit(void) { exit(0); #endif } else { - view_append(win_view(TAGS), - "File is modified. Repeat action twice quickly to quit."); + ondiagmsg("File is modified. Repeat action twice quickly to quit."); } before = now; } static bool changed_externally(Buf* buf) { bool modified = (buf->modtime != modtime(buf->path)); - if (modified) { - view_append(win_view(TAGS), - "File modified externally: Reload, Overwrite, or {SaveAs }"); - } + if (modified) + ondiagmsg("File modified externally: Reload, Overwrite, or {SaveAs }"); return modified; } @@ -288,7 +286,7 @@ static void pick_symbol(char* symbol) { win_setregion(EDIT); } else { if (!buf->path && !buf->modified) { - view_init(win_view(EDIT), pick, onerror); + view_init(win_view(EDIT), pick, ondiagmsg); } else { OpenCmd[1] = chomp(pick); cmdrun(OpenCmd, NULL); @@ -466,7 +464,8 @@ void onscroll(double percent) { void onfocus(bool focused) { /* notify the user if the file has changed externally */ - (void)changed_externally(win_buf(EDIT)); + if (focused) + (void)changed_externally(win_buf(EDIT)); } void onupdate(void) { @@ -511,11 +510,11 @@ int main(int argc, char** argv) { if (!ShellCmd[0]) ShellCmd[0] = getenv("SHELL"); if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh"; /* Create the window and enter the event loop */ - win_window("edit", onerror); + win_window("edit", ondiagmsg); char* tags = getenv("EDITTAGS"); win_settext(TAGS, (tags ? tags : DefaultTags)); win_setruler(RulePosition); - view_init(win_view(EDIT), (argc > 1 ? argv[1] : NULL), onerror); + view_init(win_view(EDIT), (argc > 1 ? argv[1] : NULL), ondiagmsg); win_setkeys(Bindings); win_loop(); return 0; -- 2.52.0