screen-users
[Top][All Lists]
Advanced

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

fFtT patch


From: bill
Subject: fFtT patch
Date: Fri, 16 Dec 2005 18:41:26 +0000
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929)

Here's the patch which implements the fFtT;, cursor movements.  I'm not
even remotely confident of this: I cut and pasted from a terminal
into thunderbird.

Common subdirectories: screen-orig/doc and screen-4.0.2/doc
Common subdirectories: screen-orig/etc and screen-4.0.2/etc
diff -u screen-orig/mark.c screen-4.0.2/mark.c
--- screen-orig/mark.c  2003-09-08 15:26:00.000000000 +0100
+++ screen-4.0.2/mark.c 2005-12-15 07:57:16.302048784 +0000
@@ -149,6 +149,55 @@
#define NW_MUSTMOVE    (1<<2)
#define NW_BIG         (1<<3)

+static int
+nextchar(int *xp, int *yp, int direction, char target, int num)
+{   /* Set *xp to the num-th occurrence of the target in the line. */
+
+    /* Return EXIT_FAILURE if the target doesn't appear num times.
+    Caller could use that to emit a warning. */
+
+    int    width;           /* width of the current window. */
+ int x; /* x coordinate of the current cursor position. */
+    int    step;            /* amount to increment x (+1 or -1) */
+    int    adjust;          /* Final adjustment of cursor position. */
+    char  *displayed_line;  /* Line in which search takes place. */
+
+    debug("nextchar\n");
+
+    x              = *xp;
+    adjust         = 0;
+    width          = fore->w_width;
+    displayed_line = WIN(*yp) -> image;
+
+    switch(direction) {
+    case 't': adjust = -1; /* fall through */
+    case 'f': step = 1;    /* fall through */
+        break;
+    case 'T': adjust = 1;  /* fall through */
+    case 'F': step = -1;   /* fall through */
+        break;
+    default:
+        ASSERT(0);
+    }
+
+    x += step;
+
+    debug1("ml->image = %s\n", displayed_line);
+    debug2("num = %d, width = %d\n",num, width);
+    debug2("x = %d targe = %c\n", x, target );
+
+    for ( ;x>=0 && x <= width; x += step) {
+        if (displayed_line[x] == target) {
+            if (--num == 0) {
+                *xp = x + adjust;
+                return EXIT_SUCCESS;
+            }
+        }
+    }
+    return EXIT_FAILURE;
+}
+
+
static void
nextword(xp, yp, flags, num)
int *xp, *yp, flags, num;
@@ -534,8 +583,55 @@
       }
      cx = markdata->cx;
      cy = markdata->cy;
+
+      if (markdata -> char_search[0]) {
+        debug2("searching for %c:%d\n",od,rep_cnt);
+        markdata->char_search[0] = 0;  /* Clear the flag. */
+        markdata->rep_cnt = 0;
+
+        if (isgraph (od)) {
+          markdata->char_search[1] = od;
+          rep_cnt = (rep_cnt) ? rep_cnt : 1;
+          nextchar(&cx, &cy, markdata->char_search[2], od, rep_cnt );
+          revto(cx, cy);
+          continue;
+        }
+      }
+
      switch (od)
       {
+        case 'f': /* fall through */
+        case 'F': /* fall through */
+        case 't': /* fall through */
+        case 'T': /* fall through */
+            markdata -> char_search[0] = markdata->char_search[2] = od;
+            debug("entering char search\n");
+            continue;
+            /* If we break, rep_cnt will be reset, so we
+            continue instead.  It might be cleaner to
+            store the rep_count in char_search and
+            break here so later followon code will be
+            hit. */
+        case ';':
+                if (!rep_cnt) rep_cnt = 1;
+ nextchar(&cx, &cy, markdata->char_search[2], markdata->char_search[1], rep_cnt );
+                revto(cx, cy);
+                break;
+        case ',': {
+                int search_dir;
+                if (!rep_cnt) rep_cnt = 1;
+                switch (markdata->char_search[2]) {
+                case 't': search_dir = 'T'; break;
+                case 'T': search_dir = 't'; break;
+                case 'f': search_dir = 'F'; break;
+                case 'F': search_dir = 'f'; break;
+                }
+ nextchar(&cx, &cy, search_dir, markdata->char_search[1], rep_cnt );
+
+                revto(cx, cy);
+                break;
+            }
+
       case 'o':
       case 'x':
         if (!markdata->second)
diff -u screen-orig/mark.h screen-4.0.2/mark.h
--- screen-orig/mark.h  2002-01-08 15:42:30.000000000 +0000
+++ screen-4.0.2/mark.h 2005-12-14 21:11:45.452032960 +0000
@@ -41,6 +41,7 @@
  int  isdir;          /* current search direction */
  int  isstartpos;     /* position where isearch was started */
  int  isstartdir;     /* direction when isearch was started */
+  int   char_search[3];
};


Common subdirectories: screen-orig/terminfo and screen-4.0.2/terminfo
Common subdirectories: screen-orig/utf8encodings and screen-4.0.2/utf8encodings





reply via email to

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