Revision: 2901
http://geany.svn.sourceforge.net/geany/?rev=2901&view=rev
Author: ntrel
Date: 2008-08-25 15:44:51 +0000 (Mon, 25 Aug 2008)
Log Message:
-----------
Add editor_destroy() to dispose of a GeanyEditor struct (in future
we may want to do more than just free it).
Fix editor.h dox description to be more informative for the API
(and move dox from editor.h to editor.c).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
trunk/src/editor.c
trunk/src/editor.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-08-19 14:55:56 UTC (rev 2900)
+++ trunk/ChangeLog 2008-08-25 15:44:51 UTC (rev 2901)
@@ -1,3 +1,12 @@
+2008-08-25 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/document.c, src/editor.c, src/editor.h:
+ Add editor_destroy() to dispose of a GeanyEditor struct (in future
+ we may want to do more than just free it).
+ Fix editor.h dox description to be more informative for the API
+ (and move dox from editor.h to editor.c).
+
+
2008-08-19 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/editor.c:
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2008-08-19 14:55:56 UTC (rev 2900)
+++ trunk/src/document.c 2008-08-25 15:44:51 UTC (rev 2901)
@@ -495,7 +495,7 @@
g_free(doc->real_path);
tm_workspace_remove_object(doc->tm_file, TRUE, TRUE);
- g_free(doc->editor);
+ editor_destroy(doc->editor);
doc->editor = NULL;
doc->is_valid = FALSE;
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2008-08-19 14:55:56 UTC (rev 2900)
+++ trunk/src/editor.c 2008-08-25 15:44:51 UTC (rev 2901)
@@ -21,13 +21,20 @@
* $Id$
*/
-/*
- * Callbacks for the Scintilla widget (ScintillaObject).
+/**
+ * @file editor.h
+ * Editor-related functions for @ref GeanyEditor.
+ * Geany uses the Scintilla editing widget, and this file is mostly built around
+ * Scintilla's functionality.
+ * @see sciwrappers.h.
+ */
+/* Callbacks for the Scintilla widget (ScintillaObject).
* Most important is the sci-notify callback, handled in on_editor_notification().
* This includes auto-indentation, comments, auto-completion, calltips, etc.
* Also some general Scintilla-related functions.
*/
+
#include <ctype.h>
#include <string.h>
@@ -3805,6 +3812,13 @@
}
+/* in case we need to free some fields in future */
+void editor_destroy(GeanyEditor *editor)
+{
+ g_free(editor);
+}
+
+
void editor_init(void)
{
static GeanyIndentPrefs indent_prefs;
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2008-08-19 14:55:56 UTC (rev 2900)
+++ trunk/src/editor.h 2008-08-25 15:44:51 UTC (rev 2901)
@@ -21,15 +21,7 @@
* $Id$
*/
-/**
- * @file editor.h
- * Callbacks for the Scintilla widget (ScintillaObject).
- * Most important is the sci-notify callback, handled in on_editor_notification().
- * This includes auto-indentation, comments, auto-completion, calltips, etc.
- * Also some general Scintilla-related functions.
- **/
-
#ifndef GEANY_SCI_CB_H
#define GEANY_SCI_CB_H 1
@@ -149,6 +141,8 @@
GeanyEditor *editor_create(GeanyDocument *doc);
+void editor_destroy(GeanyEditor *editor);
+
void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data);
gboolean editor_start_auto_complete(GeanyDocument *doc, gint pos, gboolean force);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2900
http://geany.svn.sourceforge.net/geany/?rev=2900&view=rev
Author: ntrel
Date: 2008-08-19 14:55:56 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
Detect 'Tabs and Spaces' indent mode on finding one or more hard
tabs before a soft tab at the start of several lines, and also when
the first indent symbol count is not mainly tabs or mainly spaces.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-08-19 11:45:07 UTC (rev 2899)
+++ trunk/ChangeLog 2008-08-19 14:55:56 UTC (rev 2900)
@@ -8,8 +8,12 @@
Spaces' is selected.
* src/document.c:
Don't warn about a missing file on disk more than once (otherwise
- somtimes it's too difficult to close the file before getting the
+ sometimes it's too difficult to close the file before getting the
prompt).
+ * src/document.c:
+ Detect 'Tabs and Spaces' indent mode on finding one or more hard
+ tabs before a soft tab at the start of several lines, and also when
+ the first indent symbol count is not mainly tabs or mainly spaces.
2008-08-18 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2008-08-19 11:45:07 UTC (rev 2899)
+++ trunk/src/document.c 2008-08-19 14:55:56 UTC (rev 2900)
@@ -883,7 +883,7 @@
}
-/* Count lines that start with a hard tab then a soft tab. */
+/* Count lines that start with some hard tabs then a soft tab. */
static gboolean detect_tabs_and_spaces(GeanyEditor *editor)
{
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
@@ -891,7 +891,7 @@
gsize count = 0;
struct TextToFind ttf;
gchar *soft_tab = g_strnfill(iprefs->width, ' ');
- gchar *regex = g_strconcat("^\t", soft_tab, NULL);
+ gchar *regex = g_strconcat("^\t+", soft_tab, "[^ ]", NULL);
g_free(soft_tab);
@@ -909,16 +909,17 @@
ttf.chrg.cpMin = ttf.chrgText.cpMax + 1; /* search after this match */
}
g_free(regex);
+ /* The 0.02 is a low weighting to ignore a few possibly accidental occurrences */
return count > sci_get_line_count(sci) * 0.02;
}
+/* Detect the indent type based on counting the leading indent characters for each line. */
static GeanyIndentType detect_indent_type(GeanyEditor *editor)
{
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
ScintillaObject *sci = editor->sci;
gint line;
- gboolean use_tabs;
gsize tabs = 0, spaces = 0;
if (detect_tabs_and_spaces(editor))
@@ -935,7 +936,7 @@
else
if (c == ' ')
{
- /* check at least 2 spaces */
+ /* check for at least 2 spaces */
if (sci_get_char_at(sci, pos + 1) == ' ')
spaces++;
}
@@ -943,13 +944,13 @@
if (spaces == 0 && tabs == 0)
return iprefs->type;
- /* Skew comparison by a factor of 2 in favour of default editor pref */
- if (iprefs->type == GEANY_INDENT_TYPE_TABS)
- use_tabs = ! (spaces > tabs * 2);
+ /* the factors may need to be tweaked */
+ if (spaces > tabs * 4)
+ return GEANY_INDENT_TYPE_SPACES;
+ else if (tabs > spaces * 4)
+ return GEANY_INDENT_TYPE_TABS;
else
- use_tabs = (tabs > spaces * 2);
-
- return use_tabs ? GEANY_INDENT_TYPE_TABS : GEANY_INDENT_TYPE_SPACES;
+ return GEANY_INDENT_TYPE_BOTH;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2899
http://geany.svn.sourceforge.net/geany/?rev=2899&view=rev
Author: ntrel
Date: 2008-08-19 11:45:07 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
Don't warn about a missing file on disk more than once (otherwise
somtimes it's too difficult to close the file before getting the
prompt).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-08-19 11:20:09 UTC (rev 2898)
+++ trunk/ChangeLog 2008-08-19 11:45:07 UTC (rev 2899)
@@ -6,6 +6,10 @@
* src/interface.c, src/callbacks.c, src/callbacks.h, geany.glade:
Don't disable 'Detect from file' indent type pref when 'Tabs and
Spaces' is selected.
+ * src/document.c:
+ Don't warn about a missing file on disk more than once (otherwise
+ somtimes it's too difficult to close the file before getting the
+ prompt).
2008-08-18 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2008-08-19 11:20:09 UTC (rev 2898)
+++ trunk/src/document.c 2008-08-19 11:45:07 UTC (rev 2899)
@@ -2608,6 +2608,8 @@
{
/* file is missing - set unsaved state */
document_set_text_changed(doc, TRUE);
+ /* don't prompt more than once */
+ setptr(doc->real_path, NULL);
if (dialogs_show_question_full(NULL, GTK_STOCK_SAVE, GTK_STOCK_CANCEL,
_("Try to resave the file?"),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2896
http://geany.svn.sourceforge.net/geany/?rev=2896&view=rev
Author: ntrel
Date: 2008-08-18 16:51:45 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
Add item: MRU documents switching.
Modified Paths:
--------------
trunk/TODO
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2008-08-18 16:06:19 UTC (rev 2895)
+++ trunk/TODO 2008-08-18 16:51:45 UTC (rev 2896)
@@ -18,6 +18,7 @@
o recent projects menu
o project indentation settings support
o improve Compile toolbar button for Make (drop down radio list?)
+ o MRU documents switching
o (selectable menu of arguments to use for Make, from Make Custom)
o (DBUS)
o (indent wrapped lines - Scintilla issue)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2895
http://geany.svn.sourceforge.net/geany/?rev=2895&view=rev
Author: ntrel
Date: 2008-08-18 16:06:19 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
Removing merged branch.
Removed Paths:
-------------
branches/editor-struct/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.