Skip to content

Instantly share code, notes, and snippets.

@saitoha
Last active December 15, 2015 07:59
Show Gist options
  • Select an option

  • Save saitoha/5227332 to your computer and use it in GitHub Desktop.

Select an option

Save saitoha/5227332 to your computer and use it in GitHub Desktop.
less(1) - add support for alternate scroll mode (xterm, DECSET 1007) http://www.greenwoodsoftware.com/less/
diff -u less-457/opttbl.c less-457-alternate-scroll/opttbl.c
--- less-457/opttbl.c 2012-12-09 07:15:56.000000000 +0900
+++ less-457-alternate-scroll/opttbl.c 2013-03-23 20:05:50.000000000 +0900
@@ -44,6 +44,7 @@
public int chopline; /* Truncate displayed lines at screen width */
public int no_init; /* Disable sending ti/te termcap strings */
public int no_keypad; /* Disable sending ks/ke termcap strings */
+public int no_wheel; /* Disable alternate wheel mode */
public int twiddle; /* Show tildes after EOF */
public int show_attn; /* Hilite first unread line */
public int shift_count; /* Number of positions to shift horizontally */
@@ -432,6 +433,14 @@
NULL
}
},
+ { OLETTER_NONE, &keypad_optname,
+ BOOL|NO_TOGGLE, OPT_OFF, &no_wheel, NULL,
+ {
+ "Use alternate scroll mode",
+ "Don't use alternate scroll mode",
+ NULL
+ }
+ },
{ OLETTER_NONE, &oldbot_optname,
BOOL, OPT_OFF, &oldbot, NULL,
{
Binary files less-457/opttbl.o and less-457-alternate-scroll/opttbl.o differ
diff -u less-457/screen.c less-457-alternate-scroll/screen.c
--- less-457/screen.c 2012-12-09 07:15:55.000000000 +0900
+++ less-457-alternate-scroll/screen.c 2013-03-24 13:06:52.000000000 +0900
@@ -179,6 +179,8 @@
*sc_backspace, /* Backspace cursor */
*sc_s_keypad, /* Start keypad mode */
*sc_e_keypad, /* End keypad mode */
+ *sc_s_wheel, /* Start alternate scroll mode */
+ *sc_e_wheel, /* End alternate scroll mode */
*sc_init, /* Startup terminal initialization */
*sc_deinit; /* Exit terminal de-initialization */
#endif
@@ -227,6 +229,7 @@
extern int swindow;
extern int no_init;
extern int no_keypad;
+extern int no_wheel;
extern int sigs;
extern int wscroll;
extern int screen_trashed;
@@ -1207,6 +1210,9 @@
if (sc_e_keypad == NULL)
sc_e_keypad = "";
+ sc_s_wheel = "\033[?1007h";
+ sc_e_wheel = "\033[?1007l";
+
sc_init = ltgetstr("ti", &sp);
if (sc_init == NULL)
sc_init = "";
@@ -1537,6 +1543,8 @@
tputs(sc_init, sc_height, putchr);
if (!no_keypad)
tputs(sc_s_keypad, sc_height, putchr);
+ if (!no_wheel)
+ tputs(sc_s_wheel, 1, putchr);
if (top_scroll)
{
int i;
@@ -1571,6 +1579,8 @@
if (!init_done)
return;
#if !MSDOS_COMPILER
+ if (!no_wheel)
+ tputs(sc_e_wheel, 1, putchr);
if (!no_keypad)
tputs(sc_e_keypad, sc_height, putchr);
if (!no_init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment