1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-08 23:04:15 +01:00

added support for Getting and Setting Selection Fonts/Colors/Underline...

This commit is contained in:
nwanua
2000-11-10 07:24:49 +00:00
parent b0dbbb3536
commit 7d463ca48d
2 changed files with 90 additions and 4 deletions

View File

@@ -1547,8 +1547,16 @@ WMArray* WMGetTextSelectedObjects(WMText *tPtr);
void WMSetTextSelectionColor(WMText *tPtr, WMColor *color); void WMSetTextSelectionColor(WMText *tPtr, WMColor *color);
WMColor *WMGetTextSelectionColor(WMText *tPtr);
void WMSetTextSelectionFont(WMText *tPtr, WMFont *font); void WMSetTextSelectionFont(WMText *tPtr, WMFont *font);
WMFont *WMGetTextSelectionFont(WMText *tPtr);
void WMSetTextSelectionUnderlined(WMText *tPtr, int underlined);
int WMGetTextSelectionUnderlined(WMText *tPtr);
void WMSetTextAlignment(WMText *tPtr, WMAlignment alignment); void WMSetTextAlignment(WMText *tPtr, WMAlignment alignment);
Bool WMFindInTextStream(WMText *tPtr, char *needle, Bool direction, Bool WMFindInTextStream(WMText *tPtr, char *needle, Bool direction,

View File

@@ -38,7 +38,7 @@ typedef struct {
} Section; } Section;
/* a TextBlock is a doubly-linked list of TextBlocks containing: /* a TextBlock is a node in a doubly-linked list of TextBlocks containing:
o text for the block, color and font o text for the block, color and font
o or a pointer to the pixmap o or a pointer to the pixmap
o OR a pointer to the widget and the (text) description for its graphic o OR a pointer to the widget and the (text) description for its graphic
@@ -560,7 +560,8 @@ getFirstNonGraphicBlockFor(TextBlock *tb, short dir)
} }
if(!tb) if(!tb)
tb = hold; return NULL;
return tb; return tb;
} }
@@ -571,6 +572,9 @@ TextBlock *tb)
{ {
if (tPtr->flags.monoFont && tb->graphic) { if (tPtr->flags.monoFont && tb->graphic) {
tb = getFirstNonGraphicBlockFor(tb, *dir); tb = getFirstNonGraphicBlockFor(tb, *dir);
if(!tb)
return 0;
if (tb->graphic) { if (tb->graphic) {
tPtr->currentTextBlock = tPtr->currentTextBlock =
(dir? tPtr->lastTextBlock : tPtr->firstTextBlock); (dir? tPtr->lastTextBlock : tPtr->firstTextBlock);
@@ -1059,8 +1063,18 @@ cursorToTextPosition(Text *tPtr, int x, int y)
_doneV: _doneV:
/* we have the line, which TextBlock on that line is it? */ /* we have the line, which TextBlock on that line is it? */
pos = (dir?0:tb->sections[s].begin); pos = (dir?0:tb->sections[s].begin);
if (tPtr->flags.monoFont && tb->graphic) if (tPtr->flags.monoFont && tb->graphic) {
tb = getFirstNonGraphicBlockFor(tb, dir); TextBlock *hold = tb;
tb = getFirstNonGraphicBlockFor(hold, dir);
if(!tb) {
tPtr->tpos = 0;
tb = hold;
s = 0;
goto _doNothing;
}
}
if(tb->blank) if(tb->blank)
_w = 0; _w = 0;
@@ -1156,6 +1170,7 @@ _doneH:
tPtr->tpos = (pos<tb->used)? pos : tb->used; tPtr->tpos = (pos<tb->used)? pos : tb->used;
} }
_doNothing:
if (!tb) if (!tb)
printf("...for this app will surely crash :-)\n"); printf("...for this app will surely crash :-)\n");
@@ -3714,6 +3729,26 @@ WMSetTextSelectionColor(WMText *tPtr, WMColor *color)
setSelectionProperty(tPtr, NULL, color, -1); setSelectionProperty(tPtr, NULL, color, -1);
} }
WMColor *
WMGetTextSelectionColor(WMText *tPtr)
{
TextBlock *tb;
if (!tPtr)
return NULL;
tb = tPtr->currentTextBlock;
if (!tb || !tPtr->flags.ownsSelection)
return NULL;
if(!tb->selected)
return NULL;
return tb->color;
}
void void
WMSetTextSelectionFont(WMText *tPtr, WMFont *font) WMSetTextSelectionFont(WMText *tPtr, WMFont *font)
{ {
@@ -3723,6 +3758,31 @@ WMSetTextSelectionFont(WMText *tPtr, WMFont *font)
setSelectionProperty(tPtr, font, NULL, -1) ; setSelectionProperty(tPtr, font, NULL, -1) ;
} }
WMFont *
WMGetTextSelectionFont(WMText *tPtr)
{
TextBlock *tb;
if (!tPtr)
return NULL;
tb = tPtr->currentTextBlock;
if (!tb || !tPtr->flags.ownsSelection)
return NULL;
if(!tb->selected)
return NULL;
if(tb->graphic) {
tb = getFirstNonGraphicBlockFor(tb, 1);
if(!tb)
return NULL;
}
return (tb->selected ? tb->d.font : NULL);
}
void void
WMSetTextSelectionUnderlined(WMText *tPtr, int underlined) WMSetTextSelectionUnderlined(WMText *tPtr, int underlined)
{ {
@@ -3733,6 +3793,24 @@ WMSetTextSelectionUnderlined(WMText *tPtr, int underlined)
} }
int
WMGetTextSelectionUnderlined(WMText *tPtr)
{
TextBlock *tb;
if (!tPtr)
return 0;
tb = tPtr->currentTextBlock;
if (!tb || !tPtr->flags.ownsSelection)
return 0;
if(!tb->selected)
return 0;
return tb->underlined;
}
void void