Added CRLF translation to uiMultilineEntry on Windows. More TODOs.
This commit is contained in:
parent
d060744f87
commit
f3dad94039
|
@ -17,6 +17,7 @@ This README is being written.<br>
|
|||
* **22 May 2016**
|
||||
** Removed `uiControlVerifyDestroy()`; that is now part of `uiFreeControl()` itself.
|
||||
** Added `uiPi`, a constant for π. This is provided for C and C++ programmers, where there is no standard named constant for π; bindings authors shouldn't need to worry about this.
|
||||
** Fixed uiMultilineEntry not properly having line breaks on Windows.
|
||||
|
||||
## Runtime Requirements
|
||||
|
||||
|
|
|
@ -63,15 +63,23 @@ static void defaultOnChanged(uiMultilineEntry *e, void *data)
|
|||
// TODO apply crlf conversion
|
||||
char *uiMultilineEntryText(uiMultilineEntry *e)
|
||||
{
|
||||
return uiWindowsWindowText(e->hwnd);
|
||||
char *out;
|
||||
|
||||
out = uiWindowsWindowText(e->hwnd);
|
||||
CRLFtoLF(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
// TODO apply crlf conversion
|
||||
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
||||
{
|
||||
char *crlf;
|
||||
|
||||
// doing this raises an EN_CHANGED
|
||||
e->inhibitChanged = TRUE;
|
||||
crlf = LFtoCRLF(text);
|
||||
uiWindowsSetWindowText(e->hwnd, text);
|
||||
uiFree(crlf);
|
||||
e->inhibitChanged = FALSE;
|
||||
// don't queue the control for resize; entry sizes are independent of their contents
|
||||
}
|
||||
|
@ -80,14 +88,18 @@ void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
|||
void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)
|
||||
{
|
||||
LRESULT n;
|
||||
char *crlf;
|
||||
WCHAR *wtext;
|
||||
|
||||
// TODO does doing this raise EN_CHANGED?
|
||||
// TODO preserve selection? caret? what if caret used to be at end?
|
||||
// TODO scroll to bottom?
|
||||
// TODO overdraw issues
|
||||
n = SendMessageW(e->hwnd, WM_GETTEXTLENGTH, 0, 0);
|
||||
SendMessageW(e->hwnd, EM_SETSEL, n, n);
|
||||
wtext = toUTF16(text);
|
||||
crlf = LFtoCRLF(text);
|
||||
wtext = toUTF16(crlf);
|
||||
uiFree(crlf);
|
||||
SendMessageW(e->hwnd, EM_REPLACESEL, FALSE, (LPARAM) wtext);
|
||||
uiFree(wtext);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ extern WCHAR *utf16dup(const WCHAR *orig);
|
|||
extern WCHAR *strf(const WCHAR *format, ...);
|
||||
extern WCHAR *vstrf(const WCHAR *format, va_list ap);
|
||||
extern char *LFtoCRLF(const char *lfonly);
|
||||
extern void CRLFtoLF(const char *s);
|
||||
extern void CRLFtoLF(char *s);
|
||||
extern WCHAR *ftoutf16(double d);
|
||||
extern WCHAR *itoutf16(intmax_t i);
|
||||
|
||||
|
|
Loading…
Reference in New Issue