summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 16098d83..c1232d13 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -1744,7 +1744,6 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1744 showCursor_InputWidget_(d); 1744 showCursor_InputWidget_(d);
1745 refresh_Widget(w); 1745 refresh_Widget(w);
1746 return iTrue; 1746 return iTrue;
1747#if 0
1748 case SDLK_d: 1747 case SDLK_d:
1749 if (mods != KMOD_CTRL) break; 1748 if (mods != KMOD_CTRL) break;
1750 case SDLK_DELETE: 1749 case SDLK_DELETE:
@@ -1755,14 +1754,18 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1755 } 1754 }
1756 else if (mods & byWord_KeyModifier) { 1755 else if (mods & byWord_KeyModifier) {
1757 pushUndo_InputWidget_(d); 1756 pushUndo_InputWidget_(d);
1758 d->mark.start = d->cursor; 1757 d->mark.start = cursorToIndex_InputWidget_(d, d->cursor);
1759 d->mark.end = skipWord_InputWidget_(d, d->cursor, +1); 1758 d->mark.end = cursorToIndex_InputWidget_(d, skipWord_InputWidget_(d, d->cursor, +1));
1760 deleteMarked_InputWidget_(d); 1759 deleteMarked_InputWidget_(d);
1761 contentsWereChanged_InputWidget_(d); 1760 contentsWereChanged_InputWidget_(d);
1762 } 1761 }
1763 else if (d->cursor < size_Array(&d->text)) { 1762 else if (!isEqual_I2(d->cursor, curMax)) {//} < size_Array(&d->text)) {
1764 pushUndo_InputWidget_(d); 1763 pushUndo_InputWidget_(d);
1765 remove_Array(&d->text, d->cursor); 1764 //remove_Array(&d->text, d->cursor);
1765 deleteIndexRange_InputWidget_(d, (iRanges){
1766 cursorToIndex_InputWidget_(d, d->cursor),
1767 cursorToIndex_InputWidget_(d, movedCursor_InputWidget_(d, d->cursor, +1, 0))
1768 });
1766 contentsWereChanged_InputWidget_(d); 1769 contentsWereChanged_InputWidget_(d);
1767 } 1770 }
1768 showCursor_InputWidget_(d); 1771 showCursor_InputWidget_(d);
@@ -1777,7 +1780,12 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1777 } 1780 }
1778 else { 1781 else {
1779 pushUndo_InputWidget_(d); 1782 pushUndo_InputWidget_(d);
1780 removeN_Array(&d->text, d->cursor, size_Array(&d->text) - d->cursor); 1783 iInputLine *line = cursorLine_InputWidget_(d);
1784 truncate_String(&line->text, d->cursor.x);
1785 if (!isLastLine_InputWidget_(d, line)) {
1786 appendCStr_String(&line->text, "\n"); /* must have a newline */
1787 }
1788 lineTextWasChanged_InputWidget_(d, line);
1781 contentsWereChanged_InputWidget_(d); 1789 contentsWereChanged_InputWidget_(d);
1782 } 1790 }
1783 showCursor_InputWidget_(d); 1791 showCursor_InputWidget_(d);
@@ -1785,7 +1793,6 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1785 return iTrue; 1793 return iTrue;
1786 } 1794 }
1787 break; 1795 break;
1788#endif
1789 case SDLK_HOME: 1796 case SDLK_HOME:
1790 case SDLK_END: 1797 case SDLK_END:
1791 if (mods == KMOD_PRIMARY || mods == (KMOD_PRIMARY | KMOD_SHIFT)) { 1798 if (mods == KMOD_PRIMARY || mods == (KMOD_PRIMARY | KMOD_SHIFT)) {
@@ -1954,8 +1961,8 @@ static void draw_InputWidget_(const iInputWidget *d) {
1954 .maxWidth = width_Rect(contentBounds), 1961 .maxWidth = width_Rect(contentBounds),
1955 .mode = (d->inFlags & isUrl_InputWidgetFlag ? anyCharacter_WrapTextMode : word_WrapTextMode) 1962 .mode = (d->inFlags & isUrl_InputWidgetFlag ? anyCharacter_WrapTextMode : word_WrapTextMode)
1956 }; 1963 };
1957 const iRangei visLines = visibleLineRange_InputWidget_(d); 1964 const iRangei visLines = visibleLineRange_InputWidget_(d);
1958 const int visLineOffsetY = visLineOffsetY_InputWidget_(d); 1965 const int visLineOffsetY = visLineOffsetY_InputWidget_(d);
1959 /* If buffered, just draw the buffered copy. */ 1966 /* If buffered, just draw the buffered copy. */
1960 if (d->buffered && !isFocused) { 1967 if (d->buffered && !isFocused) {
1961 /* Most input widgets will use this, since only one is focused at a time. */ 1968 /* Most input widgets will use this, since only one is focused at a time. */