Fix Text editor home/end keys when theres a selection
This commit is contained in:
@@ -85,6 +85,7 @@ void txt_delete_char (struct Text *text);
|
||||
void txt_delete_word (struct Text *text);
|
||||
void txt_delete_selected (struct Text *text);
|
||||
void txt_sel_all (struct Text *text);
|
||||
void txt_sel_clear (struct Text *text);
|
||||
void txt_sel_line (struct Text *text);
|
||||
char *txt_sel_to_buf (struct Text *text);
|
||||
void txt_insert_buf (struct Text *text, const char *in_buffer);
|
||||
|
||||
@@ -1286,6 +1286,19 @@ void txt_sel_all(Text *text)
|
||||
text->selc = text->sell->len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse of #txt_pop_sel
|
||||
* Clears the selection and ensures the cursor is located
|
||||
* at the selection (where the cursor is visually while editing).
|
||||
*/
|
||||
void txt_sel_clear(Text *text)
|
||||
{
|
||||
if (text->sell) {
|
||||
text->curl = text->sell;
|
||||
text->curc = text->selc;
|
||||
}
|
||||
}
|
||||
|
||||
void txt_sel_line(Text *text)
|
||||
{
|
||||
if (!text) return;
|
||||
|
||||
@@ -1825,11 +1825,17 @@ static int text_move_cursor(bContext *C, int type, bool select)
|
||||
|
||||
switch (type) {
|
||||
case LINE_BEGIN:
|
||||
if (!select) {
|
||||
txt_sel_clear(text);
|
||||
}
|
||||
if (st && st->wordwrap && ar) txt_wrap_move_bol(st, ar, select);
|
||||
else txt_move_bol(text, select);
|
||||
break;
|
||||
|
||||
case LINE_END:
|
||||
if (!select) {
|
||||
txt_sel_clear(text);
|
||||
}
|
||||
if (st && st->wordwrap && ar) txt_wrap_move_eol(st, ar, select);
|
||||
else txt_move_eol(text, select);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user