From fcab535c38024ec35ff5cf7fb8fb6b61dd0865db Mon Sep 17 00:00:00 2001 From: kojima Date: Wed, 5 Jul 2000 04:16:53 +0000 Subject: [PATCH] fixed lots of compile bugs in wtext.c and made a few api changes to it --- WINGs/Makefile.am | 2 +- WINGs/WINGs.h | 28 +++++++++++----------------- WINGs/testtext.c | 4 ++-- WINGs/wruler.c | 4 ++++ WINGs/wtext.c | 17 +++++++++-------- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/WINGs/Makefile.am b/WINGs/Makefile.am index 98ba1716..d2f476e1 100644 --- a/WINGs/Makefile.am +++ b/WINGs/Makefile.am @@ -13,7 +13,7 @@ include_HEADERS = WINGs.h WUtil.h WINGsP.h bin_SCRIPTS = get-wings-flags get-wutil-flags noinst_PROGRAMS = wtest wmquery wmfile fontl testmywidget testcolorpanel\ - connect puzzle # testtext + connect puzzle testtext lib_LIBRARIES = libWINGs.a libWUtil.a diff --git a/WINGs/WINGs.h b/WINGs/WINGs.h index a4bc7b0d..b93b30fa 100644 --- a/WINGs/WINGs.h +++ b/WINGs/WINGs.h @@ -193,22 +193,16 @@ enum { }; -enum { +typedef enum { WRulerLeft=0, WRulerBody, WRulerFirst, WRulerRight, WRulerBoth, WRulerDocLeft -} WRulerMargins; +} WMRulerMarginType; -/* Insert type for WMText */ -typedef enum { - itAppend=0, - itPrepend -} InsertType; - /* drag operations */ typedef enum { @@ -536,13 +530,13 @@ typedef void WMParseAction(WMWidget *self, void *clientData, short type); /* these are the things parsers (for text) do */ typedef struct _parserActions { - void *(*createParagraph) (short fmargin, short bmargin, short rmargin, - short *tabstops, short numTabs, WMAlignment a); - void (*insertParagraph) (WMText *tPtr, void *para, InsertType type); + void *(*createParagraph) (short fmargin, short bmargin, + short rmargin, short *tabstops, short numTabs, WMAlignment a); + void (*insertParagraph) (WMText *tPtr, void *para, Bool prepend); void *(*createPChunk) (WMPixmap *pixmap, short script, ushort ul); - void *(*createTChunk) (char *text, short chars, WMFont *font, - WMColor *color, short script, ushort ul); - void (*insertChunk) (WMText *tPtr, void *chunk, InsertType type); + void *(*createTChunk) (char *text, short chars, WMFont *font, + WMColor *color, short script, ushort ul); + void (*insertChunk) (WMText *tPtr, void *chunk, Bool prepend); } WMParserActions; @@ -1440,9 +1434,9 @@ int WMGetTextCurrentChunk(WMText *tPtr); void WMRemoveTextChunk(WMText *tPtr, int which); void WMSetTextCurrentChunk(WMText *tPtr, int current); -void W_InsertText(WMText *tPtr, void *data, int position);/* position = -1||0*/ -#define WMAppendTextStream(t, d) W_InsertText(t, d, -1) -#define WMPrependTextStream(t, d) W_InsertText(t, d, 0) +void W_InsertText(WMText *tPtr, void *data, Bool prepend); +#define WMAppendTextStream(t, d) W_InsertText(t, d, False) +#define WMPrependTextStream(t, d) W_InsertText(t, d, True) void WMSetTextParser(WMText *tPtr, WMParseAction *parser); diff --git a/WINGs/testtext.c b/WINGs/testtext.c index cfd3db8b..4a0f7b17 100644 --- a/WINGs/testtext.c +++ b/WINGs/testtext.c @@ -5,7 +5,7 @@ #include #include - +#include void wAbort() @@ -200,7 +200,7 @@ void parseToken(WMText *tPtr, char *token, short tk) if(*img == '\"') { img[strlen(img)-1] = 0; iptr++;} pixmap = WMCreatePixmapFromFile(scr, iptr); chunk = (cfmt.actions.createPChunk)(pixmap, 0, False); - (cfmt.actions.insertChunk) (tPtr, chunk, itAppend); + (cfmt.actions.insertChunk) (tPtr, chunk, False); printf("[%s]\n", iptr); } } break; } } while(*(token++)); } diff --git a/WINGs/wruler.c b/WINGs/wruler.c index 51e0e63a..9f13efe6 100644 --- a/WINGs/wruler.c +++ b/WINGs/wruler.c @@ -1,3 +1,7 @@ +/* WMRuler: nifty ruler widget for WINGs (OK, for WMText ;-) */ +/* Copyleft (>) 1999, 2000 Nwanua Elumeze */ + + #include "WINGsP.h" #define MIN_DOC_WIDTH 10 diff --git a/WINGs/wtext.c b/WINGs/wtext.c index f31174a4..42177988 100644 --- a/WINGs/wtext.c +++ b/WINGs/wtext.c @@ -1094,7 +1094,7 @@ if(scroll) { void -W_InsertText(WMText *tPtr, void *data, int position) +W_InsertText(WMText *tPtr, void *data, Bool prepend) { if(!tPtr) return; if(!data) { @@ -1127,9 +1127,9 @@ W_InsertText(WMText *tPtr, void *data, int position) } if(tPtr->parser) - (tPtr->parser)(tPtr, data, position >= 0 ? 1 : 0); + (tPtr->parser)(tPtr, data, prepend); else - defaultParser(tPtr, data, position >= 0 ? 1 : 0); + defaultParser(tPtr, data, prepend); } static void @@ -1894,8 +1894,9 @@ createParagraph(short fmargin, short bmargin, short rmargin, This function then sets currentPara as _this_ paragraph. NOTE: this means careless parser implementors might lose previous paragraphs... but this keeps stuff small and non-buggy :-) */ + void -insertParagraph(WMText *tPtr, void *v, InsertType type) +insertParagraph(WMText *tPtr, void *v, Bool prepend) //insertParagraph(WMText *tPtr, Paragraph *para, InsertType type) { Paragraph *tmp; @@ -1906,7 +1907,7 @@ insertParagraph(WMText *tPtr, void *v, InsertType type) tPtr->paragraphs = para; } else { tmp = tPtr->paragraphs; - if(type == itAppend) { + if(!prepend) { while(tmp->next && tmp != tPtr->currentPara) tmp = tmp->next; @@ -1997,7 +1998,7 @@ createTChunk(char *text, short chars, WMFont *font, NOTE: this means careless parser implementors might lose previous paragraphs/chunks... but this keeps stuff small and non-buggy :-) */ void -insertChunk(WMText *tPtr, void *v, InsertType type) +insertChunk(WMText *tPtr, void *v, Bool prepend) { Chunk *tmp; Chunk *chunk = (Chunk *)v; @@ -2007,7 +2008,7 @@ insertChunk(WMText *tPtr, void *v, InsertType type) if(!tPtr->paragraphs) { /* i.e., first chunk via insertTextInteractively */ Paragraph *para = (tPtr->funcs.createParagraph) (0, 0, tPtr->visibleW, NULL, 0, WALeft); - (tPtr->funcs.insertParagraph) (tPtr, para, itAppend); + (tPtr->funcs.insertParagraph) (tPtr, para, False); } if(!tPtr->currentPara) @@ -2020,7 +2021,7 @@ insertChunk(WMText *tPtr, void *v, InsertType type) } else { tmp = tPtr->currentPara->chunks; - if(type == itAppend) { + if(!prepend) { while(tmp->next && tmp != tPtr->currentChunk) tmp = tmp->next; -- 2.11.4.GIT