update .gitignore
[nedit-bw.git] / leftrightmousewheel.patch
blobfc1a4eb5646b38afa6d1f18d801188978e6318f8
1 ---
3 doc/help.etx | 22 +++++++++++++---------
4 source/text.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
5 util/misc.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
6 3 files changed, 104 insertions(+), 11 deletions(-)
8 diff --quilt old/source/text.c new/source/text.c
9 --- old/source/text.c
10 +++ new/source/text.c
11 @@ -426,10 +426,16 @@ static char defaultTranslations[] =
12 "Ctrl~Meta~Alt Button3<MotionNotify>: mouse_pan()\n"
13 "<Btn3Up>: end_drag()\n"
14 "<FocusIn>: focusIn()\n"
15 "<FocusOut>: focusOut()\n"
16 /* Support for mouse wheel in XFree86 */
17 + "Shift Alt<Btn4Down>,<Btn4Up>: scroll_left(1)\n"
18 + "Shift Alt<Btn5Down>,<Btn5Up>: scroll_right(1)\n"
19 + "Ctrl Alt<Btn4Down>,<Btn4Up>: scroll_left(1, tab)\n"
20 + "Ctrl Alt<Btn5Down>,<Btn5Up>: scroll_right(1, tab)\n"
21 + "Alt<Btn4Down>,<Btn4Up>: scroll_left(1, char)\n"
22 + "Alt<Btn5Down>,<Btn5Up>: scroll_right(1, char)\n"
23 "Shift<Btn4Down>,<Btn4Up>: scroll_up(1)\n"
24 "Shift<Btn5Down>,<Btn5Up>: scroll_down(1)\n"
25 "Ctrl<Btn4Down>,<Btn4Up>: scroll_up(1, pages)\n"
26 "Ctrl<Btn5Down>,<Btn5Up>: scroll_down(1, pages)\n"
27 "<Btn4Down>,<Btn4Up>: scroll_up(5)\n"
28 @@ -3399,12 +3405,31 @@ static void scrollLeftAP(Widget w, XEven
29 int horizOffset, nPixels;
30 int sliderMax, sliderSize;
32 if (*nArgs == 0 || sscanf(args[0], "%d", &nPixels) != 1)
33 return;
35 + if (*nArgs == 2) {
36 + if (strncmp(args[1], "char", 4) == 0) {
37 + nPixels *= TextDMinFontWidth(textD, True);
38 + }
39 + else if (strncmp(args[1], "tab", 3) == 0) {
40 + nPixels *= TextDMinFontWidth(textD, True) * textD->buffer->tabDist;
41 + }
42 + else if (strncmp(args[1], "emtab", 5) == 0) {
43 + int tabDist = ((TextWidget)w)->text.emulateTabs;
44 + if (tabDist <= 0)
45 + tabDist = textD->buffer->tabDist;
46 + nPixels *= TextDMinFontWidth(textD, True) * tabDist;
47 + }
48 + else if (strncmp(args[1], "pixel", 5) != 0) {
49 + return;
50 + }
51 + }
53 XtVaGetValues(textD->hScrollBar, XmNmaximum, &sliderMax,
54 - XmNsliderSize, &sliderSize, NULL);
55 + XmNsliderSize, &sliderSize, NULL);
56 horizOffset = min(max(0, textD->horizOffset - nPixels), sliderMax - sliderSize);
57 if (textD->horizOffset != horizOffset) {
58 TextDSetScroll(textD, textD->topLineNum, horizOffset);
61 @@ -3416,10 +3441,29 @@ static void scrollRightAP(Widget w, XEve
62 int horizOffset, nPixels;
63 int sliderMax, sliderSize;
65 if (*nArgs == 0 || sscanf(args[0], "%d", &nPixels) != 1)
66 return;
68 + if (*nArgs == 2) {
69 + if (strncmp(args[1], "char", 4) == 0) {
70 + nPixels *= TextDMinFontWidth(textD, True);
71 + }
72 + else if (strncmp(args[1], "tab", 3) == 0) {
73 + nPixels *= TextDMinFontWidth(textD, True) * textD->buffer->tabDist;
74 + }
75 + else if (strncmp(args[1], "emtab", 5) == 0) {
76 + int tabDist = ((TextWidget)w)->text.emulateTabs;
77 + if (tabDist <= 0)
78 + tabDist = textD->buffer->tabDist;
79 + nPixels *= TextDMinFontWidth(textD, True) * tabDist;
80 + }
81 + else if (strncmp(args[1], "pixel", 5) != 0) {
82 + return;
83 + }
84 + }
86 XtVaGetValues(textD->hScrollBar, XmNmaximum, &sliderMax,
87 XmNsliderSize, &sliderSize, NULL);
88 horizOffset = min(max(0, textD->horizOffset + nPixels), sliderMax - sliderSize);
89 if (textD->horizOffset != horizOffset) {
90 TextDSetScroll(textD, textD->topLineNum, horizOffset);
91 diff --quilt old/util/misc.c new/util/misc.c
92 --- old/util/misc.c
93 +++ new/util/misc.c
94 @@ -154,10 +154,14 @@ static void scrollUpAP(Widget w, XEvent
95 Cardinal *nArgs);
96 static void pageDownAP(Widget w, XEvent *event, String *args,
97 Cardinal *nArgs);
98 static void pageUpAP(Widget w, XEvent *event, String *args,
99 Cardinal *nArgs);
100 +static void scrollLeftAP(Widget w, XEvent *event, String *args,
101 + Cardinal *nArgs);
102 +static void scrollRightAP(Widget w, XEvent *event, String *args,
103 + Cardinal *nArgs);
104 static long queryDesktop(Display *display, Window window, Atom deskTopAtom);
105 static void warning(const char* mesg);
106 static void microsleep(long usecs);
109 @@ -1927,11 +1931,13 @@ void InstallMouseWheelActions(XtAppConte
111 static XtActionsRec Actions[] = {
112 {"scrolled-window-scroll-up", scrollUpAP},
113 {"scrolled-window-page-up", pageUpAP},
114 {"scrolled-window-scroll-down", scrollDownAP},
115 - {"scrolled-window-page-down", pageDownAP}
116 + {"scrolled-window-page-down", pageDownAP},
117 + {"scrolled-window-scroll-left", scrollLeftAP},
118 + {"scrolled-window-scroll-right", scrollRightAP}
121 XtAppAddActions(context, Actions, XtNumber(Actions));
124 @@ -1942,10 +1948,16 @@ void InstallMouseWheelActions(XtAppConte
125 void AddMouseWheelSupport(Widget w)
127 if (XmIsScrolledWindow(XtParent(w)))
129 static const char scrollTranslations[] =
130 + "Shift Alt<Btn4Down>,<Btn4Up>: scrolled-window-scroll-left(1)\n"
131 + "Shift Alt<Btn5Down>,<Btn5Up>: scrolled-window-scroll-right(1)\n"
132 + "Ctrl Alt<Btn4Down>,<Btn4Up>: scrolled-window-scroll-left(8)\n"
133 + "Ctrl Alt<Btn5Down>,<Btn5Up>: scrolled-window-scroll-right(8)\n"
134 + "Alt<Btn4Down>,<Btn4Up>: scrolled-window-scroll-left(4)\n"
135 + "Alt<Btn5Down>,<Btn5Up>: scrolled-window-scroll-right(4)\n"
136 "Shift<Btn4Down>,<Btn4Up>: scrolled-window-scroll-up(1)\n"
137 "Shift<Btn5Down>,<Btn5Up>: scrolled-window-scroll-down(1)\n"
138 "Ctrl<Btn4Down>,<Btn4Up>: scrolled-window-page-up()\n"
139 "Ctrl<Btn5Down>,<Btn5Up>: scrolled-window-page-down()\n"
140 "<Btn4Down>,<Btn4Up>: scrolled-window-scroll-up(3)\n"
141 @@ -2018,10 +2030,43 @@ static void scrollDownAP(Widget w, XEven
142 for (i=0; i<nLines; i++)
143 XtCallActionProc(scrollBar, "IncrementDownOrRight", event, al, 1) ;
144 return;
147 +static void scrollLeftAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
149 + Widget scrolledWindow, scrollBar;
150 + String al[1];
151 + int i, nLines;
153 + if (*nArgs == 0 || sscanf(args[0], "%d", &nLines) != 1)
154 + return;
155 + al[0] = "Left";
156 + scrolledWindow = XtParent(w);
157 + scrollBar = XtNameToWidget (scrolledWindow, "HorScrollBar");
158 + if (scrollBar)
159 + for (i=0; i<nLines; i++)
160 + XtCallActionProc(scrollBar, "IncrementUpOrLeft", event, al, 1) ;
161 + return;
164 +static void scrollRightAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
166 + Widget scrolledWindow, scrollBar;
167 + String al[1];
168 + int i, nLines;
170 + if (*nArgs == 0 || sscanf(args[0], "%d", &nLines) != 1)
171 + return;
172 + al[0] = "Right";
173 + scrolledWindow = XtParent(w);
174 + scrollBar = XtNameToWidget (scrolledWindow, "HorScrollBar");
175 + if (scrollBar)
176 + for (i=0; i<nLines; i++)
177 + XtCallActionProc(scrollBar, "IncrementDownOrRight", event, al, 1) ;
178 + return;
182 ** This is a disguisting hack to work around a bug in OpenMotif.
183 ** OpenMotif's toggle button Select() action routine remembers the last radio
184 ** button that was toggled (stored as global state) and refuses to take any
185 diff --quilt old/doc/help.etx new/doc/help.etx
186 --- old/doc/help.etx
187 +++ new/doc/help.etx
188 @@ -2480,11 +2480,11 @@ Macro Subroutines
190 **$display_width**
191 Width of the current pane in pixels.
193 **$em_tab_dist**
194 - If tab emulation is turned on in the Tabs...
195 + If tab emulation is turned on in the Tab Stops...
196 dialog of the Preferences menu, the value is the
197 distance between emulated tab stops. If tab
198 emulation is turned off, the value is 0.
200 **$empty_array**
201 @@ -2599,23 +2599,23 @@ Macro Subroutines
202 Contains the value of the array sub-script separation string.
204 **$tab_dist**
205 The distance between tab stops for a
206 hardware tab character, as set in the
207 - Tabs... dialog of the Preferences menu.
208 + Tab Stops... dialog of the Preferences menu.
210 **$text_length**
211 The length of the text in the current document.
213 **$top_line**
214 The line number of the top line of the currently active pane.
216 **$use_tabs**
217 Whether the user is allowing the NEdit to insert tab characters to maintain
218 spacing in tab emulation and rectangular dragging operations. (The setting of
219 - the "Use tab characters in padding and emulated tabs" button in the Tabs...
220 - dialog of the Preferences menu.)
221 + the "Use tab characters in padding and emulated tabs" button in the
222 + Tab Stops... dialog of the Preferences menu.)
224 **$wrap_margin**
225 The right margin in the current window for text wrapping and filling.
227 **$wrap_text**
228 @@ -3761,15 +3761,19 @@ Action Routines
230 **scroll_down( nUnits, ["lines" | "pages"] )**
231 Scroll the display down (towards the end of the file) by a given
232 number of units, units being lines or pages. Default units are lines.
234 -**scroll_left( nPixels )**
235 - Scroll the display left by nPixels.
237 -**scroll_right( nPixels )**
238 - Scroll the display right by nPixels.
239 +**scroll_left( nUnits, ["chars" | "tabs" | "emtabs" | "pixels"] )**
240 + Scroll the display left by a given number of units, units being characters,
241 + hardware tab stop spacing, emulated tab stop spacing, or pixels. If emulated
242 + tabs are disabled in the Tab Stops... dialog, "emtabs" is the same as "tabs".
244 +**scroll_right( nUnits, ["chars" | "tabs" | "emtabs" | "pixels"] )**
245 + Scroll the display right by a given number of units, units being characters,
246 + hardware tab stop spacing, emulated tab stop spacing, or pixels. If emulated
247 + tabs are disabled in the Tab Stops... dialog, "emtabs" is the same as "tabs".
249 **scroll_up( nUnits, ["lines" | "pages"] )**
250 Scroll the display up (towards the beginning of the file) by a given
251 number of units, units being lines or pages. Default units are lines.