Add Goto Previous/Next Marker keybindings (Ctrl-, and Ctrl-.).
Make sci_marker_next() and sci_marker_previous() return marker line number. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1397 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
b364ea0cd5
commit
3293150f92
@ -1,3 +1,12 @@
|
||||
2007-03-15 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||
|
||||
* src/keybindings.c, src/keybindings.h, src/sciwrappers.c,
|
||||
src/sciwrappers.h:
|
||||
Add Goto Previous/Next Marker keybindings (Ctrl-, and Ctrl-.).
|
||||
Make sci_marker_next() and sci_marker_previous() return marker line
|
||||
number.
|
||||
|
||||
|
||||
2007-03-14 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||
|
||||
* src/callbacks.c:
|
||||
|
@ -239,6 +239,12 @@ void keybindings_init(void)
|
||||
keys[GEANY_KEYS_EDIT_GOTOMATCHINGBRACE] = fill(cb_func_edit,
|
||||
GDK_less, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "edit_gotomatchingbrace",
|
||||
_("Goto matching brace"));
|
||||
keys[GEANY_KEYS_EDIT_GOTONEXTMARKER] = fill(cb_func_edit,
|
||||
GDK_period, GDK_CONTROL_MASK, "edit_gotonextmarker",
|
||||
_("Goto next marker"));
|
||||
keys[GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER] = fill(cb_func_edit,
|
||||
GDK_comma, GDK_CONTROL_MASK, "edit_gotopreviousmarker",
|
||||
_("Goto previous marker"));
|
||||
keys[GEANY_KEYS_EDIT_AUTOCOMPLETE] = fill(cb_func_edit,
|
||||
GDK_space, GDK_CONTROL_MASK, "edit_autocomplete", _("Complete word"));
|
||||
#ifdef G_OS_WIN32
|
||||
@ -819,11 +825,14 @@ static void goto_matching_brace(gint idx)
|
||||
static void cb_func_edit(guint key_id)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
gint cur_line;
|
||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(app->window));
|
||||
|
||||
// edit keybindings only valid when scintilla widget has focus
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(doc_list[idx].sci)) return;
|
||||
|
||||
cur_line = sci_get_current_line(doc_list[idx].sci, -1);
|
||||
|
||||
switch (key_id)
|
||||
{
|
||||
case GEANY_KEYS_EDIT_DUPLICATELINE:
|
||||
@ -859,6 +868,28 @@ static void cb_func_edit(guint key_id)
|
||||
case GEANY_KEYS_EDIT_GOTOMATCHINGBRACE:
|
||||
goto_matching_brace(idx);
|
||||
break;
|
||||
case GEANY_KEYS_EDIT_GOTONEXTMARKER:
|
||||
{
|
||||
gint mline = sci_marker_next(doc_list[idx].sci, cur_line + 1, 1 << 1, TRUE);
|
||||
|
||||
if (mline != -1)
|
||||
{
|
||||
sci_goto_line(doc_list[idx].sci, mline, TRUE);
|
||||
doc_list[idx].scroll_percent = 0.5F;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER:
|
||||
{
|
||||
gint mline = sci_marker_previous(doc_list[idx].sci, cur_line - 1, 1 << 1, TRUE);
|
||||
|
||||
if (mline != -1)
|
||||
{
|
||||
sci_goto_line(doc_list[idx].sci, mline, TRUE);
|
||||
doc_list[idx].scroll_percent = 0.5F;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GEANY_KEYS_EDIT_TOLOWERCASE:
|
||||
on_to_lower_case1_activate(NULL, NULL);
|
||||
break;
|
||||
|
@ -105,6 +105,8 @@ enum
|
||||
GEANY_KEYS_EDIT_SENDTOCMD2,
|
||||
GEANY_KEYS_EDIT_SENDTOCMD3,
|
||||
GEANY_KEYS_EDIT_GOTOMATCHINGBRACE,
|
||||
GEANY_KEYS_EDIT_GOTONEXTMARKER,
|
||||
GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER,
|
||||
GEANY_KEYS_EDIT_AUTOCOMPLETE,
|
||||
GEANY_KEYS_EDIT_CALLTIP,
|
||||
GEANY_KEYS_EDIT_MACROLIST,
|
||||
|
@ -331,33 +331,36 @@ gboolean sci_is_marker_set_at_line(ScintillaObject* sci, gint line, gint marker)
|
||||
}
|
||||
|
||||
|
||||
gboolean sci_marker_next(ScintillaObject* sci, gint line, gint marker_mask)
|
||||
/* Returns the line number of the next marker that matches marker_mask, or -1.
|
||||
* marker_mask is a bitor of 1 << marker_index. (See MarkerHandleSet::MarkValue()).
|
||||
* Note: If there is a marker on the line, it returns the same line. */
|
||||
gint sci_marker_next(ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap)
|
||||
{
|
||||
gint marker_line;
|
||||
|
||||
marker_line = SSM(sci, SCI_MARKERNEXT, line, marker_mask);
|
||||
|
||||
if( marker_line != -1 ){
|
||||
SSM(sci,SCI_GOTOLINE,marker_line,0);
|
||||
return TRUE;
|
||||
}else{
|
||||
return FALSE;
|
||||
}
|
||||
if (wrap && marker_line == -1)
|
||||
marker_line = SSM(sci, SCI_MARKERNEXT, 0, marker_mask);
|
||||
return marker_line;
|
||||
}
|
||||
|
||||
|
||||
gboolean sci_marker_prev(ScintillaObject* sci, gint line, gint marker_mask)
|
||||
/* Returns the line number of the previous marker that matches marker_mask, or -1.
|
||||
* marker_mask is a bitor of 1 << marker_index. (See MarkerHandleSet::MarkValue()).
|
||||
* Note: If there is a marker on the line, it returns the same line. */
|
||||
gint sci_marker_previous(ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap)
|
||||
{
|
||||
gint marker_line;
|
||||
|
||||
marker_line = SSM(sci, SCI_MARKERPREVIOUS, line, marker_mask);
|
||||
if (wrap && marker_line == -1)
|
||||
{
|
||||
gint len = sci_get_length(sci);
|
||||
gint last_line = sci_get_line_from_position(sci, len - 1);
|
||||
|
||||
if( marker_line != -1 ){
|
||||
SSM(sci,SCI_GOTOLINE,marker_line,0);
|
||||
return TRUE;
|
||||
}else{
|
||||
return FALSE;
|
||||
marker_line = SSM(sci, SCI_MARKERPREVIOUS, last_line, marker_mask);
|
||||
}
|
||||
return marker_line;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,8 +62,8 @@ void sci_zoom_out (ScintillaObject* sci);
|
||||
void sci_zoom_off (ScintillaObject* sci);
|
||||
void sci_set_marker_at_line (ScintillaObject* sci, gint line_number, gboolean set, gint marker );
|
||||
gboolean sci_is_marker_set_at_line (ScintillaObject* sci, gint line, gint marker);
|
||||
gboolean sci_marker_next (ScintillaObject* sci, gint line, gint marker_mask);
|
||||
gboolean sci_marker_prev (ScintillaObject* sci, gint line, gint marker_mask);
|
||||
gint sci_marker_next (ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap);
|
||||
gint sci_marker_previous (ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap);
|
||||
|
||||
gint sci_get_col_from_position (ScintillaObject* sci, gint position);
|
||||
gint sci_get_line_from_position (ScintillaObject* sci, gint position);
|
||||
|
Loading…
x
Reference in New Issue
Block a user