SF.net SVN: geany: [1514] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Tue May 8 16:03:09 UTC 2007
Revision: 1514
http://svn.sourceforge.net/geany/?rev=1514&view=rev
Author: eht16
Date: 2007-05-08 09:03:07 -0700 (Tue, 08 May 2007)
Log Message:
-----------
Added sci_get_line_indentation() and sci_set_line_indentation().
Fixed broken increase/decrease indentation when using only spaces for indentation.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/callbacks.c
trunk/src/sciwrappers.c
trunk/src/sciwrappers.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-05-07 15:36:43 UTC (rev 1513)
+++ trunk/ChangeLog 2007-05-08 16:03:07 UTC (rev 1514)
@@ -1,3 +1,11 @@
+2007-05-08 Enrico Tröger <enrico.troeger at uvena.de>
+
+ * src/sciwrappers.c, src/sciwrappers.h:
+ Added sci_get_line_indentation() and sci_set_line_indentation().
+ * src/callbacks.c: Fixed broken increase/decrease indentation when
+ using only spaces for indentation.
+
+
2007-05-07 Enrico Tröger <enrico.troeger at uvena.de>
* data/filetypes.haskell: Added build instructions.
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2007-05-07 15:36:43 UTC (rev 1513)
+++ trunk/src/callbacks.c 2007-05-08 16:03:07 UTC (rev 1514)
@@ -1863,7 +1863,7 @@
gpointer user_data)
{
gint idx = document_get_cur_idx();
- if (idx == -1 || ! doc_list[idx].is_valid) return;
+ if (! DOC_IDX_VALID(idx)) return;
if (sci_get_lines_selected(doc_list[idx].sci) > 1)
{
@@ -1871,16 +1871,18 @@
}
else
{
- gint line, ind_pos, old_pos;
+ gint line, ind_pos, old_pos, new_pos, step;
old_pos = sci_get_current_position(doc_list[idx].sci);
line = sci_get_current_line(doc_list[idx].sci, old_pos);
ind_pos = sci_get_line_indent_position(doc_list[idx].sci, line);
+ // when using tabs increase cur pos by 1, when using space increase it by tab_width
+ step = (app->pref_editor_use_tabs) ? 1 : app->pref_editor_tab_width;
+ new_pos = (old_pos > ind_pos) ? old_pos + step : old_pos;
sci_set_current_position(doc_list[idx].sci, ind_pos, TRUE);
sci_cmd(doc_list[idx].sci, SCI_TAB);
- sci_set_current_position(doc_list[idx].sci,
- (old_pos > ind_pos) ? old_pos + 1 : old_pos, TRUE);
+ sci_set_current_position(doc_list[idx].sci, new_pos, TRUE);
}
}
@@ -1890,7 +1892,7 @@
gpointer user_data)
{
gint idx = document_get_cur_idx();
- if (idx == -1 || ! doc_list[idx].is_valid) return;
+ if (! DOC_IDX_VALID(idx)) return;
if (sci_get_lines_selected(doc_list[idx].sci) > 1)
{
@@ -1898,18 +1900,25 @@
}
else
{
- gint line, ind_pos, old_pos;
+ gint line, ind_pos, old_pos, new_pos, step, indent;
old_pos = sci_get_current_position(doc_list[idx].sci);
line = sci_get_current_line(doc_list[idx].sci, old_pos);
ind_pos = sci_get_line_indent_position(doc_list[idx].sci, line);
+ step = (app->pref_editor_use_tabs) ? 1 : app->pref_editor_tab_width;
+ new_pos = (old_pos >= ind_pos) ? old_pos - step : old_pos;
if (ind_pos == sci_get_position_from_line(doc_list[idx].sci, line))
return;
+
sci_set_current_position(doc_list[idx].sci, ind_pos, TRUE);
- sci_cmd(doc_list[idx].sci, SCI_BACKTAB);
- sci_set_current_position(doc_list[idx].sci,
- (old_pos >= ind_pos) ? old_pos - 1 : old_pos, TRUE);
+ indent = sci_get_line_indentation(doc_list[idx].sci, line);
+ indent -= app->pref_editor_tab_width;
+ if (indent < 0)
+ indent = 0;
+ sci_set_line_indentation(doc_list[idx].sci, line, indent);
+
+ sci_set_current_position(doc_list[idx].sci, new_pos, TRUE);
}
}
Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c 2007-05-07 15:36:43 UTC (rev 1513)
+++ trunk/src/sciwrappers.c 2007-05-08 16:03:07 UTC (rev 1514)
@@ -941,3 +941,13 @@
SSM(sci, SCI_SETVSCROLLBAR, visible, 0);
}
+void sci_set_line_indentation(ScintillaObject *sci, gint line, gint indent)
+{
+ SSM(sci, SCI_SETLINEINDENTATION, line, indent);
+}
+
+int sci_get_line_indentation(ScintillaObject *sci, gint line)
+{
+ return SSM(sci, SCI_GETLINEINDENTATION, line, 0);
+}
+
Modified: trunk/src/sciwrappers.h
===================================================================
--- trunk/src/sciwrappers.h 2007-05-07 15:36:43 UTC (rev 1513)
+++ trunk/src/sciwrappers.h 2007-05-08 16:03:07 UTC (rev 1514)
@@ -167,6 +167,8 @@
void sci_start_styling (ScintillaObject * sci, gint pos, gint mask);
void sci_select_all (ScintillaObject * sci);
gint sci_get_line_indent_position(ScintillaObject * sci, gint line);
+void sci_set_line_indentation (ScintillaObject * sci, gint line, gint indent);
+int sci_get_line_indentation (ScintillaObject * sci, gint line);
void sci_set_autoc_max_height (ScintillaObject * sci, gint val);
gint sci_find_bracematch (ScintillaObject * sci, gint pos);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list