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\
11 source/menu.c | 18 ++++++++++++++
12 source/window.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14 4 files changed, 95 insertions(+), 1 deletion(-)
16 diff --quilt old/source/menu.c new/source/menu.c
19 @@ -328,10 +328,14 @@ static void nextDocumentAP(Widget w, XEv
21 static void prevDocumentAP(Widget w, XEvent *event, String *args,
23 static void lastDocumentAP(Widget w, XEvent *event, String *args,
25 +static void switchNextDocumentAP(Widget w, XEvent *event, String *args,
27 +static void switchPrevDocumentAP(Widget w, XEvent *event, String *args,
29 static void closePaneAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
30 static void capitalizeAP(Widget w, XEvent *event, String *args,
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
50 LastDocument(WidgetToWindow(w));
53 +static void switchNextDocumentAP(Widget w, XEvent *event, String *args,
56 + SwitchWithNextDocument(WidgetToWindow(w));
59 +static void switchPrevDocumentAP(Widget w, XEvent *event, String *args,
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
81 +void SwitchWithNextDocument(WindowInfo *window)
88 + if (WindowList->next == NULL)
91 + win = getNextTabWindow(window, 1, 0, 1);
96 + win->tab = window->tab;
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);
115 +** switch current tab with previous tab
117 +void SwitchWithPreviousDocument(WindowInfo *window)
121 + WidgetList tabList;
124 + if (WindowList->next == NULL)
127 + win = getNextTabWindow(window, -1, 0, 1);
132 + win->tab = window->tab;
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);
151 ** make sure window is alive is kicking
153 int IsValidWindow(WindowInfo *window)
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
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().