- remove old patches
This commit is contained in:
parent
10a65c5d31
commit
2c4ddac295
@ -1,63 +0,0 @@
|
||||
Index: checkboxtree.c
|
||||
===================================================================
|
||||
RCS file: /usr/local/CVS/newt/checkboxtree.c,v
|
||||
retrieving revision 1.32
|
||||
retrieving revision 1.33
|
||||
diff -u -r1.32 -r1.33
|
||||
--- checkboxtree.c 30 Jan 2007 14:03:18 -0000 1.32
|
||||
+++ checkboxtree.c 12 Apr 2007 16:57:33 -0000 1.33
|
||||
@@ -38,8 +38,7 @@
|
||||
static struct items * findItem(struct items * items, const void * data);
|
||||
static void buildFlatList(newtComponent co);
|
||||
static void doBuildFlatList(struct CheckboxTree * ct, struct items * item);
|
||||
-enum countWhat { COUNT_EXPOSED=0, COUNT_SELECTED=1 };
|
||||
-static int countItems(struct items * item, enum countWhat justExposed);
|
||||
+static int countItems(struct items * item, int what);
|
||||
static inline void updateWidth(newtComponent co, struct CheckboxTree * ct,
|
||||
int maxField);
|
||||
|
||||
@@ -60,13 +59,14 @@
|
||||
ct->sb->left = co->left + co->width - 1;
|
||||
}
|
||||
|
||||
-static int countItems(struct items * item, enum countWhat what) {
|
||||
+static int countItems(struct items * item, int what) {
|
||||
int count = 0;
|
||||
|
||||
while (item) {
|
||||
- if ((!item->branch && item->selected == what) || (what == COUNT_EXPOSED))
|
||||
+ if (what < 0 || !item->branch && (what > 0 && item->selected == what
|
||||
+ || what == 0 && item->selected))
|
||||
count++;
|
||||
- if (item->branch || (what == COUNT_EXPOSED && item->selected))
|
||||
+ if (item->branch && (what >= 0 || what < 0 && item->selected))
|
||||
count += countItems(item->branch, what);
|
||||
item = item->next;
|
||||
}
|
||||
@@ -88,7 +88,7 @@
|
||||
struct CheckboxTree * ct = co->data;
|
||||
|
||||
if (ct->flatList) free(ct->flatList);
|
||||
- ct->flatCount = countItems(ct->itemlist, COUNT_EXPOSED);
|
||||
+ ct->flatCount = countItems(ct->itemlist, -1);
|
||||
|
||||
ct->flatList = malloc(sizeof(*ct->flatList) * (ct->flatCount+1));
|
||||
ct->flatCount = 0;
|
||||
@@ -273,7 +273,7 @@
|
||||
|
||||
static void listSelected(struct items * items, int * num, const void ** list, int seqindex) {
|
||||
while (items) {
|
||||
- if ((seqindex ? items->selected==seqindex : items->selected) && !items->branch)
|
||||
+ if ((seqindex ? items->selected==seqindex : items->selected) && !items->branch)
|
||||
list[(*num)++] = (void *) items->data;
|
||||
if (items->branch)
|
||||
listSelected(items->branch, num, list, seqindex);
|
||||
@@ -312,7 +312,7 @@
|
||||
seqindex = 0;
|
||||
}
|
||||
|
||||
- *numitems = countItems(ct->itemlist, (seqindex ? seqindex : COUNT_SELECTED));
|
||||
+ *numitems = countItems(ct->itemlist, seqindex);
|
||||
if (!*numitems) return NULL;
|
||||
|
||||
retval = malloc(*numitems * sizeof(void *));
|
||||
@ -1,24 +0,0 @@
|
||||
Index: newt.c
|
||||
===================================================================
|
||||
RCS file: /usr/local/CVS/newt/newt.c,v
|
||||
retrieving revision 1.75
|
||||
retrieving revision 1.76
|
||||
diff -u -r1.75 -r1.76
|
||||
--- newt.c 28 Feb 2007 17:35:01 -0000 1.75
|
||||
+++ newt.c 11 Apr 2007 14:31:40 -0000 1.76
|
||||
@@ -778,8 +778,13 @@
|
||||
}
|
||||
|
||||
void newtGetrc(int * row, int * col) {
|
||||
- *row = cursorRow;
|
||||
- *col = cursorCol;
|
||||
+ *row = cursorRow;
|
||||
+ *col = cursorCol;
|
||||
+
|
||||
+ if (currentWindow) {
|
||||
+ *row -= currentWindow->top;
|
||||
+ *col -= currentWindow->left;
|
||||
+ }
|
||||
}
|
||||
|
||||
void newtGotorc(int newRow, int newCol) {
|
||||
@ -1,197 +0,0 @@
|
||||
Index: entry.c
|
||||
===================================================================
|
||||
RCS file: /usr/local/CVS/newt/entry.c,v
|
||||
retrieving revision 1.40
|
||||
retrieving revision 1.41
|
||||
diff -u -r1.40 -r1.41
|
||||
--- entry.c 11 Oct 2006 15:19:39 -0000 1.40
|
||||
+++ entry.c 4 Apr 2007 15:17:51 -0000 1.41
|
||||
@@ -25,6 +25,8 @@
|
||||
void * filterData;
|
||||
};
|
||||
|
||||
+static int previous_char(const char *buf, int pos);
|
||||
+static int next_char(const char *buf, int pos);
|
||||
static void entryDraw(newtComponent co);
|
||||
static void entryDestroy(newtComponent co);
|
||||
static struct eventResult entryEvent(newtComponent co,
|
||||
@@ -103,6 +105,11 @@
|
||||
strcpy(en->buf, initialValue);
|
||||
en->bufUsed = strlen(initialValue);
|
||||
en->cursorPosition = en->bufUsed;
|
||||
+
|
||||
+ /* move cursor back if entry is full */
|
||||
+ if (en->cursorPosition && !(en->flags & NEWT_FLAG_SCROLL ||
|
||||
+ wstrlen(en->buf, -1) < co->width))
|
||||
+ en->cursorPosition = previous_char(en->buf, en->cursorPosition);
|
||||
} else {
|
||||
*en->buf = '\0';
|
||||
en->bufUsed = 0;
|
||||
@@ -112,39 +119,57 @@
|
||||
return co;
|
||||
}
|
||||
|
||||
-static int visible_width(const char *str, int start, int end)
|
||||
-{
|
||||
- int width = wstrlen(str + start, end-start);
|
||||
- int len, w = 0;
|
||||
- wchar_t wc;
|
||||
-
|
||||
- len = mbtowc(&wc, str+end, MB_CUR_MAX);
|
||||
- if (len == 0)
|
||||
- w = 1;
|
||||
- else if (len > 0)
|
||||
- w = wcwidth(wc);
|
||||
- return width + w;
|
||||
-}
|
||||
-
|
||||
static void scroll(struct entry *en, int width)
|
||||
{
|
||||
- wchar_t wc;
|
||||
- int len, w;
|
||||
- int newwidth = visible_width(en->buf, en->firstChar, en->cursorPosition);
|
||||
-
|
||||
- while (newwidth > width) {
|
||||
- len = mbtowc(&wc, en->buf+en->firstChar, MB_CUR_MAX);
|
||||
- if (!len) {
|
||||
- en->firstChar++;
|
||||
- break;
|
||||
- }
|
||||
- if (len < 0)
|
||||
- break;
|
||||
- w = wcwidth(wc);
|
||||
- if (w < 0)
|
||||
- break;
|
||||
- en->firstChar += len;
|
||||
- newwidth -= w;
|
||||
+ int r, lv, rv, cntx, cw, cn, nc, pc, ncw, pcw;
|
||||
+
|
||||
+ if (width <= 1) {
|
||||
+ en->firstChar = en->cursorPosition;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ cntx = width / 4;
|
||||
+ if (cntx > 5)
|
||||
+ cntx = 5;
|
||||
+
|
||||
+ if (en->cursorPosition < en->firstChar)
|
||||
+ en->firstChar = en->cursorPosition;
|
||||
+
|
||||
+ cn = next_char(en->buf, en->cursorPosition);
|
||||
+ cw = en->cursorPosition >= en->bufUsed ? 1 :
|
||||
+ wstrlen(en->buf + en->cursorPosition, cn - en->cursorPosition);
|
||||
+
|
||||
+ r = wstrlen(en->buf + cn, -1);
|
||||
+
|
||||
+ lv = wstrlen(en->buf + en->firstChar, en->cursorPosition - en->firstChar);
|
||||
+ rv = width - lv - cw;
|
||||
+
|
||||
+#define RC (ncw > 0 && (r > rv && lv - ncw >= cntx && rv < cntx))
|
||||
+#define LC (pcw > 0 && (r + pcw <= rv || (lv < cntx && rv - pcw >= cntx)))
|
||||
+
|
||||
+ nc = next_char(en->buf, en->firstChar);
|
||||
+ ncw = wstrlen(en->buf + en->firstChar, nc - en->firstChar);
|
||||
+ if (RC) {
|
||||
+ do {
|
||||
+ lv -= ncw;
|
||||
+ rv += ncw;
|
||||
+ en->firstChar = nc;
|
||||
+ nc = next_char(en->buf, en->firstChar);
|
||||
+ ncw = wstrlen(en->buf + en->firstChar, nc - en->firstChar);
|
||||
+ } while (RC);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ pc = previous_char(en->buf, en->firstChar);
|
||||
+ pcw = wstrlen(en->buf + pc, en->firstChar - pc);
|
||||
+ if (LC) {
|
||||
+ do {
|
||||
+ lv += pcw;
|
||||
+ rv -= pcw;
|
||||
+ en->firstChar = pc;
|
||||
+ pc = previous_char(en->buf, en->firstChar);
|
||||
+ pcw = wstrlen(en->buf + pc, en->firstChar - pc);
|
||||
+ } while (LC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,13 +196,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- if (en->cursorPosition < en->firstChar) {
|
||||
- /* scroll to the left */
|
||||
- en->firstChar = en->cursorPosition;
|
||||
- } else {
|
||||
- /* scroll to the right */
|
||||
- scroll(en, co->width);
|
||||
- }
|
||||
+ /* scroll if necessary */
|
||||
+ scroll(en, co->width);
|
||||
|
||||
chptr = en->buf + en->firstChar;
|
||||
|
||||
@@ -317,17 +337,15 @@
|
||||
static int next_char(const char *buf, int pos)
|
||||
{
|
||||
int len = mblen(buf + pos, MB_CUR_MAX);
|
||||
- if (len < 0)
|
||||
+ if (len <= 0)
|
||||
return pos;
|
||||
- if (len == 0)
|
||||
- return ++pos;
|
||||
return pos+len;
|
||||
}
|
||||
|
||||
static struct eventResult entryHandleKey(newtComponent co, int key) {
|
||||
struct entry * en = co->data;
|
||||
struct eventResult er;
|
||||
- char * chptr, * insPoint;
|
||||
+ char * chptr;
|
||||
|
||||
er.result = ER_SWALLOWED;
|
||||
switch (key) {
|
||||
@@ -430,7 +448,7 @@
|
||||
s[i] = SLang_getkey();
|
||||
}
|
||||
|
||||
- if (!i || !(en->flags & NEWT_FLAG_SCROLL) && wstrlen(en->buf, -1) >= co->width) {
|
||||
+ if (!i || (!(en->flags & NEWT_FLAG_SCROLL) && wstrlen(en->buf, -1) + wstrlen(s, i) > co->width)) {
|
||||
/* FIXME this is broken */
|
||||
SLtt_beep();
|
||||
break;
|
||||
@@ -440,20 +458,12 @@
|
||||
en->bufAlloced += 20;
|
||||
en->buf = realloc(en->buf, en->bufAlloced);
|
||||
if (en->resultPtr) *en->resultPtr = en->buf;
|
||||
- memset(en->buf + en->bufUsed + 1, 0, 20);
|
||||
+ memset(en->buf + en->bufAlloced - 20, 0, 20);
|
||||
}
|
||||
|
||||
if (en->cursorPosition != en->bufUsed) {
|
||||
/* insert the new character */
|
||||
-
|
||||
- /* chptr is the last character in the string */
|
||||
- chptr = (en->buf + en->bufUsed) - 2 + i;
|
||||
- insPoint = en->buf + en->cursorPosition;
|
||||
-
|
||||
- while (chptr >= insPoint) {
|
||||
- *(chptr + i) = *chptr;
|
||||
- chptr--;
|
||||
- }
|
||||
+ memmove(en->buf + en->cursorPosition + i, en->buf + en->cursorPosition, en->bufUsed - en->cursorPosition);
|
||||
}
|
||||
en->bufUsed += i;
|
||||
for (l = 0; l < i; l++)
|
||||
@@ -462,6 +472,10 @@
|
||||
er.result = ER_IGNORED;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ if (en->cursorPosition == en->bufUsed && en->cursorPosition &&
|
||||
+ !(en->flags & NEWT_FLAG_SCROLL || wstrlen(en->buf, -1) < co->width))
|
||||
+ en->cursorPosition = previous_char(en->buf, en->cursorPosition);
|
||||
|
||||
entryDraw(co);
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
Index: checkboxtree.c
|
||||
===================================================================
|
||||
RCS file: /usr/local/CVS/newt/checkboxtree.c,v
|
||||
retrieving revision 1.33
|
||||
retrieving revision 1.34
|
||||
diff -u -r1.33 -r1.34
|
||||
--- checkboxtree.c 12 Apr 2007 16:57:33 -0000 1.33
|
||||
+++ checkboxtree.c 12 Apr 2007 17:03:57 -0000 1.34
|
||||
@@ -531,19 +531,26 @@
|
||||
(*ct->currItem ? (*ct->currItem)->depth : 0) * 3 + 4);
|
||||
}
|
||||
|
||||
-static void ctDestroy(newtComponent co) {
|
||||
- struct CheckboxTree * ct = co->data;
|
||||
- struct items * item, * nextitem;
|
||||
-
|
||||
- nextitem = item = ct->itemlist;
|
||||
+static void destroyItems(struct items * item) {
|
||||
+ struct items * nextitem;
|
||||
|
||||
while (item != NULL) {
|
||||
nextitem = item->next;
|
||||
free(item->text);
|
||||
+ if (item->branch)
|
||||
+ destroyItems(item->branch);
|
||||
free(item);
|
||||
item = nextitem;
|
||||
}
|
||||
+}
|
||||
+
|
||||
+static void ctDestroy(newtComponent co) {
|
||||
+ struct CheckboxTree * ct = co->data;
|
||||
|
||||
+ destroyItems(ct->itemlist);
|
||||
+ free(ct->flatList);
|
||||
+ if (ct->sb)
|
||||
+ ct->sb->ops->destroy(ct->sb);
|
||||
free(ct->seq);
|
||||
free(ct);
|
||||
free(co);
|
||||
@@ -802,6 +809,7 @@
|
||||
treeTop = item->branch;
|
||||
}
|
||||
|
||||
+ free(path);
|
||||
buildFlatList(co);
|
||||
|
||||
item = findItem(ct->itemlist, data);
|
||||
Index: textbox.c
|
||||
===================================================================
|
||||
RCS file: /usr/local/CVS/newt/textbox.c,v
|
||||
retrieving revision 1.38
|
||||
retrieving revision 1.39
|
||||
diff -u -r1.38 -r1.39
|
||||
--- textbox.c 12 Oct 2006 14:18:38 -0000 1.38
|
||||
+++ textbox.c 12 Apr 2007 17:03:57 -0000 1.39
|
||||
@@ -451,6 +451,10 @@
|
||||
int i;
|
||||
struct textbox * tb = co->data;
|
||||
|
||||
+ if (tb->sb)
|
||||
+ tb->sb->ops->destroy(tb->sb);
|
||||
+ if (tb->sb_act)
|
||||
+ tb->sb_act->ops->destroy(tb->sb_act);
|
||||
for (i = 0; i < tb->numLines; i++)
|
||||
free(tb->lines[i]);
|
||||
free(tb->lines);
|
||||
Loading…
Reference in New Issue
Block a user