]> git.mdlowis.com Git - projs/tide.git/commitdiff
diagnostic messages printed to tags region now steal focus
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 25 May 2017 19:39:17 +0000 (15:39 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 25 May 2017 19:39:17 +0000 (15:39 -0400)
TODO.md
tests/xedit.c
xedit.c

diff --git a/TODO.md b/TODO.md
index 541018ee0b1b6cc263db883e1614a4eddee35bf4..8d692914796f9f40da89020be241d5764ede8610 100644 (file)
--- 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
index 652bc1ca7e2969ea27367cffdd15ac1fd5709ad9..4423cc1ac544f5e864b3db7571417854c4ef9e1a 100644 (file)
@@ -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 dcd6d5f44a53015de600e1ab23c3da86e623f67c..e04440609dccae1c7e8038c1bd152e3b002b4de3 100644 (file)
--- 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;