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**
|
* **22 May 2016**
|
||||||
** Removed `uiControlVerifyDestroy()`; that is now part of `uiFreeControl()` itself.
|
** 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.
|
** 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
|
## Runtime Requirements
|
||||||
|
|
||||||
|
|
|
@ -63,15 +63,23 @@ static void defaultOnChanged(uiMultilineEntry *e, void *data)
|
||||||
// TODO apply crlf conversion
|
// TODO apply crlf conversion
|
||||||
char *uiMultilineEntryText(uiMultilineEntry *e)
|
char *uiMultilineEntryText(uiMultilineEntry *e)
|
||||||
{
|
{
|
||||||
return uiWindowsWindowText(e->hwnd);
|
char *out;
|
||||||
|
|
||||||
|
out = uiWindowsWindowText(e->hwnd);
|
||||||
|
CRLFtoLF(out);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO apply crlf conversion
|
// TODO apply crlf conversion
|
||||||
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
|
char *crlf;
|
||||||
|
|
||||||
// doing this raises an EN_CHANGED
|
// doing this raises an EN_CHANGED
|
||||||
e->inhibitChanged = TRUE;
|
e->inhibitChanged = TRUE;
|
||||||
|
crlf = LFtoCRLF(text);
|
||||||
uiWindowsSetWindowText(e->hwnd, text);
|
uiWindowsSetWindowText(e->hwnd, text);
|
||||||
|
uiFree(crlf);
|
||||||
e->inhibitChanged = FALSE;
|
e->inhibitChanged = FALSE;
|
||||||
// don't queue the control for resize; entry sizes are independent of their contents
|
// 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)
|
void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
LRESULT n;
|
LRESULT n;
|
||||||
|
char *crlf;
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
|
|
||||||
// TODO does doing this raise EN_CHANGED?
|
// TODO does doing this raise EN_CHANGED?
|
||||||
// TODO preserve selection? caret? what if caret used to be at end?
|
// TODO preserve selection? caret? what if caret used to be at end?
|
||||||
// TODO scroll to bottom?
|
// TODO scroll to bottom?
|
||||||
|
// TODO overdraw issues
|
||||||
n = SendMessageW(e->hwnd, WM_GETTEXTLENGTH, 0, 0);
|
n = SendMessageW(e->hwnd, WM_GETTEXTLENGTH, 0, 0);
|
||||||
SendMessageW(e->hwnd, EM_SETSEL, n, n);
|
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);
|
SendMessageW(e->hwnd, EM_REPLACESEL, FALSE, (LPARAM) wtext);
|
||||||
uiFree(wtext);
|
uiFree(wtext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ extern WCHAR *utf16dup(const WCHAR *orig);
|
||||||
extern WCHAR *strf(const WCHAR *format, ...);
|
extern WCHAR *strf(const WCHAR *format, ...);
|
||||||
extern WCHAR *vstrf(const WCHAR *format, va_list ap);
|
extern WCHAR *vstrf(const WCHAR *format, va_list ap);
|
||||||
extern char *LFtoCRLF(const char *lfonly);
|
extern char *LFtoCRLF(const char *lfonly);
|
||||||
extern void CRLFtoLF(const char *s);
|
extern void CRLFtoLF(char *s);
|
||||||
extern WCHAR *ftoutf16(double d);
|
extern WCHAR *ftoutf16(double d);
|
||||||
extern WCHAR *itoutf16(intmax_t i);
|
extern WCHAR *itoutf16(intmax_t i);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue