qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs qe.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs qe.c
Date: Thu, 2 Mar 2017 10:21:16 -0500 (EST)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/03/02 10:21:16

Modified files:
        .              : qe.c 

Log message:
        basic: improve goto-line and goto-char and next-mode
        - handle size suffixes kmg and KMG
        - split qe_find_target_window() for next-mode and find-file
          from a dired left pane

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.248&r2=1.249

Patches:
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -b -r1.248 -r1.249
--- qe.c        25 Feb 2017 19:39:49 -0000      1.248
+++ qe.c        2 Mar 2017 15:21:16 -0000       1.249
@@ -2369,7 +2369,7 @@
 
 /* do_goto: move point to a specified position.
  * take string and default unit,
- * string is parsed as an integer with an optional unit and suffix
+ * string is parsed as an integer with an optional sign, unit and suffix
  * units: (b)yte, (c)har, (w)ord, (l)line, (%)percentage
  * optional suffix :col or .col for column number in goto_line
  */
@@ -2394,6 +2394,31 @@
     /* skip space required to separate hex offset from b or c suffix */
     if (*p == ' ')
         p++;
+
+    /* handle an optional multiple suffix */
+    switch (*p) {
+    case 'g':
+        pos *= 1000;
+        /* fall thru */
+    case 'm':
+        pos *= 1000;
+        /* fall thru */
+    case 'k':
+        pos *= 1000;
+        p++;
+        break;
+    case 'G':
+        pos *= 1024;
+        /* fall thru */
+    case 'M':
+        pos *= 1024;
+        /* fall thru */
+    case 'K':
+        pos *= 1024;
+        p++;
+        break;
+    }
+
     if (memchr("bcwl%", *p, 5))
         unit = *p++;
 
@@ -2403,6 +2428,9 @@
             goto error;
         if (rel)
             pos += s->offset;
+        /* XXX: should realign on character boundary?
+         *      realignment probably better addressed in display module
+         */
         s->offset = clamp(pos, 0, s->b->total_size);
         return;
     case 'c':
@@ -2423,7 +2451,7 @@
 
     case 'l':
         line = pos - 1;
-        if (rel || pos == 0) {
+        if (rel || pos <= 0) {
             eb_get_pos(s->b, &line, &col, s->offset);
             line += pos;
         }
@@ -6516,6 +6544,21 @@
     return found_modes;
 }
 
+static EditState *qe_find_target_window(EditState *s, int activate) {
+    /* Find the target window for some commands run from the dired window */
+#ifndef CONFIG_TINY
+    if ((s->flags & WF_POPLEFT) && s->x1 == 0) {
+        EditState *e = find_window(s, KEY_RIGHT, NULL);
+        if (e) {
+            if (activate && s->qe_state->active_window == s)
+                s->qe_state->active_window = e;
+            s = e;
+        }
+    }
+#endif
+    return s;
+}
+
 /* Select appropriate mode for buffer:
  * iff dir == 0, select best mode
  * iff dir > 0, select next mode
@@ -6523,6 +6566,8 @@
  */
 void do_set_next_mode(EditState *s, int dir)
 {
+    /* next-mode from the dired window applies to the target window */
+    s = qe_find_target_window(s, 0);
     qe_set_next_mode(s, dir, 1);
 }
 
@@ -6592,14 +6637,8 @@
     /* when exploring from a popleft dired buffer, load a directory or
      * file pattern into the same pane, but load a regular file into the view 
pane
      */
-    if ((s->flags & WF_POPLEFT) && s->x1 == 0
-    &&  !is_directory(filename) && !is_filepattern(filename)) {
-        EditState *e = find_window(s, KEY_RIGHT, NULL);
-        if (e) {
-            if (s->qe_state->active_window == s)
-                s->qe_state->active_window = e;
-            s = e;
-        }
+    if (!is_directory(filename) && !is_filepattern(filename)) {
+        s = qe_find_target_window(s, 1);
     }
 #endif
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]