fix nc -do ""
[nedit-bw.git] / switch_tabs.patch
blobb19e47d08fabe59ba8e76c9bf9eab9cad3a4da6d
1 Subject: action routines for switching tabs with neighboring tabs
3 NEdit*text.translations: #override \
4 Shift Ctrl<KeyPress>osfPageUp: switch_previous_document()\n\
5 Shift Ctrl<KeyPress>osfPageDown: switch_next_document()\n\
6 ...
8 ---
10 doc/help.etx | 4 ++-
11 source/menu.c | 18 ++++++++++++++
12 source/window.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 source/window.h | 2 +
14 4 files changed, 95 insertions(+), 1 deletion(-)
16 diff --quilt old/source/menu.c new/source/menu.c
17 --- old/source/menu.c
18 +++ new/source/menu.c
19 @@ -331,6 +331,10 @@ static void prevDocumentAP(Widget w, XEv
20 Cardinal *nArgs);
21 static void lastDocumentAP(Widget w, XEvent *event, String *args,
22 Cardinal *nArgs);
23 +static void switchNextDocumentAP(Widget w, XEvent *event, String *args,
24 + Cardinal *nArgs);
25 +static void switchPrevDocumentAP(Widget w, XEvent *event, String *args,
26 + Cardinal *nArgs);
27 static void closePaneAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
28 static void capitalizeAP(Widget w, XEvent *event, String *args,
29 Cardinal *nArgs);
30 @@ -546,6 +550,8 @@ static XtActionsRec Actions[] = {
31 {"next_document", nextDocumentAP},
32 {"previous_document", prevDocumentAP},
33 {"last_document", lastDocumentAP},
34 + {"switch_next_document", switchNextDocumentAP},
35 + {"switch_previous_document", switchPrevDocumentAP},
36 {"uppercase", capitalizeAP},
37 {"lowercase", lowercaseAP},
38 {"fill-paragraph", fillAP},
39 @@ -3733,6 +3739,18 @@ static void lastDocumentAP(Widget w, XEv
40 LastDocument(WidgetToWindow(w));
43 +static void switchNextDocumentAP(Widget w, XEvent *event, String *args,
44 + Cardinal *nArgs)
46 + SwitchWithNextDocument(WidgetToWindow(w));
49 +static void switchPrevDocumentAP(Widget w, XEvent *event, String *args,
50 + Cardinal *nArgs)
52 + SwitchWithPreviousDocument(WidgetToWindow(w));
55 static void capitalizeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
57 WindowInfo *window = WidgetToWindow(w);
58 diff --quilt old/source/window.c new/source/window.c
59 --- old/source/window.c
60 +++ new/source/window.c
61 @@ -4060,6 +4060,78 @@ void LastDocument(WindowInfo *window)
65 +** switch current tab with next tab
66 +*/
67 +void SwitchWithNextDocument(WindowInfo *window)
69 + WindowInfo *win;
70 + Widget w;
71 + WidgetList tabList;
72 + int i, nDoc;
74 + if (WindowList->next == NULL)
75 + return;
77 + win = getNextTabWindow(window, 1, 0, 1);
78 + if (win == NULL)
79 + return;
81 + w = win->tab;
82 + win->tab = window->tab;
83 + window->tab = w;
85 + RefreshTabState(win);
86 + RefreshTabState(window);
88 + RaiseDocument(window);
90 + nDoc = NDocuments(window);
91 + XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList, NULL);
92 + for (i = 0; i < nDoc; i++) {
93 + if (window->tab == tabList[i]) {
94 + XmLFolderSetActiveTab(window->tabBar, i, False);
95 + break;
96 + }
97 + }
101 +** switch current tab with previous tab
103 +void SwitchWithPreviousDocument(WindowInfo *window)
105 + WindowInfo *win;
106 + Widget w;
107 + WidgetList tabList;
108 + int i, nDoc;
110 + if (WindowList->next == NULL)
111 + return;
113 + win = getNextTabWindow(window, -1, 0, 1);
114 + if (win == NULL)
115 + return;
117 + w = win->tab;
118 + win->tab = window->tab;
119 + window->tab = w;
121 + RefreshTabState(win);
122 + RefreshTabState(window);
124 + RaiseDocument(window);
126 + nDoc = NDocuments(window);
127 + XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList, NULL);
128 + for (i = 0; i < nDoc; i++) {
129 + if (window->tab == tabList[i]) {
130 + XmLFolderSetActiveTab(window->tabBar, i, False);
131 + break;
137 ** make sure window is alive is kicking
139 int IsValidWindow(WindowInfo *window)
140 diff --quilt old/source/window.h new/source/window.h
141 --- old/source/window.h
142 +++ new/source/window.h
143 @@ -86,6 +86,8 @@ WindowInfo *MarkActiveDocument(WindowInf
144 void NextDocument(WindowInfo *window);
145 void PreviousDocument(WindowInfo *window);
146 void LastDocument(WindowInfo *window);
147 +void SwitchWithNextDocument(WindowInfo *window);
148 +void SwitchWithPreviousDocument(WindowInfo *window);
149 int NDocuments(WindowInfo *window);
150 WindowInfo *MoveDocument(WindowInfo *toWindow, WindowInfo *window);
151 WindowInfo *DetachDocument(WindowInfo *window);
152 diff --quilt old/doc/help.etx new/doc/help.etx
153 --- old/doc/help.etx
154 +++ new/doc/help.etx
155 @@ -805,7 +805,9 @@ Tabbed Editing
157 Notice that you can re-group tabs at any time by detaching and attaching them,
158 or moving them, to other windows. This can be done using the Windows menu, or
159 - using the context menu, which pops up when right clicking on a tab.
160 + using the context menu, which pops up when right clicking on a tab. You can
161 + also reorder the current tab by switching it with the left or right neighbor
162 + using the actions switch_next_document() or switch_previous_document().
164 You can switch to a tab by simply clicking on it, or you can use the keyboard.
165 The default keybindings to switch tabs (which are Ctrl+PageUp/-Down and Alt+Home,