Currently, if you bind Left and Right to LEFT_LINK and RIGHT_LINK (as
one should ;-), the behaviour in the edit fields is not intuitive.
The actions implemented in the patch make cursor move to the
link/textarea next to the right if done at the end of the edit-field,
similar for LYE_PREV_LL.

The patches should be applied in order, the second one fixes a minor
problem with the first one.

Enjoy,
Ilya
Does not work for left movement after editing...

--- ./src/LYForms.c~    Thu Aug  3 12:19:52 2000
+++ ./src/LYForms.c     Sun Oct 15 21:40:32 2000
@@ -717,7 +717,9 @@ again:
                    case LYE_BOL:
                    case LYE_EOL:
                    case LYE_FORW:
+                   case LYE_FORW_RL:
                    case LYE_BACK:
+                   case LYE_BACK_LL:
                    case LYE_FORWW:
                    case LYE_BACKW:
 #ifdef EXP_KEYBOARD_LAYOUT
@@ -738,10 +740,14 @@ again:
                if (repeat < 0)
                    repeat = 1;
                while (repeat--) {
-#ifndef SUPPORT_MULTIBYTE_EDIT
-                   LYLineEdit(&MyEdit, ch, TRUE);
-#else /* SUPPORT_MULTIBYTE_EDIT */
-                   if (LYLineEdit(&MyEdit, ch, TRUE) == 0) {
+                   int rc = LYLineEdit(&MyEdit, ch, TRUE);
+
+                   if (rc < 0) {
+                       ch = -rc;
+                       goto breakfor;
+                   }
+#ifdef SUPPORT_MULTIBYTE_EDIT
+                   if (rc == 0) {
                        if (HTCJK != NOCJK && (0x80 <= ch)
                        && (ch <= 0xfe) && refresh_mb)
                            refresh_mb = FALSE;
@@ -771,9 +777,7 @@ again:
                LYSetLastTFPos(MyEdit.pos);
        }
     }
-#if defined(NOTDEFINED) || defined(SH_EX)
-breakfor:
-#endif /* NOTDEFINED */
+  breakfor:
     if (Edited) {
        char  *p;
 
--- ./src/LYKeymap.c~   Thu Sep 21 21:21:58 2000
+++ ./src/LYKeymap.c    Sun Oct 15 21:39:38 2000
@@ -1010,7 +1010,9 @@ PRIVATE struct emap ekmap[] = {
   {"BOL",      LYE_BOL,        "Go to begin of line"},
   {"EOL",      LYE_EOL,        "Go to end   of line"},
   {"FORW",     LYE_FORW,       "Cursor forwards"},
+  {"FORW_RL",  LYE_FORW_RL,    "Cursor forwards or right link"},
   {"BACK",     LYE_BACK,       "Cursor backwards"},
+  {"BACK_LL",  LYE_BACK_LL,    "Cursor backwards or left link"},
   {"FORWW",    LYE_FORWW,      "Word forward"},
   {"BACKW",    LYE_BACKW,      "Word back"},
 
--- ./src/LYStrings.c~  Sun Oct 15 20:56:24 2000
+++ ./src/LYStrings.c   Sun Oct 15 21:57:58 2000
@@ -2664,6 +2664,7 @@ PUBLIC int LYEdit1 ARGS4(
        int,            action,
        BOOL,           maxMessage)
 {   /* returns 0    character processed
+     *         -ch  if action should be performed outside of line-editing mode
      *         ch   otherwise
      */
     int i;
@@ -2972,6 +2973,7 @@ PUBLIC int LYEdit1 ARGS4(
        Buf[i] = 0;
        break;
 
+    case LYE_FORW_RL:
     case LYE_FORW:
        /*
         *  Move cursor to the right.
@@ -2986,8 +2988,11 @@ PUBLIC int LYEdit1 ARGS4(
                Pos++;
        }
 #endif /* SUPPORT_MULTIBYTE_EDIT */
+       else if (action == LYE_FORW_RL)
+           return -ch;
        break;
 
+    case LYE_BACK_LL:
     case LYE_BACK:
        /*
         *  Left-arrow move cursor to the left.
@@ -3003,6 +3008,8 @@ PUBLIC int LYEdit1 ARGS4(
                Pos--;
        }
 #endif /* SUPPORT_MULTIBYTE_EDIT */
+       else if (action == LYE_BACK_LL)
+           return -ch;
        break;
 
 #ifdef ENHANCED_LINEEDIT
--- ./src/LYStrings.h~  Thu Aug  3 12:19:52 2000
+++ ./src/LYStrings.h   Sun Oct 15 21:40:58 2000
@@ -225,8 +225,10 @@ typedef struct _EditFieldData {
 #define LYE_BOL   (LYE_ERASE +1)  /* Go to begin of line   */
 #define LYE_EOL   (LYE_BOL   +1)  /* Go to end   of line   */
 #define LYE_FORW  (LYE_EOL   +1)  /* Cursor forwards       */
-#define LYE_BACK  (LYE_FORW  +1)  /* Cursor backwards      */
-#define LYE_FORWW (LYE_BACK  +1)  /* Word forward          */
+#define LYE_FORW_RL (LYE_FORW +1) /* Cursor forwards or right link */
+#define LYE_BACK  (LYE_FORW_RL+1) /* Cursor backwards      */
+#define LYE_BACK_LL (LYE_BACK+1)  /* Cursor backwards or left link */
+#define LYE_FORWW (LYE_BACK_LL+1) /* Word forward          */
 #define LYE_BACKW (LYE_FORWW +1)  /* Word back             */
 
 #define LYE_LOWER (LYE_BACKW +1)  /* Lower case the line   */
--- ./LYForms.c-pre-goodleft    Sun Oct 15 21:40:32 2000
+++ ./LYForms.c Thu Jan 18 20:20:42 2001
@@ -683,12 +683,12 @@ again:
                goto breakfor;
 #endif /* NOTDEFINED */
 
-           /*
+           default:
+           /*  [ 1999/04/14 (Wed) 15:01:33 ]
             *  Left arrrow in column 0 deserves special treatment here,
             *  else you can get trapped in a form without submit button!
             */
-           case LTARROW:       /* 1999/04/14 (Wed) 15:01:33 */
-               if (MyEdit.pos == 0 && repeat == -1) {
+               if (action == LYE_BACK && MyEdit.pos == 0 && repeat == -1) {
                    int c = YES;    /* Go back immediately if no changes */
                    if (textfield_prompt_at_left_edge) {
                        c = HTConfirmDefault(PREV_DOC_QUERY, NO);
@@ -704,9 +704,6 @@ again:
                            _statusline(ENTER_TEXT_ARROWS_OR_TAB);
                    }
                }
-               /* fall through */
-
-           default:
                if (form->disabled == YES) {
                    /*
                     *  Allow actions that don't modify the contents even
@@ -744,7 +741,25 @@ again:
 
                    if (rc < 0) {
                        ch = -rc;
-                       goto breakfor;
+                       /* FORW_RL and BACK_LL may require special attention.
+                          BACK_LL wanted to switch to the previous link on
+                          the same line.  However, if there is no such link,
+                          then we would either disactivate the form
+                          (with -tna), or will reenter the form, thus we jump
+                          to the end of the line; both are counterintuitive.
+                          Unfortunately, we do not have access to curdoc.link,
+                          so we deduce it ourselves.  We don't have the info
+                          to do it inside LYLineEdit().
+                          This should work for prompts too.  */
+                       if ( (action != LYE_BACK_LL && action != LYE_FORW_RL)
+                            || ((form_link - links) >= 0
+                               && (form_link - links) < nlinks
+                               && (action==LYE_FORW_RL
+                                   ? (form_link - links) < nlinks - 1
+                                   : (form_link - links) > 0)
+                               && form_link[action==LYE_FORW_RL ? 1 : -1].ly
+                                  == form_link->ly))
+                           goto breakfor;
                    }
 #ifdef SUPPORT_MULTIBYTE_EDIT
                    if (rc == 0) {

Reply via email to