This commit is contained in:
committed by
Git OBS Bridge
parent
7668526534
commit
afd2c108bb
63
newt-0.52.6-countitems.patch
Normal file
63
newt-0.52.6-countitems.patch
Normal file
@@ -0,0 +1,63 @@
|
||||
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 *));
|
||||
24
newt-0.52.6-cursor.patch
Normal file
24
newt-0.52.6-cursor.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
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) {
|
||||
197
newt-0.52.6-entry.patch
Normal file
197
newt-0.52.6-entry.patch
Normal file
@@ -0,0 +1,197 @@
|
||||
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);
|
||||
|
||||
67
newt-0.52.6-memleaks.patch
Normal file
67
newt-0.52.6-memleaks.patch
Normal file
@@ -0,0 +1,67 @@
|
||||
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);
|
||||
17
newt.changes
17
newt.changes
@@ -1,3 +1,20 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 13 17:30:43 CEST 2007 - lrupp@suse.de
|
||||
|
||||
- included patches from Miroslav Lichvar:
|
||||
+ fix cursor positioning when setting entry or checkbox flags
|
||||
(newt-0.52.6-cursor.patch)
|
||||
+ fix counting of items in checkboxtree
|
||||
(newt-0.52.6-countitems.patch)
|
||||
+ fix some memory leaks
|
||||
(newt-0.52.6-memleaks.patch)
|
||||
+ fix entry scrolling (RH#234829) and
|
||||
+ fix multibyte character handling in entry
|
||||
(newt-0.52.6-entry.patch)
|
||||
- disable gpm-support - seems to smash the stack
|
||||
- remove libbz2-1 from buildreq
|
||||
- re-arange buildrequires
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 5 20:02:15 CEST 2007 - ro@suse.de
|
||||
|
||||
|
||||
45
newt.spec
45
newt.spec
@@ -11,17 +11,21 @@
|
||||
# norootforbuild
|
||||
|
||||
Name: newt
|
||||
BuildRequires: popt-devel python-devel slang-devel
|
||||
URL: ftp://download.fedora.redhat.com/pub/fedora/linux/core/development/source/SRPMS/newt-0.52.4-2.fc7.src.rpm
|
||||
URL: ftp://download.fedora.redhat.com/pub/fedora/linux/core/development/source/SRPMS/newt-0.52.6-3.fc7.src.rpm
|
||||
Summary: Nifty Erik's Windowing Toolkit
|
||||
Version: 0.52.6
|
||||
Release: 24
|
||||
Release: 30
|
||||
License: GNU Library General Public License v. 2.0 and 2.1 (LGPL)
|
||||
Group: System/Libraries
|
||||
Source: %{name}-%{version}.tar.bz2
|
||||
Patch1: newt-0.52.6-entry.patch
|
||||
Patch2: newt-0.52.6-cursor.patch
|
||||
Patch3: newt-0.52.6-countitems.patch
|
||||
Patch4: newt-0.52.6-memleaks.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: python-devel slang-devel
|
||||
%{py_requires}
|
||||
Provides: snack = %{version}-%{release}
|
||||
Requires: slang
|
||||
####################
|
||||
# Distribution parts
|
||||
####################
|
||||
@@ -29,23 +33,20 @@ Requires: slang
|
||||
# SUSE
|
||||
#
|
||||
%if 0%{?suse_version}
|
||||
%{py_requires}
|
||||
%if 0%{?suse_version} > 1020
|
||||
BuildRequires: libbz2-1
|
||||
%endif
|
||||
BuildRequires: popt-devel
|
||||
%endif
|
||||
#
|
||||
# Mandriva
|
||||
#
|
||||
%if 0%{?mandriva_version}
|
||||
%{py_requires}
|
||||
BuildRequires: popt-devel
|
||||
%endif
|
||||
#
|
||||
%package devel
|
||||
Summary: Development files for the Newt windowing toolkit
|
||||
Provides: newtd = %{version}
|
||||
Requires: newt = %{version}
|
||||
Requires: slang
|
||||
Requires: slang-devel %{name} = %{version}
|
||||
Group: Development/Libraries/C and C++
|
||||
Obsoletes: newtd <= %{version}
|
||||
#
|
||||
@@ -103,19 +104,25 @@ Authors:
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch1 -p0 -b .entry
|
||||
%patch2 -p0 -b .cursor
|
||||
%patch3 -p0 -b .countitems
|
||||
%patch4 -p0 -b .memleaks
|
||||
|
||||
%build
|
||||
%{?suse_update_config:%{suse_update_config -f}}
|
||||
export CFLAGS="$RPM_OPT_FLAGS -fPIC -Wall -fno-strict-aliasing"
|
||||
%configure --with-gpm-support --without-tcl
|
||||
%configure --without-tcl
|
||||
# gpm support seems to smash the stack
|
||||
# --with-gpm-support
|
||||
make depend
|
||||
make PYTHONVERS=python%{py_ver}
|
||||
make shared PYTHONVERS=python%{py_ver}
|
||||
chmod 0644 peanuts.py popcorn.py
|
||||
|
||||
%install
|
||||
make instroot=%buildroot install PYTHONVERS=python%{py_ver}
|
||||
make instroot=%buildroot install-sh PYTHONVERS=python%{py_ver}
|
||||
chmod 0644 peanuts.py popcorn.py
|
||||
# currently we don't support these languages
|
||||
for lang in dz mg tl wo; do
|
||||
rm -rf %buildroot%_datadir/locale/$lang
|
||||
@@ -148,6 +155,20 @@ rm -rf %buildroot
|
||||
%{_libdir}/libnewt.a
|
||||
|
||||
%changelog
|
||||
* Wed Jun 13 2007 - lrupp@suse.de
|
||||
- included patches from Miroslav Lichvar:
|
||||
+ fix cursor positioning when setting entry or checkbox flags
|
||||
(newt-0.52.6-cursor.patch)
|
||||
+ fix counting of items in checkboxtree
|
||||
(newt-0.52.6-countitems.patch)
|
||||
+ fix some memory leaks
|
||||
(newt-0.52.6-memleaks.patch)
|
||||
+ fix entry scrolling (RH#234829) and
|
||||
+ fix multibyte character handling in entry
|
||||
(newt-0.52.6-entry.patch)
|
||||
- disable gpm-support - seems to smash the stack
|
||||
- remove libbz2-1 from buildreq
|
||||
- re-arange buildrequires
|
||||
* Tue Jun 05 2007 - ro@suse.de
|
||||
- buildreq: libbz2 -> libbz2-1
|
||||
* Sun Apr 01 2007 - lrupp@suse.de
|
||||
|
||||
Reference in New Issue
Block a user