Add keybinding for Select, Transpose, Cut, Copy and Delete line.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1674 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2007-07-07 15:12:13 +00:00
parent 1a4fc52ec5
commit 7b99a9f325
7 changed files with 80 additions and 3 deletions

View File

@ -2,6 +2,9 @@
* src/editor.c: * src/editor.c:
Include new line character(s) when selecting a paragraph. Include new line character(s) when selecting a paragraph.
* doc/geany.docbook, src/document.c, src/editor.c, src/editor.h,
src/keybindings.c, src/keybindings.h:
Add keybinding for Select, Transpose, Cut, Copy and Delete line.
2007-07-07 Nick Treleaven <nick.treleaven@btinternet.com> 2007-07-07 Nick Treleaven <nick.treleaven@btinternet.com>

View File

@ -1850,6 +1850,26 @@ widget "GeanyPrefsDialog" style "geanyStyle"
<entry>Duplicate line or selection</entry> <entry>Duplicate line or selection</entry>
<entry>Duplicates the current line or selection.</entry> <entry>Duplicates the current line or selection.</entry>
</row> </row>
<row>
<entry>Delete current line</entry>
<entry>Deletes the current line.
</entry>
</row>
<row>
<entry>Cut current line</entry>
<entry>Cuts the current line.
</entry>
</row>
<row>
<entry>Copy current line</entry>
<entry>Copies the current line into the clipboard.
</entry>
</row>
<row>
<entry>Transpose current line</entry>
<entry>Transposes the current line with the previous one.
</entry>
</row>
<row> <row>
<entry>Comment line</entry> <entry>Comment line</entry>
<entry>Comments current line or selection.</entry> <entry>Comments current line or selection.</entry>
@ -1936,6 +1956,11 @@ widget "GeanyPrefsDialog" style "geanyStyle"
defined by two empty lines around it. defined by two empty lines around it.
</entry> </entry>
</row> </row>
<row>
<entry>Select current line</entry>
<entry>Selects the current line under the cursor..
</entry>
</row>
<row> <row>
<entry>Insert alternative whitespace</entry> <entry>Insert alternative whitespace</entry>
<entry>Inserts a tabulator character when spaces should be used for <entry>Inserts a tabulator character when spaces should be used for

View File

@ -301,8 +301,12 @@ static gint document_create_new_sci(const gchar *filename)
sci_use_popup(sci, FALSE); sci_use_popup(sci, FALSE);
sci_assign_cmdkey(sci, SCK_HOME, SCI_VCHOMEWRAP); sci_assign_cmdkey(sci, SCK_HOME, SCI_VCHOMEWRAP);
sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP); sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP);
// disable select all to be able to redefine it // disable some Scintilla keybinsings to be able to redefine it
sci_clear_cmdkey(sci, 'A' | (SCMOD_CTRL << 16)); sci_clear_cmdkey(sci, 'A' | (SCMOD_CTRL << 16)); // select all
sci_clear_cmdkey(sci, 'T' | (SCMOD_CTRL << 16)); // line transpose
sci_clear_cmdkey(sci, 'L' | (SCMOD_CTRL << 16)); // line cut
sci_clear_cmdkey(sci, 'L' | (SCMOD_CTRL << 16) | (SCMOD_SHIFT << 16)); // line delete
sci_clear_cmdkey(sci, 'T' | (SCMOD_CTRL << 16) | (SCMOD_SHIFT << 16)); // line copy
document_apply_update_prefs(new_idx); document_apply_update_prefs(new_idx);

View File

@ -2351,6 +2351,22 @@ void editor_select_word(ScintillaObject *sci)
} }
void editor_select_line(ScintillaObject *sci)
{
gint pos, line, start, end;
g_return_if_fail(sci != NULL);
pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0);
line = SSM(sci, SCI_LINEFROMPOSITION, pos, 0);
start = SSM(sci, SCI_POSITIONFROMLINE, line, TRUE);
end = SSM(sci, SCI_POSITIONFROMLINE, line + 1, TRUE);
SSM(sci, SCI_SETSEL, start, end);
}
/* find the start or end of a paragraph by searching all lines in direction (UP or DOWN) /* find the start or end of a paragraph by searching all lines in direction (UP or DOWN)
* starting at the given line and return the found line or return -1 if called on an empty line */ * starting at the given line and return the found line or return -1 if called on an empty line */
static gint find_paragraph_stop(ScintillaObject *sci, gint line, gint direction) static gint find_paragraph_stop(ScintillaObject *sci, gint line, gint direction)

View File

@ -136,6 +136,8 @@ void editor_insert_multiline_comment(gint idx);
void editor_select_word(ScintillaObject *sci); void editor_select_word(ScintillaObject *sci);
void editor_select_line(ScintillaObject *sci);
void editor_select_paragraph(ScintillaObject *sci); void editor_select_paragraph(ScintillaObject *sci);
void editor_insert_alternative_whitespace(ScintillaObject *sci); void editor_insert_alternative_whitespace(ScintillaObject *sci);

View File

@ -171,7 +171,7 @@ void keybindings_init(void)
keys[GEANY_KEYS_MENU_NEXTMESSAGE] = fill(cb_func_menu_nextmessage, keys[GEANY_KEYS_MENU_NEXTMESSAGE] = fill(cb_func_menu_nextmessage,
0, 0, "menu_nextmessage", _("Next Message")); 0, 0, "menu_nextmessage", _("Next Message"));
keys[GEANY_KEYS_MENU_GOTOLINE] = fill(cb_func_menu_gotoline, keys[GEANY_KEYS_MENU_GOTOLINE] = fill(cb_func_menu_gotoline,
GDK_j, GDK_CONTROL_MASK, "menu_gotoline", _("Go to line")); GDK_l, GDK_CONTROL_MASK, "menu_gotoline", _("Go to line"));
keys[GEANY_KEYS_MENU_TOGGLEALL] = fill(cb_func_menu_toggle_all, keys[GEANY_KEYS_MENU_TOGGLEALL] = fill(cb_func_menu_toggle_all,
0, 0, "menu_toggleall", _("Toggle all additional widgets")); 0, 0, "menu_toggleall", _("Toggle all additional widgets"));
@ -244,6 +244,14 @@ void keybindings_init(void)
keys[GEANY_KEYS_EDIT_DUPLICATELINE] = fill(cb_func_edit, keys[GEANY_KEYS_EDIT_DUPLICATELINE] = fill(cb_func_edit,
GDK_d, GDK_CONTROL_MASK, "edit_duplicateline", _("Duplicate line or selection")); GDK_d, GDK_CONTROL_MASK, "edit_duplicateline", _("Duplicate line or selection"));
keys[GEANY_KEYS_EDIT_DELETELINE] = fill(cb_func_edit,
GDK_k, GDK_CONTROL_MASK, "edit_deleteline", _("Delete current line"));
keys[GEANY_KEYS_EDIT_COPYLINE] = fill(cb_func_edit,
GDK_k, GDK_MOD1_MASK | GDK_SHIFT_MASK, "edit_copyline", _("Copy current line"));
keys[GEANY_KEYS_EDIT_CUTLINE] = fill(cb_func_edit,
GDK_k, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "edit_cutline", _("Cut current line"));
keys[GEANY_KEYS_EDIT_TRANSPOSELINE] = fill(cb_func_edit,
GDK_t, GDK_CONTROL_MASK, "edit_transposeline", _("Transpose current line"));
keys[GEANY_KEYS_EDIT_TOLOWERCASE] = fill(cb_func_edit, keys[GEANY_KEYS_EDIT_TOLOWERCASE] = fill(cb_func_edit,
GDK_u, GDK_CONTROL_MASK, "edit_tolowercase", _("Convert Selection to lower-case")); GDK_u, GDK_CONTROL_MASK, "edit_tolowercase", _("Convert Selection to lower-case"));
keys[GEANY_KEYS_EDIT_TOUPPERCASE] = fill(cb_func_edit, keys[GEANY_KEYS_EDIT_TOUPPERCASE] = fill(cb_func_edit,
@ -290,6 +298,8 @@ void keybindings_init(void)
keys[GEANY_KEYS_EDIT_SELECTWORD] = fill(cb_func_edit, keys[GEANY_KEYS_EDIT_SELECTWORD] = fill(cb_func_edit,
GDK_w, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectword", _("Select current word")); GDK_w, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectword", _("Select current word"));
keys[GEANY_KEYS_EDIT_SELECTLINE] = fill(cb_func_edit,
GDK_l, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectline", _("Select current line"));
keys[GEANY_KEYS_EDIT_SELECTPARAGRAPH] = fill(cb_func_edit, keys[GEANY_KEYS_EDIT_SELECTPARAGRAPH] = fill(cb_func_edit,
GDK_p, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectparagraph", _("Select current paragraph")); GDK_p, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectparagraph", _("Select current paragraph"));
@ -1095,6 +1105,15 @@ static void cb_func_edit(guint key_id)
case GEANY_KEYS_EDIT_DUPLICATELINE: case GEANY_KEYS_EDIT_DUPLICATELINE:
on_menu_duplicate_line1_activate(NULL, NULL); on_menu_duplicate_line1_activate(NULL, NULL);
break; break;
case GEANY_KEYS_EDIT_DELETELINE:
sci_cmd(doc_list[idx].sci, SCI_LINEDELETE);
break;
case GEANY_KEYS_EDIT_CUTLINE:
sci_cmd(doc_list[idx].sci, SCI_LINECUT);
break;
case GEANY_KEYS_EDIT_TRANSPOSELINE:
sci_cmd(doc_list[idx].sci, SCI_LINETRANSPOSE);
break;
case GEANY_KEYS_EDIT_COMMENTLINETOGGLE: case GEANY_KEYS_EDIT_COMMENTLINETOGGLE:
on_menu_toggle_line_commentation1_activate(NULL, NULL); on_menu_toggle_line_commentation1_activate(NULL, NULL);
break; break;
@ -1131,6 +1150,9 @@ static void cb_func_edit(guint key_id)
case GEANY_KEYS_EDIT_SELECTWORD: case GEANY_KEYS_EDIT_SELECTWORD:
editor_select_word(doc_list[idx].sci); editor_select_word(doc_list[idx].sci);
break; break;
case GEANY_KEYS_EDIT_SELECTLINE:
editor_select_line(doc_list[idx].sci);
break;
case GEANY_KEYS_EDIT_SELECTPARAGRAPH: case GEANY_KEYS_EDIT_SELECTPARAGRAPH:
editor_select_paragraph(doc_list[idx].sci); editor_select_paragraph(doc_list[idx].sci);
break; break;

View File

@ -115,6 +115,10 @@ enum
GEANY_KEYS_EDIT_TOLOWERCASE, GEANY_KEYS_EDIT_TOLOWERCASE,
GEANY_KEYS_EDIT_TOUPPERCASE, GEANY_KEYS_EDIT_TOUPPERCASE,
GEANY_KEYS_EDIT_DUPLICATELINE, GEANY_KEYS_EDIT_DUPLICATELINE,
GEANY_KEYS_EDIT_DELETELINE,
GEANY_KEYS_EDIT_COPYLINE,
GEANY_KEYS_EDIT_CUTLINE,
GEANY_KEYS_EDIT_TRANSPOSELINE,
GEANY_KEYS_EDIT_COMMENTLINETOGGLE, GEANY_KEYS_EDIT_COMMENTLINETOGGLE,
GEANY_KEYS_EDIT_COMMENTLINE, GEANY_KEYS_EDIT_COMMENTLINE,
GEANY_KEYS_EDIT_UNCOMMENTLINE, GEANY_KEYS_EDIT_UNCOMMENTLINE,
@ -128,6 +132,7 @@ enum
GEANY_KEYS_EDIT_GOTONEXTMARKER, GEANY_KEYS_EDIT_GOTONEXTMARKER,
GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER, GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER,
GEANY_KEYS_EDIT_SELECTWORD, GEANY_KEYS_EDIT_SELECTWORD,
GEANY_KEYS_EDIT_SELECTLINE,
GEANY_KEYS_EDIT_SELECTPARAGRAPH, GEANY_KEYS_EDIT_SELECTPARAGRAPH,
GEANY_KEYS_EDIT_INSERTALTWHITESPACE, GEANY_KEYS_EDIT_INSERTALTWHITESPACE,