Added different auto indention modes to select who should Geany indent new lines (closes #1615605).
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1373 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
3948762be3
commit
9dc61832fc
@ -11,6 +11,12 @@
|
||||
2007-03-08 Enrico Tröger <enrico.troeger@uvena.de>
|
||||
|
||||
* geany.glade, src/interface.c: Fixed wrong tooltip.
|
||||
* geany.glade, doc/geany.docbook, src/document.c, src/document.h,
|
||||
src/geany.h, src/interface.c, src/keyfile.c, src/main.c, src/prefs.c,
|
||||
src/sci_cb.c, src/ui_utils.c:
|
||||
Added different auto indention modes to select who should Geany
|
||||
indent new lines (closes #1615605).
|
||||
|
||||
|
||||
|
||||
2007-03-06 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<!ENTITY appversion "0.11">
|
||||
<!ENTITY appurl "http://geany.uvena.de">
|
||||
<!ENTITY author_mail "enrico.troeger@uvena.de">
|
||||
<!ENTITY date "February 18, 2007">
|
||||
<!ENTITY date "March 08, 2007">
|
||||
<!ENTITY legal SYSTEM "geany_gpl.docbook">
|
||||
<!ENTITY scikeybinding SYSTEM "scikeybinding.docbook">
|
||||
]>
|
||||
@ -380,6 +380,37 @@
|
||||
was copied to the new position.
|
||||
</para>
|
||||
</section>
|
||||
<section id="general_indention">
|
||||
<title>Auto indention</title>
|
||||
<para>
|
||||
<application>Geany</application> knows three types of auto indention:
|
||||
None, Basic and Advanced.
|
||||
<variablelist><title>Auto indention types</title>
|
||||
<varlistentry><term>None</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Disables auto indention completely.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry><term>Basic</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Adds the same amount of whitespace on a new line as on the last line.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry><term>Advanced</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Does the same as Basic but also indents curly brackets and adds a tabulator
|
||||
character (or spaces) on a new line after an opening '{' brace.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</section>
|
||||
<section id="general_vte">
|
||||
<title>Virtual terminal emulator widget (VTE)</title>
|
||||
<para>
|
||||
|
||||
63
geany.glade
63
geany.glade
@ -5311,17 +5311,60 @@ Bottom
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="check_auto_indent">
|
||||
<widget class="GtkHBox" id="hbox7">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Add the same indentation as the previous line after pressing enter</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Auto indentation</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label183">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Auto indention mode:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEventBox" id="eventbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Selects the indention mode. Use None to disable auto indention completely. Basic indents new lines with the same indention as the previous line. Advanced does the same and indents also curly brackets.</property>
|
||||
<property name="visible_window">True</property>
|
||||
<property name="above_child">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="combo_auto_indent_mode">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">None
|
||||
Basic
|
||||
Advanced</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
||||
@ -194,8 +194,9 @@ void document_set_text_changed(gint idx)
|
||||
|
||||
|
||||
// Apply just the prefs that can change in the Preferences dialog
|
||||
void document_apply_update_prefs(ScintillaObject *sci)
|
||||
void document_apply_update_prefs(gint idx)
|
||||
{
|
||||
ScintillaObject *sci = doc_list[idx].sci;
|
||||
sci_set_mark_long_lines(sci, app->long_line_type, app->long_line_column, app->long_line_color);
|
||||
|
||||
sci_set_tab_width(sci, app->pref_editor_tab_width);
|
||||
@ -208,6 +209,8 @@ void document_apply_update_prefs(ScintillaObject *sci)
|
||||
sci_set_visible_eols(sci, app->pref_editor_show_line_endings);
|
||||
|
||||
sci_set_folding_margin_visible(sci, app->pref_editor_folding);
|
||||
|
||||
doc_list[idx].use_auto_indention = (app->pref_editor_indention_mode != INDENT_NONE);
|
||||
}
|
||||
|
||||
|
||||
@ -217,7 +220,7 @@ static void init_doc_struct(document *new_doc)
|
||||
{
|
||||
new_doc->is_valid = FALSE;
|
||||
new_doc->has_tags = FALSE;
|
||||
new_doc->use_auto_indention = app->pref_editor_use_auto_indention;
|
||||
new_doc->use_auto_indention = (app->pref_editor_indention_mode != INDENT_NONE);
|
||||
new_doc->line_breaking = app->pref_editor_line_breaking;
|
||||
new_doc->readonly = FALSE;
|
||||
new_doc->tag_store = NULL;
|
||||
@ -296,7 +299,7 @@ static gint document_create_new_sci(const gchar *filename)
|
||||
// disable select all to be able to redefine it
|
||||
sci_clear_cmdkey(sci, 'A' | (SCMOD_CTRL << 16));
|
||||
|
||||
document_apply_update_prefs(sci);
|
||||
document_apply_update_prefs(new_idx);
|
||||
|
||||
sci_set_tab_indents(sci, app->use_tab_to_indent);
|
||||
sci_set_symbol_margin(sci, app->show_markers_margin);
|
||||
@ -331,7 +334,7 @@ static gint document_create_new_sci(const gchar *filename)
|
||||
this->last_check = time(NULL);
|
||||
this->readonly = FALSE;
|
||||
this->line_breaking = app->pref_editor_line_breaking;
|
||||
this->use_auto_indention = app->pref_editor_use_auto_indention;
|
||||
this->use_auto_indention = (app->pref_editor_indention_mode != INDENT_NONE);
|
||||
this->has_tags = FALSE;
|
||||
|
||||
treeviews_openfiles_add(new_idx); // sets this->iter
|
||||
|
||||
@ -120,7 +120,7 @@ void document_set_text_changed(gint idx);
|
||||
|
||||
|
||||
// Apply just the prefs that can change in the Preferences dialog
|
||||
void document_apply_update_prefs(ScintillaObject *sci);
|
||||
void document_apply_update_prefs(gint idx);
|
||||
|
||||
|
||||
/* removes the given notebook tab and clears the related entry in the document list */
|
||||
|
||||
12
src/geany.h
12
src/geany.h
@ -105,7 +105,7 @@ typedef struct MyApp
|
||||
// I know, it is a bit confusing, but this line breaking is globally,
|
||||
// to change the default value at startup, I think
|
||||
gboolean pref_editor_line_breaking;
|
||||
gboolean pref_editor_use_auto_indention;
|
||||
gint pref_editor_indention_mode;
|
||||
gboolean pref_editor_use_indicators;
|
||||
gboolean pref_editor_show_white_space;
|
||||
gboolean pref_editor_show_indent_guide;
|
||||
@ -214,7 +214,15 @@ enum
|
||||
RIGHT
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
INDENT_NONE = 0,
|
||||
INDENT_BASIC,
|
||||
INDENT_ADVANCED
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
KILOBYTE = 1024,
|
||||
MEGABYTE = (KILOBYTE*1024),
|
||||
GIGABYTE = (MEGABYTE*1024)
|
||||
|
||||
@ -2454,7 +2454,10 @@ create_prefs_dialog (void)
|
||||
GtkWidget *frame14;
|
||||
GtkWidget *alignment17;
|
||||
GtkWidget *vbox17;
|
||||
GtkWidget *check_auto_indent;
|
||||
GtkWidget *hbox7;
|
||||
GtkWidget *label183;
|
||||
GtkWidget *eventbox2;
|
||||
GtkWidget *combo_auto_indent_mode;
|
||||
GtkWidget *check_line_wrapping;
|
||||
GtkWidget *check_folding;
|
||||
GtkWidget *check_unfold_children;
|
||||
@ -3327,10 +3330,25 @@ create_prefs_dialog (void)
|
||||
gtk_widget_show (vbox17);
|
||||
gtk_container_add (GTK_CONTAINER (alignment17), vbox17);
|
||||
|
||||
check_auto_indent = gtk_check_button_new_with_mnemonic (_("Auto indentation"));
|
||||
gtk_widget_show (check_auto_indent);
|
||||
gtk_box_pack_start (GTK_BOX (vbox17), check_auto_indent, FALSE, FALSE, 0);
|
||||
gtk_tooltips_set_tip (tooltips, check_auto_indent, _("Add the same indentation as the previous line after pressing enter"), NULL);
|
||||
hbox7 = gtk_hbox_new (FALSE, 0);
|
||||
gtk_widget_show (hbox7);
|
||||
gtk_box_pack_start (GTK_BOX (vbox17), hbox7, FALSE, FALSE, 0);
|
||||
|
||||
label183 = gtk_label_new (_("Auto indention mode:"));
|
||||
gtk_widget_show (label183);
|
||||
gtk_box_pack_start (GTK_BOX (hbox7), label183, FALSE, FALSE, 0);
|
||||
|
||||
eventbox2 = gtk_event_box_new ();
|
||||
gtk_widget_show (eventbox2);
|
||||
gtk_box_pack_start (GTK_BOX (hbox7), eventbox2, FALSE, TRUE, 5);
|
||||
gtk_tooltips_set_tip (tooltips, eventbox2, _("Selects the indention mode. Use None to disable auto indention completely. Basic indents new lines with the same indention as the previous line. Advanced does the same and indents also curly brackets."), NULL);
|
||||
|
||||
combo_auto_indent_mode = gtk_combo_box_new_text ();
|
||||
gtk_widget_show (combo_auto_indent_mode);
|
||||
gtk_container_add (GTK_CONTAINER (eventbox2), combo_auto_indent_mode);
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("None"));
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Basic"));
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Advanced"));
|
||||
|
||||
check_line_wrapping = gtk_check_button_new_with_mnemonic (_("Line wrapping"));
|
||||
gtk_widget_show (check_line_wrapping);
|
||||
@ -3902,7 +3920,10 @@ create_prefs_dialog (void)
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, frame14, "frame14");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment17, "alignment17");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox17, "vbox17");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, check_auto_indent, "check_auto_indent");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, hbox7, "hbox7");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, label183, "label183");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, eventbox2, "eventbox2");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, combo_auto_indent_mode, "combo_auto_indent_mode");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, check_line_wrapping, "check_line_wrapping");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, check_folding, "check_folding");
|
||||
GLADE_HOOKUP_OBJECT (prefs_dialog, check_unfold_children, "check_unfold_children");
|
||||
|
||||
@ -106,7 +106,7 @@ void configuration_save()
|
||||
g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", app->msgwindow_visible);
|
||||
g_key_file_set_boolean(config, PACKAGE, "use_folding", app->pref_editor_folding);
|
||||
g_key_file_set_boolean(config, PACKAGE, "unfold_all_children", app->pref_editor_unfold_all_children);
|
||||
g_key_file_set_boolean(config, PACKAGE, "use_auto_indention", app->pref_editor_use_auto_indention);
|
||||
g_key_file_set_integer(config, PACKAGE, "indention_mode", app->pref_editor_indention_mode);
|
||||
g_key_file_set_boolean(config, PACKAGE, "use_tab_to_indent", app->use_tab_to_indent);
|
||||
g_key_file_set_boolean(config, PACKAGE, "use_indicators", app->pref_editor_use_indicators);
|
||||
g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", app->pref_editor_show_indent_guide);
|
||||
@ -322,7 +322,7 @@ gboolean configuration_load()
|
||||
app->sidebar_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_visible", TRUE);
|
||||
app->msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
|
||||
app->pref_editor_line_breaking = utils_get_setting_boolean(config, PACKAGE, "line_breaking", FALSE); //default is off for better performance
|
||||
app->pref_editor_use_auto_indention = utils_get_setting_boolean(config, PACKAGE, "use_auto_indention", TRUE);
|
||||
app->pref_editor_indention_mode = utils_get_setting_integer(config, PACKAGE, "indention_mode", INDENT_ADVANCED);
|
||||
app->use_tab_to_indent = utils_get_setting_boolean(config, PACKAGE, "use_tab_to_indent", FALSE);
|
||||
app->pref_editor_use_indicators = utils_get_setting_boolean(config, PACKAGE, "use_indicators", TRUE);
|
||||
app->pref_editor_show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);
|
||||
|
||||
@ -209,7 +209,8 @@ static void apply_settings(void)
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
|
||||
lookup_widget(app->window, "menu_line_breaking1")), app->pref_editor_line_breaking);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
|
||||
lookup_widget(app->window, "menu_use_auto_indention1")), app->pref_editor_use_auto_indention);
|
||||
lookup_widget(app->window, "menu_use_auto_indention1")),
|
||||
(app->pref_editor_indention_mode != INDENT_NONE));
|
||||
app->ignore_callback = FALSE;
|
||||
|
||||
// connect the toolbar dropdown menus
|
||||
|
||||
16
src/prefs.c
16
src/prefs.c
@ -232,8 +232,8 @@ void prefs_init_dialog(void)
|
||||
widget = lookup_widget(app->prefs_dialog, "check_line_end");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_editor_show_line_endings);
|
||||
|
||||
widget = lookup_widget(app->prefs_dialog, "check_auto_indent");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_editor_use_auto_indention);
|
||||
widget = lookup_widget(app->prefs_dialog, "combo_auto_indent_mode");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), app->pref_editor_indention_mode);
|
||||
|
||||
widget = lookup_widget(app->prefs_dialog, "check_line_wrapping");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_editor_line_breaking);
|
||||
@ -550,8 +550,8 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
|
||||
widget = lookup_widget(app->prefs_dialog, "check_line_end");
|
||||
app->pref_editor_show_line_endings = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
|
||||
widget = lookup_widget(app->prefs_dialog, "check_auto_indent");
|
||||
app->pref_editor_use_auto_indention = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
widget = lookup_widget(app->prefs_dialog, "combo_auto_indent_mode");
|
||||
app->pref_editor_indention_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
|
||||
|
||||
widget = lookup_widget(app->prefs_dialog, "check_line_wrapping");
|
||||
app->pref_editor_line_breaking = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
@ -676,12 +676,14 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
|
||||
// re-colourise all open documents, if tab width or long line settings have changed
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid)
|
||||
if (DOC_IDX_VALID(i))
|
||||
{
|
||||
document_apply_update_prefs(doc_list[i].sci);
|
||||
if (! app->pref_editor_folding) document_unfold_all(i);
|
||||
document_apply_update_prefs(i);
|
||||
if (! app->pref_editor_folding)
|
||||
document_unfold_all(i);
|
||||
}
|
||||
}
|
||||
ui_document_show_hide(-1);
|
||||
|
||||
// store all settings
|
||||
configuration_save();
|
||||
|
||||
54
src/sci_cb.c
54
src/sci_cb.c
@ -248,7 +248,8 @@ void on_editor_notification(GtkWidget *editor, gint scn, gpointer lscn, gpointer
|
||||
}
|
||||
case ' ':
|
||||
{ // if and for autocompletion
|
||||
if (app->pref_editor_auto_complete_constructs) sci_cb_auto_forif(idx, pos);
|
||||
if (app->pref_editor_auto_complete_constructs)
|
||||
sci_cb_auto_forif(idx, pos);
|
||||
break;
|
||||
}
|
||||
case '[':
|
||||
@ -263,7 +264,9 @@ void on_editor_notification(GtkWidget *editor, gint scn, gpointer lscn, gpointer
|
||||
}
|
||||
case '}':
|
||||
{ // closing bracket handling
|
||||
if (doc_list[idx].use_auto_indention) sci_cb_close_block(idx, pos - 1);
|
||||
if (doc_list[idx].use_auto_indention &&
|
||||
app->pref_editor_indention_mode == INDENT_ADVANCED)
|
||||
sci_cb_close_block(idx, pos - 1);
|
||||
break;
|
||||
}
|
||||
default: sci_cb_start_auto_complete(idx, pos, FALSE);
|
||||
@ -334,23 +337,27 @@ static void on_new_line_added(ScintillaObject *sci, gint idx)
|
||||
get_indent(sci, pos, FALSE);
|
||||
sci_add_text(sci, indent);
|
||||
|
||||
// add extra indentation for Python after colon
|
||||
if (doc_list[idx].file_type->id == GEANY_FILETYPES_PYTHON &&
|
||||
sci_get_char_at(sci, pos - 2) == ':' &&
|
||||
sci_get_style_at(sci, pos - 2) == SCE_P_OPERATOR)
|
||||
{ // creates and inserts one tabulator sign or whitespace of the amount of the tab width
|
||||
gchar *text = utils_get_whitespace(app->pref_editor_tab_width);
|
||||
sci_add_text(sci, text);
|
||||
g_free(text);
|
||||
if (app->pref_editor_indention_mode == INDENT_ADVANCED)
|
||||
{
|
||||
// add extra indentation for Python after colon
|
||||
if (doc_list[idx].file_type->id == GEANY_FILETYPES_PYTHON &&
|
||||
sci_get_char_at(sci, pos - 2) == ':' &&
|
||||
sci_get_style_at(sci, pos - 2) == SCE_P_OPERATOR)
|
||||
{
|
||||
// creates and inserts one tabulator sign or whitespace of the amount of the tab width
|
||||
gchar *text = utils_get_whitespace(app->pref_editor_tab_width);
|
||||
sci_add_text(sci, text);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
/// TODO on which option should auto_multiline() depend? indention vs. auto completion
|
||||
// " * " auto completion in multiline C/C++/D/Java comments
|
||||
auto_multiline(sci, pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (app->pref_editor_auto_complete_constructs)
|
||||
{
|
||||
auto_multiline(sci, pos); // " * " auto completion in multiline C/C++/D/Java comments
|
||||
|
||||
sci_cb_auto_latex(idx, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -366,13 +373,14 @@ static void get_indent(ScintillaObject *sci, gint pos, gboolean use_this_line)
|
||||
len = sci_get_line_length(sci, prev_line);
|
||||
linebuf = sci_get_line(sci, prev_line);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (i = 0; i < len && j <= (sizeof(indent) - 1); i++)
|
||||
{
|
||||
if (j == sizeof(indent) - 1) break;
|
||||
else if (linebuf[i] == ' ' || linebuf[i] == '\t') indent[j++] = linebuf[i];
|
||||
if (linebuf[i] == ' ' || linebuf[i] == '\t')
|
||||
indent[j++] = linebuf[i];
|
||||
// "&& ! use_this_line" to auto-indent only if it is a real new line
|
||||
// and ignore the case of sci_cb_close_block
|
||||
else if (linebuf[i] == '{' && ! use_this_line)
|
||||
else if (linebuf[i] == '{' && ! use_this_line &&
|
||||
app->pref_editor_indention_mode == INDENT_ADVANCED)
|
||||
{
|
||||
if (app->pref_editor_use_tabs)
|
||||
{
|
||||
@ -390,11 +398,15 @@ static void get_indent(ScintillaObject *sci, gint pos, gboolean use_this_line)
|
||||
else
|
||||
{
|
||||
gint k = len - 1;
|
||||
if (use_this_line) break; // break immediately in the case of sci_cb_close_block
|
||||
|
||||
if (use_this_line)
|
||||
break; // break immediately in the case of sci_cb_close_block
|
||||
|
||||
while (k > 0 && isspace(linebuf[k])) k--;
|
||||
|
||||
// if last non-whitespace character is a { increase indention by a tab
|
||||
// e.g. for (...) {
|
||||
if (linebuf[k] == '{')
|
||||
if (app->pref_editor_indention_mode == INDENT_ADVANCED && linebuf[k] == '{')
|
||||
{
|
||||
if (app->pref_editor_use_tabs)
|
||||
{
|
||||
@ -403,7 +415,7 @@ static void get_indent(ScintillaObject *sci, gint pos, gboolean use_this_line)
|
||||
else
|
||||
{ // insert as many spaces as a tabulator would take
|
||||
gint i;
|
||||
for (i = 0; i < app->pref_editor_use_tabs; i++)
|
||||
for (i = 0; i < app->pref_editor_tab_width; i++)
|
||||
indent[j++] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
@ -537,15 +537,23 @@ void ui_treeviews_show_hide(G_GNUC_UNUSED gboolean force)
|
||||
void ui_document_show_hide(gint idx)
|
||||
{
|
||||
gchar *widget_name;
|
||||
GtkWidget *indention;
|
||||
|
||||
if (idx == -1)
|
||||
idx = document_get_cur_idx();
|
||||
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return;
|
||||
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
app->ignore_callback = TRUE;
|
||||
|
||||
indention = lookup_widget(app->window, "menu_use_auto_indention1");
|
||||
|
||||
gtk_check_menu_item_set_active(
|
||||
GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_line_breaking1")),
|
||||
doc_list[idx].line_breaking);
|
||||
gtk_check_menu_item_set_active(
|
||||
GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_use_auto_indention1")),
|
||||
GTK_CHECK_MENU_ITEM(indention),
|
||||
doc_list[idx].use_auto_indention);
|
||||
gtk_check_menu_item_set_active(
|
||||
GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "set_file_readonly1")),
|
||||
@ -563,6 +571,8 @@ void ui_document_show_hide(gint idx)
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, widget_name)),
|
||||
TRUE);
|
||||
|
||||
gtk_widget_set_sensitive(indention, app->pref_editor_indention_mode != INDENT_NONE);
|
||||
|
||||
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_write_unicode_bom1"),
|
||||
encodings_is_unicode_charset(doc_list[idx].encoding));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user