These patches enable showing the region between mark and point in the
edit areas in a different style. The style names are
edit.active.marked and edit.prompt.marked.
Patches should be applied in order, the first one enables
unconditional show (which is ugly), the second one disables the
highlight unless you set mark explicitly.
Do not define these styles if you do not want to see this. ;-)
Enjoy,
Ilya
--- ./LYCurses.c-premark Wed Jan 17 19:55:18 2001
+++ ./LYCurses.c Thu Jan 18 20:37:38 2001
@@ -397,6 +397,7 @@ PUBLIC void curses_w_style ARGS3(
case ABS_ON: /* change without remembering the previous style */
/* don't cache style changes for active links and edits */
if ( style != s_alink && style != s_curedit && style != s_aedit
+ && style != s_aedit_sel
&& style != s_aedit_pad && style != s_aedit_arr ) {
CTRACE((tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP));
if (win == stdscr) cached_styles[YP][XP] = style;
--- ./LYHash.h-premark Wed Jan 17 19:53:08 2001
+++ ./LYHash.h Thu Jan 18 20:41:58 2001
@@ -43,7 +43,8 @@ extern int s_alink, s_a, s_status,
s_sb_bar, s_sb_bg, s_sb_aa, s_sb_naa,
#endif
s_whereis, s_curedit, s_aedit, s_aedit_pad, s_aedit_arr,
- s_prompt_edit, s_prompt_edit_pad, s_prompt_edit_arr;
+ s_prompt_edit, s_prompt_edit_pad, s_prompt_edit_arr,
+ s_aedit_sel, s_prompt_sel;
#define CACHEW 128
#define CACHEH 64
--- ./LYStyle.c-premark Wed Jan 17 19:54:54 2001
+++ ./LYStyle.c Thu Jan 18 21:23:02 2001
@@ -71,6 +71,7 @@ PUBLIC int s_alink = NOSTYLE, s_a =
s_sb_aa = NOSTYLE, s_sb_naa = NOSTYLE,
#endif
s_whereis = NOSTYLE, s_curedit = NOSTYLE, s_aedit = NOSTYLE,
+ s_aedit_sel = NOSTYLE, s_prompt_sel = NOSTYLE,
s_aedit_pad = NOSTYLE, s_aedit_arr = NOSTYLE,
s_prompt_edit = NOSTYLE, s_prompt_edit_pad = NOSTYLE,
s_prompt_edit_arr = NOSTYLE;
@@ -302,12 +303,17 @@ where OBJECT is one of EM,STRONG,B,I,U,B
parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.active.arrow");
s_aedit_arr = hash_code("edit.active.arrow");
}
+ else if (!strncasecomp(element, "edit.active.marked", 18))
+ {
+ parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.active.marked");
+ s_aedit_sel = hash_code("edit.active.marked");
+ }
else if (!strncasecomp(element, "edit.active", 11))
{
parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.active");
s_aedit = hash_code("edit.active");
}
- else if (!strncasecomp(element, "edit.current", 11))
+ else if (!strncasecomp(element, "edit.current", 12))
{
parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.current");
s_curedit = hash_code("edit.current");
@@ -322,6 +328,11 @@ where OBJECT is one of EM,STRONG,B,I,U,B
parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.prompt.arrow");
s_prompt_edit_arr = hash_code("edit.prompt.arrow");
}
+ else if (!strncasecomp(element, "edit.prompt.marked", 18))
+ {
+ parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.prompt.marked");
+ s_prompt_sel = hash_code("edit.prompt.marked");
+ }
else if (!strncasecomp(element, "edit.prompt", 11))
{
parse_attributes(mono,fg,bg,DSTYLE_ELEMENTS,"edit.prompt");
@@ -453,6 +464,8 @@ PUBLIC void parse_userstyles NOARGS
s_prompt_edit_arr = s_prompt_edit;
if (s_prompt_edit_pad == NOSTYLE)
s_prompt_edit_pad = s_prompt_edit;
+ if (s_prompt_sel == NOSTYLE)
+ s_prompt_sel = s_prompt_edit;
if (s_aedit == NOSTYLE)
s_aedit = s_alink;
if (s_aedit_arr == NOSTYLE)
@@ -461,6 +474,8 @@ PUBLIC void parse_userstyles NOARGS
s_aedit_pad = s_aedit;
if (s_curedit == NOSTYLE)
s_curedit = s_aedit;
+ if (s_aedit_sel == NOSTYLE)
+ s_aedit_sel = s_aedit;
}
--- ./LYStrings.c-bad1 Thu Jan 18 19:59:24 2001
+++ ./LYStrings.c Thu Jan 18 21:14:06 2001
@@ -3317,7 +3304,19 @@ PUBLIC void LYRefreshEdit ARGS1(
for (i = 0; i < nrdisplayed; i++)
addch('*');
} else {
- for (i = 0; i < nrdisplayed; i++)
+#ifdef ENHANCED_LINEEDIT
+ if (DspStart > Mark)
+ TmpStyleOn(prompting ? s_prompt_sel : s_aedit_sel);
+#endif
+ for (i = 0; i < nrdisplayed; i++) {
+#ifdef ENHANCED_LINEEDIT
+ if ( (DspStart + i == Mark && Pos > Mark)
+ || (DspStart + i == Pos && Pos < Mark) )
+ TmpStyleOn(prompting ? s_prompt_sel : s_aedit_sel);
+ if ( (DspStart + i == Mark && Pos < Mark)
+ || (DspStart + i == Pos && Pos > Mark) )
+ TmpStyleOff(prompting ? s_prompt_sel : s_aedit_sel);
+#endif
if ((buffer[0] = str[i]) == 1 || buffer[0] == 2 ||
((unsigned char)buffer[0] == 160 &&
!(HTPassHighCtrlRaw || HTCJK != NOCJK ||
@@ -3350,6 +3349,12 @@ PUBLIC void LYRefreshEdit ARGS1(
#endif /* SUPPORT_MULTIBYTE_EDIT */
}
}
+ }
+#ifdef ENHANCED_LINEEDIT
+ if ((DspStart + nrdisplayed <= Mark && DspStart + nrdisplayed > Pos)
+ || (DspStart + nrdisplayed > Mark && DspStart + nrdisplayed <= Pos))
+ TmpStyleOff(prompting ? s_prompt_sel : s_aedit_sel);
+#endif
}
/*
--- ./LYForms.c-pre-activemark Thu Jan 18 20:20:42 2001
+++ ./LYForms.c Thu Jan 18 21:40:18 2001
@@ -445,7 +445,7 @@ PRIVATE int form_getstr ARGS3(
MyEdit.pos = LastTFPos;
#ifdef ENHANCED_LINEEDIT
if (MyEdit.pos == 0)
- MyEdit.mark = MyEdit.strlen;
+ MyEdit.mark = -1 - MyEdit.strlen; /* Do not show the region. */
#endif
}
/* Try to prepare for setting position based on the last mouse event */
--- ./LYStrings.c-pre-activemark Thu Jan 18 21:14:06 2001
+++ ./LYStrings.c Thu Jan 18 22:07:10 2001
@@ -2605,7 +2605,7 @@ PUBLIC void LYSetupEdit ARGS4(
Margin = 0;
Pos = strlen(old);
#ifdef ENHANCED_LINEEDIT
- Mark = 0;
+ Mark = -1; /* pos=0, but do not show it yet */
#endif
DspStart = 0;
@@ -2744,6 +2744,10 @@ PUBLIC int LYEdit1 ARGS4(
#ifdef ENHANCED_LINEEDIT
if (Mark > Pos)
Mark++;
+ else if (Mark < -1 - Pos)
+ Mark--;
+ if (Mark >= 0)
+ Mark = -1 - Mark; /* Disable it */
#endif
for(i = length; i >= Pos; i--) /* Make room */
Buf[i+1] = Buf[i];
@@ -2773,6 +2777,10 @@ PUBLIC int LYEdit1 ARGS4(
#ifdef ENHANCED_LINEEDIT
if (Mark > Pos)
Mark++;
+ else if (Mark < -1 - Pos)
+ Mark--;
+ if (Mark >= 0)
+ Mark = -1 - Mark; /* Disable it */
#endif
for(i = length; i >= Pos; i--) /* Make room */
Buf[i+1] = Buf[i];
@@ -2857,7 +2865,7 @@ PUBLIC int LYEdit1 ARGS4(
*/
Buf[0] = '\0';
#ifdef ENHANCED_LINEEDIT
- Mark = 0;
+ Mark = -1; /* Do not show the mark */
#endif
/* fall through */
@@ -2946,8 +2954,10 @@ PUBLIC int LYEdit1 ARGS4(
if (length == 0 || Pos == 0)
break;
#ifdef ENHANCED_LINEEDIT
- if (Mark >= Pos)
- Mark--;
+ if (Mark >= 0)
+ Mark = -1 - Mark; /* Disable it */
+ if (Mark <= -1 - Pos)
+ Mark++;
#endif
Pos--;
for (i = Pos; i < length; i++)
@@ -2968,6 +2978,12 @@ PUBLIC int LYEdit1 ARGS4(
for (i = Pos; i < length; i++)
Buf[i] = Buf[i + offset];
i -= offset;
+#ifdef ENHANCED_LINEEDIT
+ if (Mark >= 0)
+ Mark = -1 - Mark; /* Disable it */
+ if (Mark <= -1 - Pos)
+ Mark += offset;
+#endif
}
#endif /* SUPPORT_MULTIBYTE_EDIT */
Buf[i] = 0;
@@ -3021,8 +3037,12 @@ PUBLIC int LYEdit1 ARGS4(
return(ch);
if (Pos == length)
Pos--;
+ if (Mark < 0)
+ Mark = -1 - Mark; /* Temporary enable it */
if (Mark == Pos || Mark == Pos+1)
Mark = Pos-1;
+ if (Mark >= 0)
+ Mark = -1 - Mark; /* Disable it */
if (Buf[Pos-1] == Buf[Pos]) {
Pos++;
break;
@@ -3041,6 +3061,8 @@ PUBLIC int LYEdit1 ARGS4(
/*
* emacs-like exchange-point-and-mark
*/
+ if (Mark < 0)
+ Mark = -1 - Mark; /* Enable it */
if (Mark == Pos)
return(0);
i = Pos; Pos = Mark; Mark = i;
@@ -3050,6 +3072,8 @@ PUBLIC int LYEdit1 ARGS4(
/*
* primitive emacs-like kill-region
*/
+ if (Mark < 0)
+ Mark = -1 - Mark; /* Enable it */
if (Mark == Pos) {
killbuffer[0] = '\0';
return(0);
@@ -3066,6 +3090,8 @@ PUBLIC int LYEdit1 ARGS4(
Buf[i] = Buf[i+reglen]; /* terminate */
Pos = Mark;
}
+ if (Mark >= 0)
+ Mark = -1 - Mark; /* Disable it */
break;
case LYE_YANK:
@@ -3073,14 +3099,14 @@ PUBLIC int LYEdit1 ARGS4(
* primitive emacs-like yank
*/
if (!killbuffer[0]) {
- Mark = Pos;
+ Mark = -1 - Pos;
return(0);
}
{
int yanklen = strlen(killbuffer);
if (Pos+yanklen <= (MaxLen) && StrLen+yanklen <= (MaxLen)) {
- Mark = Pos;
+ Mark = -1 - Pos;
for(i = length; i >= Pos; i--) /* Make room */
Buf[i+yanklen] = Buf[i];
@@ -3305,16 +3331,16 @@ PUBLIC void LYRefreshEdit ARGS1(
addch('*');
} else {
#ifdef ENHANCED_LINEEDIT
- if (DspStart > Mark)
+ if (Mark >= 0 && DspStart > Mark)
TmpStyleOn(prompting ? s_prompt_sel : s_aedit_sel);
#endif
for (i = 0; i < nrdisplayed; i++) {
#ifdef ENHANCED_LINEEDIT
- if ( (DspStart + i == Mark && Pos > Mark)
- || (DspStart + i == Pos && Pos < Mark) )
+ if ( Mark >= 0 && ((DspStart + i == Mark && Pos > Mark)
+ || (DspStart + i == Pos && Pos < Mark) ))
TmpStyleOn(prompting ? s_prompt_sel : s_aedit_sel);
- if ( (DspStart + i == Mark && Pos < Mark)
- || (DspStart + i == Pos && Pos > Mark) )
+ if ( Mark >= 0 && ((DspStart + i == Mark && Pos < Mark)
+ || (DspStart + i == Pos && Pos > Mark) ))
TmpStyleOff(prompting ? s_prompt_sel : s_aedit_sel);
#endif
if ((buffer[0] = str[i]) == 1 || buffer[0] == 2 ||
@@ -3351,8 +3377,10 @@ PUBLIC void LYRefreshEdit ARGS1(
}
}
#ifdef ENHANCED_LINEEDIT
- if ((DspStart + nrdisplayed <= Mark && DspStart + nrdisplayed > Pos)
- || (DspStart + nrdisplayed > Mark && DspStart + nrdisplayed <= Pos))
+ if (Mark >= 0 &&
+ ((DspStart + nrdisplayed <= Mark && DspStart + nrdisplayed > Pos)
+ || (DspStart + nrdisplayed > Mark
+ && DspStart + nrdisplayed <= Pos)))
TmpStyleOff(prompting ? s_prompt_sel : s_aedit_sel);
#endif
}
--- ./LYStrings.h-pre-activemark Sun Oct 15 21:40:58 2000
+++ ./LYStrings.h Thu Jan 18 21:39:50 2001
@@ -195,7 +195,8 @@ typedef struct _EditFieldData {
int margin; /* Number of columns look-ahead/look-back */
int current_modifiers; /* Modifiers for next input lynxkeycode */
#ifdef ENHANCED_LINEEDIT
- int mark; /* position of emacs-like mark */
+ int mark; /* position of emacs-like mark, or -1-pos to denote
+ unactive mark. */
#endif
char buffer[1024]; /* String buffer */