static void editorasciikeydown(textbox t, int key) { /* check whether the text limit is about to be exceeded and increase it if necessary. Ugh - this callback is called after the text is inserted, so we make space for two characters */ checklimittext(t, 2); }
static int richeditreplace(HWND hwnd, char *what, char *replacewith, int matchcase, int wholeword, int down) { /* If current selection is the find string, replace it and find next */ long start, end; CHARRANGE sel; char *buf; textbox t = find_by_handle(hwnd); if (t) { sendmessage (hwnd, EM_EXGETSEL, 0, &sel) ; start = sel.cpMin; end = sel.cpMax; if (start < end) { buf = (char *) malloc(end - start + 1); sendmessage(hwnd, EM_GETSELTEXT, 0, buf); if (!strcmp(buf, what)) { checklimittext(t, strlen(replacewith) - strlen(what) + 2); sendmessage (hwnd, EM_REPLACESEL, 1, replacewith); } free(buf); } /* else just find next */ if (richeditfind(hwnd, what, matchcase, wholeword, down)) return 1; } return 0; }
static void editorpaste(control m) { textbox t = getdata(m); /* check whether the widget text limit needs to be increased * before doing the paste */ int pastelen = getpastelength(); checklimittext(t, pastelen + 1); pastetext(t); }