1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-04-20 15:21:27 +02:00

Guess what? Yep, another wmtext update. Now this was all, please go to

your homes.
This commit is contained in:
dan
2000-06-22 23:01:27 +00:00
parent c87c53fbe5
commit 9d4dae947b
+102 -106
View File
@@ -13,22 +13,18 @@
/* if monoFont, ignore pixmaps, colors, fonts, script, underline */
//#include <WINGs.h>
#include <WMaker.h>
#include <WINGsP.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <ctype.h>
#if 0
#include "wruler.h"
#include "wtext.h"
#endif
void wgdbFree(void *ptr)
{ if(!ptr) printf("err... cannot ");
printf("gdbFree [%p]\n", ptr);
wfree(ptr);
{
if(!ptr) printf("err... cannot ");
printf("gdbFree [%p]\n", ptr);
wfree(ptr);
}
@@ -59,7 +55,7 @@ typedef struct _Chunk {
short ul:1; /* underlined or not */
ChunkType type:1; /* a "Text" or "Image" chunk */
short script:4; /* script in points: negative for subscript */
//hrmm selec...
/* hrmm selec... */
ushort selected;
ushort sStart;
ushort sEnd;
@@ -97,48 +93,48 @@ typedef struct _Paragraph {
static char *default_bullet[] = {
"6 6 4 1",
" c None s None", ". c black",
"X c white", "o c #808080",
" ... ",
".XX.. ",
".XX..o",
".....o",
" ...oo",
" ooo "};
"6 6 4 1",
" c None s None", ". c black",
"X c white", "o c #808080",
" ... ",
".XX.. ",
".XX..o",
".....o",
" ...oo",
" ooo "};
/* this is really a shrunk down version of the original
"broken" icon... I did not draw it, I simply shrunk it */
static char * unk_xpm[] = {
"24 24 17 1",
" c None", ". c #0B080C", "+ c #13A015", "@ c #5151B8",
"# c #992719", "$ c #5B1C20", "% c #1DF51D", "& c #D1500D", "* c #2F304A",
"= c #0C6A0C", "- c #F2F1DE", "; c #D59131", "> c #B2B083", ", c #DD731A",
"' c #CC3113", ") c #828238", "! c #6A6A94",
"......!@@@@@@@....$$....",
"...@!@@@@@@@**...$#'....",
"..!!@@@@@@@@.......#....",
"..!@@@@@@@@@*.......$...",
".!@@@#,,#*@@*..*>.*.#...",
"*@@@@#'',,@@@...---!....",
"!@@@@@*.#;*@@..!--->....",
"@@@@@@@@#,.@@..!----@...",
"!@@@@@@*#;'$...!----@...",
"*@@@@@@..'&;;#.)----)...",
".@@@@@@..$..&'.>----)...",
".@@@@@@**---,'>-----!...",
".@@@@@@**---,'>-----@...",
"..@@@@@@@---;;;,;---....",
"..*@@@@*@--->#',;,-*.)..",
"........)---->)@;#!..>..",
".....)----------;$..>)..",
"=%%%*.*!-------);..)-*..",
"=%%%%+...*)>!@*$,.>--...",
"*+++++++.......*$@-->...",
"............**@)!)>->...",
"........................",
"........................",
"........................"};
"broken" icon... I did not draw it, I simply shrunk it */
static char * unk_xpm[] = {
"24 24 17 1",
" c None", ". c #0B080C", "+ c #13A015", "@ c #5151B8",
"# c #992719", "$ c #5B1C20", "% c #1DF51D", "& c #D1500D", "* c #2F304A",
"= c #0C6A0C", "- c #F2F1DE", "; c #D59131", "> c #B2B083", ", c #DD731A",
"' c #CC3113", ") c #828238", "! c #6A6A94",
"......!@@@@@@@....$$....",
"...@!@@@@@@@**...$#'....",
"..!!@@@@@@@@.......#....",
"..!@@@@@@@@@*.......$...",
".!@@@#,,#*@@*..*>.*.#...",
"*@@@@#'',,@@@...---!....",
"!@@@@@*.#;*@@..!--->....",
"@@@@@@@@#,.@@..!----@...",
"!@@@@@@*#;'$...!----@...",
"*@@@@@@..'&;;#.)----)...",
".@@@@@@..$..&'.>----)...",
".@@@@@@**---,'>-----!...",
".@@@@@@**---,'>-----@...",
"..@@@@@@@---;;;,;---....",
"..*@@@@*@--->#',;,-*.)..",
"........)---->)@;#!..>..",
".....)----------;$..>)..",
"=%%%*.*!-------);..)-*..",
"=%%%%+...*)>!@*$,.>--...",
"*+++++++.......*$@-->...",
"............**@)!)>->...",
"........................",
"........................",
"........................"};
typedef struct W_Text {
W_Class widgetClass; /* the class number of this widget */
@@ -213,7 +209,7 @@ typedef struct W_Text {
#define MIN_DOC_WIDTH 200
typedef struct _LocalMargins {
short left, right, first, body;
} LocalMargins;
} LocalMargins;
typedef struct _MyTextItems {
char text[MAX_WORD_LENGTH+1];
@@ -328,7 +324,7 @@ myDrawText(Text *tPtr, Paragraph *para, MyTextItems *items,
items[i].text, items[i].chars);
} else {
mx_descent = WMIN(mx_descent, -(items[i].pix->height-3));
/* replace -3 wif descent... */
/* replace -3 wif descent... */
line_height = WMAX(line_height, items[i].pix->height);
if(para->align == WARight || para->align == WACenter) {
line_width += items[i].pix->width;
@@ -460,7 +456,7 @@ drawTChunkPart(Text *tPtr, Chunk *chunk, char *bufr, LocalMargins m,
{
short t_chunk_width, p_width, chars;
WMFont *font = (tPtr->monoFont)?tPtr->dFont:chunk->font;
/* if(doc->clickstart.yes && doc->clickstart.done) return; */
/* if(doc->clickstart.yes && doc->clickstart.done) return; */
if(len==0) return;
p_width = m.right - WMIN(m.first, m.body);
@@ -737,9 +733,9 @@ calcDocExtents(Text *tPtr)
/* If any part of a paragraph is viewable, the entire
paragraph is drawn on an otherwise empty (XFreePixmap) pixmap.
The actual viewable parts of the paragraph(s) are then pieced
together via paintText:
paragraph is drawn on an otherwise empty (XFreePixmap) pixmap.
The actual viewable parts of the paragraph(s) are then pieced
together via paintText:
-------------------------------------------
|| this is a paragraph in this document||
@@ -762,7 +758,7 @@ together via paintText:
-------------------------------------------
simple, right? Performance: the best of both worlds...
simple, right? Performance: the best of both worlds...
o fast scrolling: no need to rewrite what's already
on the screen, simply XCopy it.
o fast typing: only change current para, then simply
@@ -815,7 +811,7 @@ paintText(Text *tPtr)
if(tPtr->hasVscroller) vS = 21;
if(tPtr->hasHscroller) hS = 21;
//XClearWindow(tPtr->view->screen->display, tPtr->view->window);
//XClearWindow(tPtr->view->screen->display, tPtr->view->window);
lmargin = WMGetRulerMargin(tPtr->ruler, WRulerDocLeft);
if(tPtr->paragraphs) {
@@ -857,7 +853,7 @@ paintText(Text *tPtr)
vS+1, rh+5, lmargin-vS, tPtr->visibleH+rh+5-vS, False);
// from the "selection" days...
// from the "selection" days...
W_DrawRelief(tPtr->view->screen, WMWidgetXID(tPtr),
tPtr->sRect.pos.x, tPtr->sRect.pos.y,
tPtr->sRect.size.width, tPtr->sRect.size.height, tPtr->relief);
@@ -1046,23 +1042,23 @@ scrollersCallBack(WMWidget *w, void *self)
#if 0
case WSKnobSlot:
case WSNoPart:
float vmax = (float)(tPtr->docHeight);
((float)tPtr->vpos)/(vmax - (float)tPtr->visibleH),
(float)tPtr->visibleH/vmax);
float vmax = (float)(tPtr->docHeight);
((float)tPtr->vpos)/(vmax - (float)tPtr->visibleH),
(float)tPtr->visibleH/vmax);
dimple =where mouse is.
#endif
break;
}
scroll = (tPtr->vpos != tPtr->prevVpos);
tPtr->prevVpos = tPtr->vpos;
}
break;
}
scroll = (tPtr->vpos != tPtr->prevVpos);
tPtr->prevVpos = tPtr->vpos;
}
if(w == tPtr->hscroller)
if(w == tPtr->hscroller)
;
//need scrollv || scrollh
if(scroll) {
/*
if(scroll) {
/*
if(0&&dimple) {
if(tPtr->rulerShown)
XClearArea(tPtr->view->screen->display, tPtr->view->window, 22, 47,
@@ -1071,11 +1067,11 @@ dimple =where mouse is.
XClearArea(tPtr->view->screen->display, tPtr->view->window, 22, 2,
tPtr->view->size.width-24, tPtr->view->size.height-4, True);
}
*/
*/
updateScrollers(tPtr);
drawDocumentPartsOnPixmap(tPtr, False);
paintText(tPtr);
}
}
}
@@ -1177,14 +1173,14 @@ cursorToTextPosition(Text *tPtr, int x, int y)
if(line_width+tPtr->clicked.x >= x) {
line_width -= _width;
done = True;
printf("break\n");
printf("break\n");
break;
} }
if(0&&chunk->next) {
if(chunk->next->type == ctImage) {
if(x+10 < line_width+chunk->next->pixmap->width) {
printf("true\n");
printf("true\n");
done = True;
} } }
} else {
@@ -1240,7 +1236,7 @@ deleteTextInteractively(Text *tPtr, DeleteType type)
case dtBackSpace: /* delete _before_ cursor */
if(chunk->chars > 1) {
pos = tPtr->tpos-1;
printf("here %d\n", pos);
printf("here %d\n", pos);
if(pos>0) {
w = WMWidthOfString(font, &chunk->text[pos], 1);
memmove(&(chunk->text[pos]),
@@ -1282,7 +1278,7 @@ printf("here %d\n", pos);
putParagraphOnPixmap(tPtr, para, True);
drawDocumentPartsOnPixmap(tPtr, False);
updateScrollers(tPtr);
paintText(tPtr);
paintText(tPtr);
//cursorToTextPosition(tPtr, tPtr->clicked.x-w, tPtr->clicked.y);
} else WMRefreshText(tPtr, tPtr->vpos, tPtr->hpos);
}
@@ -1373,10 +1369,10 @@ insertTextInteractively(Text *tPtr, char *text)
} else if(chunk->type == ctImage) {
WMPrependTextStream(tPtr, text);
printf("\n\nprepe\n\n");
printf("\n\nprepe\n\n");
} else {
if(tPtr->tpos > chunk->chars) {
printf("\n\nmore\n\n");
printf("\n\nmore\n\n");
tPtr->tpos = chunk->chars;
}
@@ -1391,8 +1387,8 @@ printf("\n\nmore\n\n");
memmove(&chunk->text[tPtr->tpos], text, 1);
chunk->chars++;
tPtr->tpos++;
//doc->clickstart.cursor.x +=
//WMWidthOfString(chunk->fmt->font, text,len);
//doc->clickstart.cursor.x +=
//WMWidthOfString(chunk->fmt->font, text,len);
}
}
@@ -1402,10 +1398,10 @@ printf("\n\nmore\n\n");
putParagraphOnPixmap(tPtr, para, True);
drawDocumentPartsOnPixmap(tPtr, False);
updateScrollers(tPtr);
paintText(tPtr);
paintText(tPtr);
//cursorToTextPosition(tPtr, tPtr->clicked.x+w, tPtr->clicked.y);
//check for "sneppah tahw" with blank paras...
//paintText(tPtr);
//check for "sneppah tahw" with blank paras...
//paintText(tPtr);
}
}
@@ -1419,14 +1415,14 @@ selectRegion(Text *tPtr, int x, int y)
if(tPtr->sRect.pos.y<0) tPtr->sRect.pos.y=0;
tPtr->sRect.size.height = abs(tPtr->clicked.y-y);
/*
/*
while(y>tPtr->visibleH && tPtr->vpos < tPtr->docHeight-tPtr->visibleH) {
WMRefreshText(tPtr, tPtr->vpos+16, tPtr->hpos);
}
*/
//printf("%d %d \n", y, tPtr->vpos);
*/
//printf("%d %d \n", y, tPtr->vpos);
//foreach para in selection...
//foreach para in selection...
drawDocumentPartsOnPixmap(tPtr, True);
paintText(tPtr);
}
@@ -1485,7 +1481,7 @@ handleTextKeyPress(Text *tPtr, XEvent *event)
case XK_Down:
case XK_Up:
noCChunk: { short h = tPtr->clheight-2;
noCChunk: { short h = tPtr->clheight-2;
if(ksym==XK_Down) h = -h;
cursorToTextPosition(tPtr, tPtr->clicked.x, tPtr->clicked.y-h);
} break;
@@ -1575,10 +1571,10 @@ requestHandler(WMView *view, Atom selection, Atom target,
if(!tPtr->ownsSelection || !tPtr->paragraphs) return NULL;
//printf("got here\n");
//printf("got here\n");
if (target == XA_STRING || target == TEXT || target == COMPOUND_TEXT) {
//for bleh in selection...
//for bleh in selection...
char *s = NULL;
Paragraph *para = tPtr->paragraphs;
Chunk *chunk = NULL;
@@ -1601,14 +1597,14 @@ requestHandler(WMView *view, Atom selection, Atom target,
data = WMCreateDataWithBytes(s, strlen(s));
first = False;
} else {
printf("append: %c %d\n", *s, strlen(s));
printf("append: %c %d\n", *s, strlen(s));
WMAppendDataBytes(data, s, strlen(s));
}
//gdbFree(s);
} } }
#if 0
printf("len is %d [%d %d] %d \n", len, chunk->sStart, chunk->sEnd,
chunk->chars);
printf("len is %d [%d %d] %d \n", len, chunk->sStart, chunk->sEnd,
chunk->chars);
#endif
chunk = chunk->next;
}
@@ -1655,7 +1651,7 @@ static WMSelectionProcs selectionHandler = {
requestHandler, lostHandler, NULL };
static void
_notification(void *observerData, WMNotification *notification)
_notification(void *observerData, WMNotification *notification)
{
WMText *to = (WMText *)observerData;
WMText *tw = (WMText *)WMGetNotificationClientData(notification);
@@ -1783,7 +1779,7 @@ handleNonTextEvents(XEvent *event, void *data)
}
//printf("handleNonTextEvents\n");
//printf("handleNonTextEvents\n");
}
@@ -2104,7 +2100,7 @@ WMCreateText(WMWidget *parent)
tPtr->docWidth = 0;
tPtr->docHeight = 0;
tPtr->dBulletPix = WMCreatePixmapFromXPMData(tPtr->view->screen,
default_bullet);
default_bullet);
tPtr->dUnknownImg = WMCreatePixmapFromXPMData(tPtr->view->screen,
unk_xpm);
@@ -2158,9 +2154,9 @@ WMCreateText(WMWidget *parent)
WMShowTextRuler(tPtr, False);
WMSetTextHasHorizontalScroller(tPtr, False);
WMSetTextHasVerticalScroller(tPtr, True);
//printf("the sizeof chunk is %d\n", sizeof(Chunk));
//printf("the sizeof para is %d\n", sizeof(Paragraph));
//printf("the sizeof text is %d\n", sizeof(Text));
//printf("the sizeof chunk is %d\n", sizeof(Chunk));
//printf("the sizeof para is %d\n", sizeof(Paragraph));
//printf("the sizeof text is %d\n", sizeof(Text));
return tPtr;
}
@@ -2186,7 +2182,7 @@ WMRemoveTextParagraph(WMText *tPtr, int which)
prior->next = removed->next;
}
wgdbFree(removed);
// removeChunks
// removeChunks
removed = NULL;
}
@@ -2248,7 +2244,7 @@ WMGetTextCurrentParagraph(WMText *tPtr)
}
/* set what is known as the currentChunk within the currently
selected currentPara (or the first paragraph in the document). */
selected currentPara (or the first paragraph in the document). */
void
WMSetTextCurrentChunk(WMText *tPtr, int current)
{
@@ -2538,20 +2534,20 @@ WMRefreshText(WMText *tPtr, int vpos, int hpos)
tPtr->visibleW, tPtr->visibleH, True);
calcDocExtents(tPtr);
/*
printf("vpos:%d tPtr->docHeight%d tPtr->visibleH%d \n",
vpos, tPtr->docHeight, tPtr->visibleH);
*/
/*
printf("vpos:%d tPtr->docHeight%d tPtr->visibleH%d \n",
vpos, tPtr->docHeight, tPtr->visibleH);
*/
// tPtr->vpos = vpos;
/*
/*
if(vpos < 0 || tPtr->docHeight < tPtr->visibleH)
tPtr->vpos = 0;
else if(vpos-tPtr->visibleH>tPtr->docHeight)
tPtr->vpos = vpos-tPtr->docHeight-tPtr->visibleH-tPtr->docHeight;
else
tPtr->vpos = tPtr->docHeight-tPtr->visibleH;
*/
*/
if(hpos < 0 || hpos > tPtr->docWidth)