summaryrefslogtreecommitdiff
path: root/iup/src/win/iupwin_text.c
diff options
context:
space:
mode:
Diffstat (limited to 'iup/src/win/iupwin_text.c')
-rwxr-xr-xiup/src/win/iupwin_text.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/iup/src/win/iupwin_text.c b/iup/src/win/iupwin_text.c
index ee6fbb7..9059796 100755
--- a/iup/src/win/iupwin_text.c
+++ b/iup/src/win/iupwin_text.c
@@ -1171,7 +1171,35 @@ static int winTextSetStandardFontAttrib(Ihandle* ih, const char* value)
return iupdrvSetStandardFontAttrib(ih, value);
}
-void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)
+typedef struct
+{
+ int eventMask;
+ DWORD line;
+ CHARRANGE oldRange;
+} formatTagBulkState;
+
+void* iupdrvTextAddFormatTagStartBulk(Ihandle* ih)
+{
+ formatTagBulkState* state = (formatTagBulkState*) malloc(sizeof(formatTagBulkState));
+ state->line = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0);
+ SendMessage(ih->handle, EM_EXGETSEL, 0, (LPARAM)&state->oldRange);
+ state->eventMask = SendMessage(ih->handle, EM_SETEVENTMASK, 0, 0);
+ SendMessage(ih->handle, WM_SETREDRAW, FALSE, 0);
+ return state;
+}
+
+void iupdrvTextAddFormatTagStopBulk(Ihandle* ih, void* stateOpaque)
+{
+ formatTagBulkState* state = (formatTagBulkState*) stateOpaque;
+ SendMessage(ih->handle, EM_EXSETSEL, 0, (LPARAM)&state->oldRange);
+ DWORD line = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0);
+ SendMessage(ih->handle, EM_LINESCROLL, 0, state->line - line);
+ SendMessage(ih->handle, WM_SETREDRAW, TRUE, 0);
+ SendMessage(ih->handle, EM_SETEVENTMASK, 0, state->eventMask);
+ free(state);
+}
+
+void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag, int bulk)
{
int convert2twips, pixel2twips;
char *selection, *units;
@@ -1197,9 +1225,6 @@ void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)
convert2twips = val;
}
- /* saves current selection / scroll position before doing anything */
- line0 = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0);
- SendMessage(ih->handle, EM_EXGETSEL, 0, (LPARAM)&oldRange);
selection = iupAttribGet(formattag, "SELECTION");
if (selection)
{
@@ -1216,7 +1241,12 @@ void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)
}
}
- oldEventMask = SendMessage(ih->handle, EM_SETEVENTMASK, 0, 0);
+ if (!bulk) {
+ line0 = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0);
+ SendMessage(ih->handle, EM_EXGETSEL, 0, (LPARAM)&oldRange);
+ oldEventMask = SendMessage(ih->handle, EM_SETEVENTMASK, 0, 0);
+ SendMessage(ih->handle, WM_SETREDRAW, FALSE, 0);
+ }
if (iupAttribGet(formattag, "FONTSCALE") && !iupAttribGet(formattag, "FONTSIZE"))
iupAttribSetStr(formattag, "FONTSIZE", iupGetFontSizeAttrib(ih));
@@ -1228,11 +1258,13 @@ void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)
if (charformat.dwMask != 0)
SendMessage(ih->handle, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&charformat);
- /* restores selection / scroll position */
- SendMessage(ih->handle, EM_EXSETSEL, 0, (LPARAM)&oldRange);
- line1 = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0);
- SendMessage(ih->handle, EM_LINESCROLL, 0, line0 - line1);
- SendMessage(ih->handle, EM_SETEVENTMASK, 0, oldEventMask);
+ if (!bulk) {
+ SendMessage(ih->handle, EM_EXSETSEL, 0, (LPARAM)&oldRange);
+ line1 = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0);
+ SendMessage(ih->handle, EM_LINESCROLL, 0, line0 - line1);
+ SendMessage(ih->handle, WM_SETREDRAW, TRUE, 0);
+ SendMessage(ih->handle, EM_SETEVENTMASK, 0, oldEventMask);
+ }
}
static int winTextSetRemoveFormattingAttrib(Ihandle* ih, const char* value)