push up:
[nedit-bw.git] / switch_tabs.patch
blobf03ec86dfed0f432ae5417dd9e10885c8bcc9849
1 NEdit*text.translations: #override \
2 Shift Ctrl<KeyPress>osfPageUp: switch_previous_document()\n\
3 Shift Ctrl<KeyPress>osfPageDown: switch_next_document()\n\
4 ...
6 ---
8 doc/help.etx | 4 ++-
9 source/menu.c | 18 ++++++++++++++
10 source/window.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 source/window.h | 2 +
12 4 files changed, 95 insertions(+), 1 deletion(-)
14 diff --quilt old/source/menu.c new/source/menu.c
15 --- old/source/menu.c
16 +++ new/source/menu.c
17 @@ -329,10 +329,14 @@ static void nextDocumentAP(Widget w, XEv
18 Cardinal *nArgs);
19 static void prevDocumentAP(Widget w, XEvent *event, String *args,
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 static void lowercaseAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
31 static void fillAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
32 @@ -544,10 +548,12 @@ static XtActionsRec Actions[] = {
33 {"detach_document_dialog", detachDocumentDialogAP},
34 {"move_document_dialog", moveDocumentDialogAP},
35 {"next_document", nextDocumentAP},
36 {"previous_document", prevDocumentAP},
37 {"last_document", lastDocumentAP},
38 + {"switch_next_document", switchNextDocumentAP},
39 + {"switch_previous_document", switchPrevDocumentAP},
40 {"uppercase", capitalizeAP},
41 {"lowercase", lowercaseAP},
42 {"fill-paragraph", fillAP},
43 {"fill_paragraph", fillAP},
44 {"control-code-dialog", controlDialogAP},
45 @@ -3761,10 +3767,22 @@ static void lastDocumentAP(Widget w, XEv
46 Cardinal *nArgs)
48 LastDocument(WidgetToWindow(w));
51 +static void switchNextDocumentAP(Widget w, XEvent *event, String *args,
52 + Cardinal *nArgs)
54 + SwitchWithNextDocument(WidgetToWindow(w));
57 +static void switchPrevDocumentAP(Widget w, XEvent *event, String *args,
58 + Cardinal *nArgs)
60 + SwitchWithPreviousDocument(WidgetToWindow(w));
63 static void capitalizeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
65 WindowInfo *window = WidgetToWindow(w);
67 if (CheckReadOnly(window))
68 diff --quilt old/source/window.c new/source/window.c
69 --- old/source/window.c
70 +++ new/source/window.c
71 @@ -4043,10 +4043,82 @@ void LastDocument(WindowInfo *window)
72 RaiseFocusDocumentWindow(win, True);
77 +** switch current tab with next tab
78 +*/
79 +void SwitchWithNextDocument(WindowInfo *window)
81 + WindowInfo *win;
82 + Widget w;
83 + WidgetList tabList;
84 + int i, nDoc;
86 + if (WindowList->next == NULL)
87 + return;
89 + win = getNextTabWindow(window, 1, 0, 1);
90 + if (win == NULL)
91 + return;
93 + w = win->tab;
94 + win->tab = window->tab;
95 + window->tab = w;
97 + RefreshTabState(win);
98 + RefreshTabState(window);
100 + RaiseDocument(window);
102 + nDoc = NDocuments(window);
103 + XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList, NULL);
104 + for (i = 0; i < nDoc; i++) {
105 + if (window->tab == tabList[i]) {
106 + XmLFolderSetActiveTab(window->tabBar, i, False);
107 + break;
113 +** switch current tab with previous tab
115 +void SwitchWithPreviousDocument(WindowInfo *window)
117 + WindowInfo *win;
118 + Widget w;
119 + WidgetList tabList;
120 + int i, nDoc;
122 + if (WindowList->next == NULL)
123 + return;
125 + win = getNextTabWindow(window, -1, 0, 1);
126 + if (win == NULL)
127 + return;
129 + w = win->tab;
130 + win->tab = window->tab;
131 + window->tab = w;
133 + RefreshTabState(win);
134 + RefreshTabState(window);
136 + RaiseDocument(window);
138 + nDoc = NDocuments(window);
139 + XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList, NULL);
140 + for (i = 0; i < nDoc; i++) {
141 + if (window->tab == tabList[i]) {
142 + XmLFolderSetActiveTab(window->tabBar, i, False);
143 + break;
149 ** make sure window is alive is kicking
151 int IsValidWindow(WindowInfo *window)
153 WindowInfo *win;
154 diff --quilt old/source/window.h new/source/window.h
155 --- old/source/window.h
156 +++ new/source/window.h
157 @@ -86,10 +86,12 @@ void RaiseFocusDocumentWindow(WindowInfo
158 WindowInfo *MarkLastDocument(WindowInfo *window);
159 WindowInfo *MarkActiveDocument(WindowInfo *window);
160 void NextDocument(WindowInfo *window);
161 void PreviousDocument(WindowInfo *window);
162 void LastDocument(WindowInfo *window);
163 +void SwitchWithNextDocument(WindowInfo *window);
164 +void SwitchWithPreviousDocument(WindowInfo *window);
165 int NDocuments(WindowInfo *window);
166 WindowInfo *MoveDocument(WindowInfo *toWindow, WindowInfo *window);
167 WindowInfo *DetachDocument(WindowInfo *window);
168 void MoveDocumentDialog(WindowInfo *window);
169 WindowInfo* GetTopDocument(Widget w);
170 diff --quilt old/doc/help.etx new/doc/help.etx
171 --- old/doc/help.etx
172 +++ new/doc/help.etx
173 @@ -806,11 +806,13 @@ Tabbed Editing
174 interface are found under Preferences -> Default Settings -> Tabbed Editing
175 (cf. "Preferences_", also "NEdit_Command_Line_").
177 Notice that you can re-group tabs at any time by detaching and attaching them,
178 or moving them, to other windows. This can be done using the Windows menu, or
179 - using the context menu, which pops up when right clicking on a tab.
180 + using the context menu, which pops up when right clicking on a tab. You can
181 + also reorder the current tab by switching it with the left or right neighbor
182 + using the actions switch_next_document() or switch_previous_document().
184 You can switch to a tab by simply clicking on it, or you can use the keyboard.
185 The default keybindings to switch tabs (which are Ctrl+PageUp/-Down and Alt+Home,
186 see "Keyboard_Shortcuts_") can be changed using the actions previous_document(),
187 next_document() and last_document().