1 Subject: scroll left/right with mouse wheel
3 Adds a units option for the scroll_left()/scroll_right() action routines:
12 doc/help.etx | 22 +++++++++++++---------
13 source/text.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
14 util/misc.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
15 3 files changed, 104 insertions(+), 11 deletions(-)
17 diff --quilt old/source/text.c new/source/text.c
20 @@ -428,6 +428,12 @@ static char defaultTranslations[] =
21 "<FocusIn>: focusIn()\n"
22 "<FocusOut>: focusOut()\n"
23 /* Support for mouse wheel in XFree86 */
24 + "Shift Alt<Btn4Down>,<Btn4Up>: scroll_left(1)\n"
25 + "Shift Alt<Btn5Down>,<Btn5Up>: scroll_right(1)\n"
26 + "Ctrl Alt<Btn4Down>,<Btn4Up>: scroll_left(1, tab)\n"
27 + "Ctrl Alt<Btn5Down>,<Btn5Up>: scroll_right(1, tab)\n"
28 + "Alt<Btn4Down>,<Btn4Up>: scroll_left(1, char)\n"
29 + "Alt<Btn5Down>,<Btn5Up>: scroll_right(1, char)\n"
30 "Shift<Btn4Down>,<Btn4Up>: scroll_up(1)\n"
31 "Shift<Btn5Down>,<Btn5Up>: scroll_down(1)\n"
32 "Ctrl<Btn4Down>,<Btn4Up>: scroll_up(1, pages)\n"
33 @@ -3401,8 +3407,27 @@ static void scrollLeftAP(Widget w, XEven
35 if (*nArgs == 0 || sscanf(args[0], "%d", &nPixels) != 1)
39 + if (strncmp(args[1], "char", 4) == 0) {
40 + nPixels *= TextDMinFontWidth(textD, True);
42 + else if (strncmp(args[1], "tab", 3) == 0) {
43 + nPixels *= TextDMinFontWidth(textD, True) * textD->buffer->tabDist;
45 + else if (strncmp(args[1], "emtab", 5) == 0) {
46 + int tabDist = ((TextWidget)w)->text.emulateTabs;
48 + tabDist = textD->buffer->tabDist;
49 + nPixels *= TextDMinFontWidth(textD, True) * tabDist;
51 + else if (strncmp(args[1], "pixel", 5) != 0) {
56 XtVaGetValues(textD->hScrollBar, XmNmaximum, &sliderMax,
57 - XmNsliderSize, &sliderSize, NULL);
58 + XmNsliderSize, &sliderSize, NULL);
59 horizOffset = min(max(0, textD->horizOffset - nPixels), sliderMax - sliderSize);
60 if (textD->horizOffset != horizOffset) {
61 TextDSetScroll(textD, textD->topLineNum, horizOffset);
62 @@ -3418,6 +3443,25 @@ static void scrollRightAP(Widget w, XEve
64 if (*nArgs == 0 || sscanf(args[0], "%d", &nPixels) != 1)
68 + if (strncmp(args[1], "char", 4) == 0) {
69 + nPixels *= TextDMinFontWidth(textD, True);
71 + else if (strncmp(args[1], "tab", 3) == 0) {
72 + nPixels *= TextDMinFontWidth(textD, True) * textD->buffer->tabDist;
74 + else if (strncmp(args[1], "emtab", 5) == 0) {
75 + int tabDist = ((TextWidget)w)->text.emulateTabs;
77 + tabDist = textD->buffer->tabDist;
78 + nPixels *= TextDMinFontWidth(textD, True) * tabDist;
80 + else if (strncmp(args[1], "pixel", 5) != 0) {
85 XtVaGetValues(textD->hScrollBar, XmNmaximum, &sliderMax,
86 XmNsliderSize, &sliderSize, NULL);
87 horizOffset = min(max(0, textD->horizOffset + nPixels), sliderMax - sliderSize);
88 diff --quilt old/util/misc.c new/util/misc.c
91 @@ -156,6 +156,10 @@ static void pageDownAP(Widget w, XEvent
93 static void pageUpAP(Widget w, XEvent *event, String *args,
95 +static void scrollLeftAP(Widget w, XEvent *event, String *args,
97 +static void scrollRightAP(Widget w, XEvent *event, String *args,
99 static long queryDesktop(Display *display, Window window, Atom deskTopAtom);
100 static void warning(const char* mesg);
101 static void microsleep(long usecs);
102 @@ -1929,7 +1933,9 @@ void InstallMouseWheelActions(XtAppConte
103 {"scrolled-window-scroll-up", scrollUpAP},
104 {"scrolled-window-page-up", pageUpAP},
105 {"scrolled-window-scroll-down", scrollDownAP},
106 - {"scrolled-window-page-down", pageDownAP}
107 + {"scrolled-window-page-down", pageDownAP},
108 + {"scrolled-window-scroll-left", scrollLeftAP},
109 + {"scrolled-window-scroll-right", scrollRightAP}
112 XtAppAddActions(context, Actions, XtNumber(Actions));
113 @@ -1944,6 +1950,12 @@ void AddMouseWheelSupport(Widget w)
114 if (XmIsScrolledWindow(XtParent(w)))
116 static const char scrollTranslations[] =
117 + "Shift Alt<Btn4Down>,<Btn4Up>: scrolled-window-scroll-left(1)\n"
118 + "Shift Alt<Btn5Down>,<Btn5Up>: scrolled-window-scroll-right(1)\n"
119 + "Ctrl Alt<Btn4Down>,<Btn4Up>: scrolled-window-scroll-left(8)\n"
120 + "Ctrl Alt<Btn5Down>,<Btn5Up>: scrolled-window-scroll-right(8)\n"
121 + "Alt<Btn4Down>,<Btn4Up>: scrolled-window-scroll-left(4)\n"
122 + "Alt<Btn5Down>,<Btn5Up>: scrolled-window-scroll-right(4)\n"
123 "Shift<Btn4Down>,<Btn4Up>: scrolled-window-scroll-up(1)\n"
124 "Shift<Btn5Down>,<Btn5Up>: scrolled-window-scroll-down(1)\n"
125 "Ctrl<Btn4Down>,<Btn4Up>: scrolled-window-page-up()\n"
126 @@ -2020,6 +2032,39 @@ static void scrollDownAP(Widget w, XEven
130 +static void scrollLeftAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
132 + Widget scrolledWindow, scrollBar;
136 + if (*nArgs == 0 || sscanf(args[0], "%d", &nLines) != 1)
139 + scrolledWindow = XtParent(w);
140 + scrollBar = XtNameToWidget (scrolledWindow, "HorScrollBar");
142 + for (i=0; i<nLines; i++)
143 + XtCallActionProc(scrollBar, "IncrementUpOrLeft", event, al, 1) ;
147 +static void scrollRightAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
149 + Widget scrolledWindow, scrollBar;
153 + if (*nArgs == 0 || sscanf(args[0], "%d", &nLines) != 1)
156 + scrolledWindow = XtParent(w);
157 + scrollBar = XtNameToWidget (scrolledWindow, "HorScrollBar");
159 + for (i=0; i<nLines; i++)
160 + XtCallActionProc(scrollBar, "IncrementDownOrRight", event, al, 1) ;
165 ** This is a disguisting hack to work around a bug in OpenMotif.
166 diff --quilt old/doc/help.etx new/doc/help.etx
169 @@ -2496,7 +2496,7 @@ Macro Subroutines
170 Width of the current pane in pixels.
173 - If tab emulation is turned on in the Tabs...
174 + If tab emulation is turned on in the Tab Stops...
175 dialog of the Preferences menu, the value is the
176 distance between emulated tab stops. If tab
177 emulation is turned off, the value is 0.
178 @@ -2615,7 +2615,7 @@ Macro Subroutines
180 The distance between tab stops for a
181 hardware tab character, as set in the
182 - Tabs... dialog of the Preferences menu.
183 + Tab Stops... dialog of the Preferences menu.
186 The length of the text in the current document.
187 @@ -2626,8 +2626,8 @@ Macro Subroutines
189 Whether the user is allowing the NEdit to insert tab characters to maintain
190 spacing in tab emulation and rectangular dragging operations. (The setting of
191 - the "Use tab characters in padding and emulated tabs" button in the Tabs...
192 - dialog of the Preferences menu.)
193 + the "Use tab characters in padding and emulated tabs" button in the
194 + Tab Stops... dialog of the Preferences menu.)
197 The right margin in the current window for text wrapping and filling.
198 @@ -3776,11 +3776,15 @@ Action Routines
199 Scroll the display down (towards the end of the file) by a given
200 number of units, units being lines or pages. Default units are lines.
202 -**scroll_left( nPixels )**
203 - Scroll the display left by nPixels.
205 -**scroll_right( nPixels )**
206 - Scroll the display right by nPixels.
207 +**scroll_left( nUnits, ["chars" | "tabs" | "emtabs" | "pixels"] )**
208 + Scroll the display left by a given number of units, units being characters,
209 + hardware tab stop spacing, emulated tab stop spacing, or pixels. If emulated
210 + tabs are disabled in the Tab Stops... dialog, "emtabs" is the same as "tabs".
212 +**scroll_right( nUnits, ["chars" | "tabs" | "emtabs" | "pixels"] )**
213 + Scroll the display right by a given number of units, units being characters,
214 + hardware tab stop spacing, emulated tab stop spacing, or pixels. If emulated
215 + tabs are disabled in the Tab Stops... dialog, "emtabs" is the same as "tabs".
217 **scroll_up( nUnits, ["lines" | "pages"] )**
218 Scroll the display up (towards the beginning of the file) by a given