[Return] will replace selection.

This commit is contained in:
Michael Drake 2013-02-09 14:43:21 +00:00
parent b4609f41bc
commit 8c3e0cf81a
1 changed files with 18 additions and 5 deletions

View File

@ -1722,11 +1722,24 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
case KEY_NL:
if (readonly)
break;
if(!textarea_insert_text(ta, caret, "\n", 1))
return false;
caret++;
ta->sel_start = ta->sel_end = -1;
redraw = true;
if (ta->sel_start != -1) {
if (!textarea_replace_text(ta,
ta->sel_start, ta->sel_end,
"\n", 1, false))
return false;
caret = ta->sel_start + 1;
ta->sel_start = ta->sel_end = -1;
redraw = true;
} else {
if (!textarea_replace_text(ta,
caret, caret,
"\n", 1, false))
return false;
caret++;
redraw = true;
}
break;
case KEY_CUT_LINE:
break;