mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-25 08:45:46 +01:00
WMReplaceTextSelection is now implemented
This commit is contained in:
@@ -1562,6 +1562,9 @@ void WMSetTextAlignment(WMText *tPtr, WMAlignment alignment);
|
|||||||
Bool WMFindInTextStream(WMText *tPtr, char *needle, Bool direction,
|
Bool WMFindInTextStream(WMText *tPtr, char *needle, Bool direction,
|
||||||
Bool caseSensitive);
|
Bool caseSensitive);
|
||||||
|
|
||||||
|
Bool WMReplaceTextSelection(WMText *tPtr, char *replacement);
|
||||||
|
|
||||||
|
|
||||||
/* parser related stuff... use only if implementing a new parser */
|
/* parser related stuff... use only if implementing a new parser */
|
||||||
|
|
||||||
void *WMCreateTextBlockWithObject(WMText *tPtr, WMWidget *w, char *description,
|
void *WMCreateTextBlockWithObject(WMText *tPtr, WMWidget *w, char *description,
|
||||||
|
|||||||
@@ -84,10 +84,7 @@ typedef struct _TextBlock {
|
|||||||
|
|
||||||
/* I'm lazy: visible.h vs. visible.size.height :-) */
|
/* I'm lazy: visible.h vs. visible.size.height :-) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int y;
|
int y, x, h, w;
|
||||||
unsigned int x;
|
|
||||||
unsigned int h;
|
|
||||||
unsigned int w;
|
|
||||||
} myRect;
|
} myRect;
|
||||||
|
|
||||||
|
|
||||||
@@ -1554,6 +1551,8 @@ layOutDocument(Text *tPtr)
|
|||||||
if ( tPtr->flags.frozen || (!(tb = tPtr->firstTextBlock)) )
|
if ( tPtr->flags.frozen || (!(tb = tPtr->firstTextBlock)) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
assert(tPtr->visible.w > 20);
|
||||||
|
|
||||||
tPtr->docWidth = tPtr->visible.w;
|
tPtr->docWidth = tPtr->visible.w;
|
||||||
x = tPtr->margins[tb->marginN].first;
|
x = tPtr->margins[tb->marginN].first;
|
||||||
bmargin = tPtr->margins[tb->marginN].body;
|
bmargin = tPtr->margins[tb->marginN].body;
|
||||||
@@ -1671,16 +1670,16 @@ _layOut:
|
|||||||
width = WMWidthOfString(font,
|
width = WMWidthOfString(font,
|
||||||
&tb->text[begin], end-begin);
|
&tb->text[begin], end-begin);
|
||||||
|
|
||||||
/* if it won't fit, break it up */
|
/* if it won't fit, char wrap it */
|
||||||
if (width > tPtr->visible.w) {
|
if (width >= tPtr->visible.w) {
|
||||||
char *t = &tb->text[begin];
|
char *t = &tb->text[begin];
|
||||||
int l=end-begin, i=0;
|
int l=end-begin, i=0;
|
||||||
do {
|
do {
|
||||||
width = WMWidthOfString(font, t, ++i);
|
width = WMWidthOfString(font, t, ++i);
|
||||||
} while (width < tPtr->visible.w && i < l);
|
} while (width < tPtr->visible.w && i < l);
|
||||||
|
if(i>2) i--;
|
||||||
end = begin+i;
|
end = begin+i;
|
||||||
if (start)
|
start = &tb->text[end];
|
||||||
start -= l-i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lw += width;
|
lw += width;
|
||||||
@@ -1856,6 +1855,7 @@ clearText(Text *tPtr)
|
|||||||
{
|
{
|
||||||
tPtr->vpos = tPtr->hpos = 0;
|
tPtr->vpos = tPtr->hpos = 0;
|
||||||
tPtr->docHeight = tPtr->docWidth = 0;
|
tPtr->docHeight = tPtr->docWidth = 0;
|
||||||
|
tPtr->cursor.x = -23;
|
||||||
|
|
||||||
if (!tPtr->firstTextBlock)
|
if (!tPtr->firstTextBlock)
|
||||||
return;
|
return;
|
||||||
@@ -3996,3 +3996,25 @@ WMFindInTextStream(WMText *tPtr, char *needle, Bool direction,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Bool
|
||||||
|
WMReplaceTextSelection(WMText *tPtr, char *replacement)
|
||||||
|
{
|
||||||
|
if (!tPtr)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
if (!tPtr->flags.ownsSelection)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
removeSelection(tPtr);
|
||||||
|
|
||||||
|
if(replacement) {
|
||||||
|
insertTextInteractively(tPtr, replacement, strlen(replacement));
|
||||||
|
updateCursorPosition(tPtr);
|
||||||
|
paintText(tPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user