summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 3be6a383..22f983eb 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -715,7 +715,8 @@ static void updateAllLinesAndResizeHeight_InputWidget_(iInputWidget *d) {
715 const int height = measure_WrapText(&wt, d->font).bounds.size.y; 715 const int height = measure_WrapText(&wt, d->font).bounds.size.y;
716 /* We use this to store the number wrapped lines for determining widget height. */ 716 /* We use this to store the number wrapped lines for determining widget height. */
717 d->visWrapLines.start = 0; 717 d->visWrapLines.start = 0;
718 d->visWrapLines.end = iMin(d->maxWrapLines, height / lineHeight_Text(d->font)); 718 d->visWrapLines.end = iMax(d->minWrapLines,
719 iMin(d->maxWrapLines, height / lineHeight_Text(d->font)));
719 updateMetrics_InputWidget_(d); 720 updateMetrics_InputWidget_(d);
720} 721}
721 722
@@ -733,8 +734,10 @@ static int contentHeight_InputWidget_(const iInputWidget *d) {
733 if (d->buffered && ~d->inFlags & needUpdateBuffer_InputWidgetFlag) { 734 if (d->buffered && ~d->inFlags & needUpdateBuffer_InputWidgetFlag) {
734 return iClamp(d->buffered->size.y, minHeight, maxHeight); 735 return iClamp(d->buffered->size.y, minHeight, maxHeight);
735 } 736 }
736#endif 737 return minHeight;
738#else
737 return (int) size_Range(&d->visWrapLines) * lineHeight; 739 return (int) size_Range(&d->visWrapLines) * lineHeight;
740#endif
738} 741}
739 742
740static void updateTextInputRect_InputWidget_(const iInputWidget *d) { 743static void updateTextInputRect_InputWidget_(const iInputWidget *d) {
@@ -1111,7 +1114,7 @@ void setText_InputWidget(iInputWidget *d, const iString *text) {
1111#else 1114#else
1112 set_String(&d->text, nfcText); 1115 set_String(&d->text, nfcText);
1113 if (d->sysCtrl) { 1116 if (d->sysCtrl) {
1114 setText_SystemTextInput(d->sysCtrl, nfcText); 1117 setText_SystemTextInput(d->sysCtrl, nfcText, iTrue);
1115 } 1118 }
1116 else { 1119 else {
1117 updateAllLinesAndResizeHeight_InputWidget_(d); /* need to know the new height */ 1120 updateAllLinesAndResizeHeight_InputWidget_(d); /* need to know the new height */
@@ -1134,7 +1137,11 @@ void setTextCStr_InputWidget(iInputWidget *d, const char *cstr) {
1134} 1137}
1135 1138
1136void selectAll_InputWidget(iInputWidget *d) { 1139void selectAll_InputWidget(iInputWidget *d) {
1137#if !LAGRANGE_USE_SYSTEM_TEXT_INPUT 1140#if LAGRANGE_USE_SYSTEM_TEXT_INPUT
1141 if (d->sysCtrl) {
1142 selectAll_SystemTextInput(d->sysCtrl);
1143 }
1144#else
1138 d->mark = (iRanges){ 0, lastLine_InputWidget_(d)->range.end }; 1145 d->mark = (iRanges){ 0, lastLine_InputWidget_(d)->range.end };
1139 refresh_Widget(as_Widget(d)); 1146 refresh_Widget(as_Widget(d));
1140#endif 1147#endif
@@ -1177,7 +1184,7 @@ void begin_InputWidget(iInputWidget *d) {
1177 (isAllowedToInsertNewline_InputWidget_(d) ? insertNewlines_SystemTextInputFlag : 0) | 1184 (isAllowedToInsertNewline_InputWidget_(d) ? insertNewlines_SystemTextInputFlag : 0) |
1178 (d->inFlags & selectAllOnFocus_InputWidgetFlag ? selectAll_SystemTextInputFlags : 0)); 1185 (d->inFlags & selectAllOnFocus_InputWidgetFlag ? selectAll_SystemTextInputFlags : 0));
1179 setFont_SystemTextInput(d->sysCtrl, d->font); 1186 setFont_SystemTextInput(d->sysCtrl, d->font);
1180 setText_SystemTextInput(d->sysCtrl, &d->oldText); 1187 setText_SystemTextInput(d->sysCtrl, &d->oldText, iFalse);
1181 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d); 1188 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d);
1182 iConnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_); 1189 iConnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_);
1183 updateTextInputRect_InputWidget_(d); 1190 updateTextInputRect_InputWidget_(d);
@@ -2157,10 +2164,6 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
2157 } 2164 }
2158 return iTrue; 2165 return iTrue;
2159 } 2166 }
2160 else if (isCommand_UserEvent(ev, "input.selectall") && isEditing_InputWidget_(d)) {
2161 selectAll_InputWidget(d);
2162 return iTrue;
2163 }
2164 else if (isCommand_UserEvent(ev, "text.insert")) { 2167 else if (isCommand_UserEvent(ev, "text.insert")) {
2165 pushUndo_InputWidget_(d); 2168 pushUndo_InputWidget_(d);
2166 deleteMarked_InputWidget_(d); 2169 deleteMarked_InputWidget_(d);
@@ -2169,6 +2172,10 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
2169 return iTrue; 2172 return iTrue;
2170 } 2173 }
2171#endif 2174#endif
2175 else if (isCommand_UserEvent(ev, "input.selectall") && isEditing_InputWidget_(d)) {
2176 selectAll_InputWidget(d);
2177 return iTrue;
2178 }
2172 else if (isCommand_UserEvent(ev, "theme.changed")) { 2179 else if (isCommand_UserEvent(ev, "theme.changed")) {
2173 if (d->buffered) { 2180 if (d->buffered) {
2174 d->inFlags |= needUpdateBuffer_InputWidgetFlag; 2181 d->inFlags |= needUpdateBuffer_InputWidgetFlag;