Kaydet (Commit) 1c68618e authored tarafından Nick Treleaven's avatar Nick Treleaven

Undo r1891 so that 'Delete lines' again includes the cursor line

even when at the start of a line - like Cut/Copy lines do.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1894 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 3baa7d8f
2007-09-20 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
2007-09-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.c, src/editor.c:
Undo r1891 so that 'Delete lines' again includes the cursor line
even when at the start of a line - like Cut/Copy lines do.
2007-09-21 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/editor.c:
Make 'Select lines' not include an extra line when whole lines are
selected.
Make 'Delete lines' not include an extra line when whole lines are
selected.
* src/keybindings.c, src/callbacks.c:
......
......@@ -2317,21 +2317,24 @@ void editor_select_word(ScintillaObject *sci)
void editor_select_lines(ScintillaObject *sci)
{
gint start, end;
gint start, end, line;
g_return_if_fail(sci != NULL);
start = sci_get_selection_start(sci);
start = sci_get_line_from_position(sci, start);
start = sci_get_position_from_line(sci, start);
end = sci_get_selection_end(sci);
if (start == end || sci_get_col_from_position(sci, end) > 0) // partially selected line
{
gint line = sci_get_line_from_position(sci, end);
end = sci_get_position_from_line(sci, line + 1);
}
if (start != end &&
sci_get_col_from_position(sci, start) == 0 &&
sci_get_col_from_position(sci, end) == 0)
return; // whole lines already selected
line = sci_get_line_from_position(sci, start);
start = sci_get_position_from_line(sci, line);
line = sci_get_line_from_position(sci, end);
end = sci_get_position_from_line(sci, line + 1);
SSM(sci, SCI_SETSEL, start, end);
}
......
......@@ -1119,7 +1119,7 @@ static void cb_func_edit_global(guint key_id)
}
static void duplicate_line(ScintillaObject *sci)
static void duplicate_lines(ScintillaObject *sci)
{
if (sci_get_lines_selected(sci) > 1)
{
......@@ -1133,6 +1133,16 @@ static void duplicate_line(ScintillaObject *sci)
}
static void delete_lines(ScintillaObject *sci)
{
// include last line (like cut lines, copy lines do):
sci_set_selection_end(sci, sci_get_selection_end(sci) + 1);
editor_select_lines(sci);
sci_clear(sci); // SCI_LINEDELETE only does 1 line
}
// common function for editing keybindings, only valid when scintilla has focus.
static void cb_func_edit(guint key_id)
{
......@@ -1154,12 +1164,10 @@ static void cb_func_edit(guint key_id)
sci_cmd(doc_list[idx].sci, SCI_LINESCROLLDOWN);
break;
case GEANY_KEYS_EDIT_DUPLICATELINE:
duplicate_line(doc_list[idx].sci);
duplicate_lines(doc_list[idx].sci);
break;
case GEANY_KEYS_EDIT_DELETELINE:
// SCI_LINEDELETE only does 1 line
editor_select_lines(doc_list[idx].sci);
sci_clear(doc_list[idx].sci);
delete_lines(doc_list[idx].sci);
break;
case GEANY_KEYS_EDIT_COPYLINE:
sci_cmd(doc_list[idx].sci, SCI_LINECOPY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment