ttyname: use precomputed lengths
[nedit-bw.git] / newTabTab.patch
bloba1707980b07b08b3832a788963ecca10ac7dfad2
1 ---
3 Microline/XmL/Folder.c | 13 ++++++-
4 Microline/XmL/Makefile.common | 2 -
5 Microline/XmL/Makefile.dependencies | 4 ++
6 source/window.c | 61 ++++++++++++++++++++++++++----------
7 4 files changed, 61 insertions(+), 19 deletions(-)
9 diff --quilt old/Microline/XmL/Folder.c new/Microline/XmL/Folder.c
10 --- old/Microline/XmL/Folder.c
11 +++ new/Microline/XmL/Folder.c
12 @@ -932,7 +932,7 @@ LayoutTopBottom(XmLFolderWidget f,
13 tabFit = 0;
18 for (i = 0; i < f->folder.tabCount; i++)
20 tab = f->folder.tabs[i];
21 @@ -953,6 +953,15 @@ LayoutTopBottom(XmLFolderWidget f,
22 XtVaSetValues(tab, XmNwidth, tgtTabWidth, NULL);
25 + else
26 + {
27 + int thisTabWidth;
28 + XtVaGetValues(tab, XmNwidth, &thisTabWidth, NULL);
29 + if (thisTabWidth < f->folder.minTabWidth)
30 + XtVaSetValues(tab, XmNwidth, f->folder.minTabWidth, NULL);
31 + if (thisTabWidth > f->folder.maxTabWidth)
32 + XtVaSetValues(tab, XmNwidth, f->folder.maxTabWidth, NULL);
33 + }
35 fc = (XmLFolderConstraintRec *)(tab->core.constraints);
37 @@ -1658,7 +1667,7 @@ ConstraintInitialize(Widget req,
38 /* add child to tabs list */
39 if (f->folder.tabAllocCount < f->folder.tabCount + 1)
41 - f->folder.tabAllocCount *= 2;
42 + f->folder.tabAllocCount += 32;
43 f->folder.tabs = (Widget *)realloc((char *)f->folder.tabs,
44 sizeof(Widget) * f->folder.tabAllocCount);
46 diff --quilt old/source/window.c new/source/window.c
47 --- old/source/window.c
48 +++ new/source/window.c
49 @@ -155,7 +155,7 @@ static Pixmap createBitmapWithDepth(Widg
50 unsigned int height);
51 static WindowInfo *getNextTabWindow(WindowInfo *window, int direction,
52 int crossWin, int wrap);
53 -static Widget addTab(Widget folder, const char *string);
54 +static Widget addTab(Widget folder, const char *string, int isNewTabTab);
55 static int compareWindowNames(const void *windowA, const void *windowB);
56 static Widget manageToolBars(Widget toolBarsForm);
57 static void hideTearOffs(Widget menuPane);
58 @@ -602,7 +602,7 @@ WindowInfo *CreateWindow(const char *nam
59 /* create the tab bar */
60 window->tabBar = XtVaCreateManagedWidget("tabBar",
61 xmlFolderWidgetClass, tabForm,
62 - XmNresizePolicy, XmRESIZE_PACK,
63 + XmNresizePolicy, XmRESIZE_DYNAMIC,
64 XmNleftAttachment, XmATTACH_FORM,
65 XmNleftOffset, 0,
66 XmNrightAttachment, XmATTACH_WIDGET,
67 @@ -611,6 +611,7 @@ WindowInfo *CreateWindow(const char *nam
68 XmNbottomAttachment, XmATTACH_FORM,
69 XmNbottomOffset, 0,
70 XmNtopAttachment, XmATTACH_FORM,
71 + XmNmaxTabWidth, 96,
72 NULL);
74 window->tabMenuPane = CreateTabContextMenu(window->tabBar, window);
75 @@ -630,7 +631,8 @@ WindowInfo *CreateWindow(const char *nam
76 XtAddCallback(window->tabBar, XmNactivateCallback,
77 raiseTabCB, NULL);
79 - window->tab = addTab(window->tabBar, name);
80 + addTab(window->tabBar, " + ", True);
81 + window->tab = addTab(window->tabBar, name, False);
83 /* A form to hold the stats line text and line/col widgets */
84 window->statsLineForm = XtVaCreateWidget("statsLineForm",
85 @@ -839,19 +841,23 @@ static void tabClickEH(Widget w, XtPoint
87 ** add a tab to the tab bar for the new document.
89 -static Widget addTab(Widget folder, const char *string)
90 +static Widget addTab(Widget folder, const char *string, int isNewTabTab)
92 Widget tooltipLabel, tab;
93 - XmString s1;
94 + XmString s1, s2;
96 s1 = XmStringCreateSimple((char *)string);
97 + if (isNewTabTab)
98 + s2 = XmStringCreateSimple("New Document");
99 + else
100 + s2 = s1;
101 tab = XtVaCreateManagedWidget("tab",
102 xrwsBubbleButtonWidgetClass, folder,
103 /* XmNmarginWidth, <default@nedit.c>, */
104 /* XmNmarginHeight, <default@nedit.c>, */
105 /* XmNalignment, <default@nedit.c>, */
106 XmNlabelString, s1,
107 - XltNbubbleString, s1,
108 + XltNbubbleString, s2,
109 XltNshowBubble, GetPrefToolTips(),
110 XltNautoParkBubble, True,
111 XltNslidingBubble, False,
112 @@ -859,6 +865,8 @@ static Widget addTab(Widget folder, cons
113 /* XltNbubbleDuration, 8000,*/
114 NULL);
115 XmStringFree(s1);
116 + if (isNewTabTab)
117 + XmStringFree(s2);
119 /* there's things to do as user click on the tab */
120 XtAddEventHandler(tab, ButtonPressMask, False,
121 @@ -882,10 +890,23 @@ static Widget addTab(Widget folder, cons
122 AddTabContextMenuAction(tab);
123 #endif /* LESSTIF_VERSION */
125 - if (GetPerfDragDropTabs()) {
126 + if (GetPerfDragDropTabs() && !isNewTabTab) {
127 addTabDragAction(tab);
128 registerDropSite(tab);
131 + /* maintain newTab-tab as last tab in tablist */
132 + if (!isNewTabTab) {
133 + WidgetList tabList;
134 + int tabCount;
135 + Widget t;
136 + XtVaGetValues(folder, XmNtabWidgetList, &tabList,
137 + XmNtabCount, &tabCount, NULL);
138 + t = tabList[tabCount - 1];
139 + tabList[tabCount - 1] = tabList[tabCount - 2];
140 + tabList[tabCount - 2] = t;
143 return tab;
146 @@ -937,7 +958,7 @@ void SortTabBar(WindowInfo *window)
147 XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList,
148 XmNtabCount, &tabCount, NULL);
150 - for (i=0, j=0; i<tabCount && j<nDoc; i++) {
151 + for (i=0, j=0; i<(tabCount-1) && j<nDoc; i++) {
152 if (tabList[i]->core.being_destroyed)
153 continue;
155 @@ -2649,7 +2670,7 @@ static void saveYourselfCB(Widget w, Wid
156 XtVaGetValues(topWin->tabBar, XmNtabWidgetList, &tabs,
157 XmNtabCount, &tabCount, NULL);
159 - for (i=0; i< tabCount; i++) {
160 + for (i=0; i< (tabCount-1); i++) {
161 win = TabToWindow(tabs[i]);
162 if (win->filenameSet) {
163 /* add filename */
164 @@ -3651,7 +3672,7 @@ WindowInfo* CreateDocument(WindowInfo* s
165 /* Set the requested hardware tab distance and useTabs in the text buffer */
166 BufSetTabDistance(window->buffer, GetPrefTabDist(PLAIN_LANGUAGE_MODE));
167 window->buffer->useTabs = GetPrefInsertTabs();
168 - window->tab = addTab(window->tabBar, name);
169 + window->tab = addTab(window->tabBar, name, False);
171 /* add the window to the global window list, update the Windows menus */
172 InvalidateWindowMenus();
173 @@ -3724,7 +3745,7 @@ static WindowInfo *getNextTabWindow(Wind
174 XtVaGetValues(win->tabBar, XmNtabWidgetList, &tabList,
175 XmNtabCount, &tabCount, NULL);
177 - for (i=0; i< tabCount; i++) {
178 + for (i=0; i< (tabCount-1); i++) {
179 tabs[tabTotalCount++] = tabList[i];
182 @@ -3734,7 +3755,7 @@ static WindowInfo *getNextTabWindow(Wind
183 XtVaGetValues(window->tabBar, XmNtabWidgetList, &tabList,
184 XmNtabCount, &tabCount, NULL);
186 - for (i=0; i< tabCount; i++) {
187 + for (i=0; i< (tabCount-1); i++) {
188 if (TabToWindow(tabList[i])) /* make sure tab is valid */
189 tabs[tabTotalCount++] = tabList[i];
191 @@ -3782,7 +3803,7 @@ int getTabPosition(Widget tab)
192 XtVaGetValues(tabBar, XmNtabWidgetList, &tabList,
193 XmNtabCount, &tabCount, NULL);
195 - for (i=0; i< tabCount; i++) {
196 + for (i=0; i< (tabCount-1); i++) {
197 if (tab == tabList[i])
198 return i;
200 @@ -5000,10 +5021,18 @@ static void raiseTabCB(Widget w, XtPoint
201 XmLFolderCallbackStruct *cbs = (XmLFolderCallbackStruct *)callData;
202 WidgetList tabList;
203 Widget tab;
204 + int tabCount;
206 - XtVaGetValues(w, XmNtabWidgetList, &tabList, NULL);
207 - tab = tabList[cbs->pos];
208 - RaiseDocument(TabToWindow(tab));
209 + XtVaGetValues(w, XmNtabWidgetList, &tabList, XmNtabCount, &tabCount, NULL);
210 + if (cbs->pos < (tabCount-1)) {
211 + tab = tabList[cbs->pos];
212 + RaiseDocument(TabToWindow(tab));
213 + } else {
214 + WindowInfo *window = GetTopDocument(w);
215 + EditNewFile(window, NULL, False, NULL, window->path, False);
216 + CheckCloseDim();
217 + cbs->allowActivate = 0;
221 static Widget containingPane(Widget w)
222 diff --quilt old/Microline/XmL/Makefile.common new/Microline/XmL/Makefile.common
223 --- old/Microline/XmL/Makefile.common
224 +++ new/Microline/XmL/Makefile.common
225 @@ -7,7 +7,7 @@
226 .c.o:
227 $(CC) -c -I.. $(CFLAGS) -o $@ $<
229 -OBJS = Folder.o XmL.o
230 +OBJS = XmL.o Folder.o Grid.o GridUtil.o Progress.o Tree.o
232 all: libXmL.a
234 diff --quilt old/Microline/XmL/Makefile.dependencies new/Microline/XmL/Makefile.dependencies
235 --- old/Microline/XmL/Makefile.dependencies
236 +++ new/Microline/XmL/Makefile.dependencies
237 @@ -1,2 +1,6 @@
238 XmL.o: XmL.c XmL.h
239 Folder.o: Folder.c Folder.h FolderP.h XmL.h
240 +Grid.o: Grid.c Grid.h GridP.h XmL.h
241 +GridUtil.o: GridUtil.c Grid.h GridP.h XmL.h
242 +Progress.o: Progress.c Progress.h ProgressP.h XmL.h
243 +Tree.o: Tree.c Tree.h TreeP.h XmL.h