finally, add at least a subject for each patch
[nedit-bw.git] / switch_tabs.patch
blob1b1adf36a90272450ccec991d47a42a70c1e3ee2
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 @@ -328,10 +328,14 @@ static void nextDocumentAP(Widget w, XEv
20 Cardinal *nArgs);
21 static void prevDocumentAP(Widget w, XEvent *event, String *args,
22 Cardinal *nArgs);
23 static void lastDocumentAP(Widget w, XEvent *event, String *args,
24 Cardinal *nArgs);
25 +static void switchNextDocumentAP(Widget w, XEvent *event, String *args,
26 + Cardinal *nArgs);
27 +static void switchPrevDocumentAP(Widget w, XEvent *event, String *args,
28 + Cardinal *nArgs);
29 static void closePaneAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
30 static void capitalizeAP(Widget w, XEvent *event, String *args,
31 Cardinal *nArgs);
32 static void lowercaseAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
33 static void fillAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
34 @@ -543,10 +547,12 @@ static XtActionsRec Actions[] = {
35 {"detach_document_dialog", detachDocumentDialogAP},
36 {"move_document_dialog", moveDocumentDialogAP},
37 {"next_document", nextDocumentAP},
38 {"previous_document", prevDocumentAP},
39 {"last_document", lastDocumentAP},
40 + {"switch_next_document", switchNextDocumentAP},
41 + {"switch_previous_document", switchPrevDocumentAP},
42 {"uppercase", capitalizeAP},
43 {"lowercase", lowercaseAP},
44 {"fill-paragraph", fillAP},
45 {"fill_paragraph", fillAP},
46 {"control-code-dialog", controlDialogAP},
47 @@ -3752,10 +3758,22 @@ static void lastDocumentAP(Widget w, XEv
48 Cardinal *nArgs)
50 LastDocument(WidgetToWindow(w));
53 +static void switchNextDocumentAP(Widget w, XEvent *event, String *args,
54 + Cardinal *nArgs)
56 + SwitchWithNextDocument(WidgetToWindow(w));
59 +static void switchPrevDocumentAP(Widget w, XEvent *event, String *args,
60 + Cardinal *nArgs)
62 + SwitchWithPreviousDocument(WidgetToWindow(w));
65 static void capitalizeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
67 WindowInfo *window = WidgetToWindow(w);
69 if (CheckReadOnly(window))
70 diff --quilt old/source/window.c new/source/window.c
71 --- old/source/window.c
72 +++ new/source/window.c
73 @@ -4069,10 +4069,82 @@ void LastDocument(WindowInfo *window)
74 RaiseFocusDocumentWindow(win, True);
79 +** switch current tab with next tab
80 +*/
81 +void SwitchWithNextDocument(WindowInfo *window)
83 + WindowInfo *win;
84 + Widget w;
85 + WidgetList tabList;
86 + int i, nDoc;
88 + if (WindowList->next == NULL)
89 + return;
91 + win = getNextTabWindow(window, 1, 0, 1);
92 + if (win == NULL)
93 + return;
95 + w = win->tab;
96 + win->tab = window->tab;
97 + window->tab = w;
99 + RefreshTabState(win);
100 + RefreshTabState(window);
102 + RaiseDocument(window);
104 + nDoc = NDocuments(window);
105 + XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList, NULL);
106 + for (i = 0; i < nDoc; i++) {
107 + if (window->tab == tabList[i]) {
108 + XmLFolderSetActiveTab(window->tabBar, i, False);
109 + break;
115 +** switch current tab with previous tab
117 +void SwitchWithPreviousDocument(WindowInfo *window)
119 + WindowInfo *win;
120 + Widget w;
121 + WidgetList tabList;
122 + int i, nDoc;
124 + if (WindowList->next == NULL)
125 + return;
127 + win = getNextTabWindow(window, -1, 0, 1);
128 + if (win == NULL)
129 + return;
131 + w = win->tab;
132 + win->tab = window->tab;
133 + window->tab = w;
135 + RefreshTabState(win);
136 + RefreshTabState(window);
138 + RaiseDocument(window);
140 + nDoc = NDocuments(window);
141 + XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList, NULL);
142 + for (i = 0; i < nDoc; i++) {
143 + if (window->tab == tabList[i]) {
144 + XmLFolderSetActiveTab(window->tabBar, i, False);
145 + break;
151 ** make sure window is alive is kicking
153 int IsValidWindow(WindowInfo *window)
155 WindowInfo *win;
156 diff --quilt old/source/window.h new/source/window.h
157 --- old/source/window.h
158 +++ new/source/window.h
159 @@ -84,10 +84,12 @@ void RaiseFocusDocumentWindow(WindowInfo
160 WindowInfo *MarkLastDocument(WindowInfo *window);
161 WindowInfo *MarkActiveDocument(WindowInfo *window);
162 void NextDocument(WindowInfo *window);
163 void PreviousDocument(WindowInfo *window);
164 void LastDocument(WindowInfo *window);
165 +void SwitchWithNextDocument(WindowInfo *window);
166 +void SwitchWithPreviousDocument(WindowInfo *window);
167 int NDocuments(WindowInfo *window);
168 WindowInfo *MoveDocument(WindowInfo *toWindow, WindowInfo *window);
169 WindowInfo *DetachDocument(WindowInfo *window);
170 void MoveDocumentDialog(WindowInfo *window);
171 WindowInfo* GetTopDocument(Widget w);
172 diff --quilt old/doc/help.etx new/doc/help.etx
173 --- old/doc/help.etx
174 +++ new/doc/help.etx
175 @@ -803,11 +803,13 @@ Tabbed Editing
176 interface are found under Preferences -> Default Settings -> Tabbed Editing
177 (cf. "Preferences_", also "NEdit_Command_Line_").
179 Notice that you can re-group tabs at any time by detaching and attaching them,
180 or moving them, to other windows. This can be done using the Windows menu, or
181 - using the context menu, which pops up when right clicking on a tab.
182 + using the context menu, which pops up when right clicking on a tab. You can
183 + also reorder the current tab by switching it with the left or right neighbor
184 + using the actions switch_next_document() or switch_previous_document().
186 You can switch to a tab by simply clicking on it, or you can use the keyboard.
187 The default keybindings to switch tabs (which are Ctrl+PageUp/-Down and Alt+Home,
188 see "Keyboard_Shortcuts_") can be changed using the actions previous_document(),
189 next_document() and last_document().