Revision: 1673
http://svn.sourceforge.net/geany/?rev=1673&view=rev
Author: eht16
Date: 2007-07-07 07:19:06 -0700 (Sat, 07 Jul 2007)
Log Message:
-----------
Include new line character(s) when selecting a paragraph.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-07 11:33:32 UTC (rev 1672)
+++ trunk/ChangeLog 2007-07-07 14:19:06 UTC (rev 1673)
@@ -1,3 +1,9 @@
+2007-07-07 Enrico Tröger <enrico.troeger(a)uvena.de>
+
+ * src/editor.c:
+ Include new line character(s) when selecting a paragraph.
+
+
2007-07-07 Nick Treleaven <nick.treleaven(a)btinternet.com>
* scintilla/ScintillaGTK.cxx, src/highlighting.c, doc/geany.docbook,
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2007-07-07 11:33:32 UTC (rev 1672)
+++ trunk/src/editor.c 2007-07-07 14:19:06 UTC (rev 1673)
@@ -2421,10 +2421,6 @@
line_found = find_paragraph_stop(sci, line_start, DOWN);
pos_end = SSM(sci, SCI_POSITIONFROMLINE, line_found, 0);
- // if not on the last line of the document, end the selection on the previous line
- if (line_found < (SSM(sci, SCI_GETLINECOUNT, 0, 0) -1))
- pos_end--;
-
SSM(sci, SCI_SETSEL, pos_start, pos_end);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1671
http://svn.sourceforge.net/geany/?rev=1671&view=rev
Author: eht16
Date: 2007-07-06 05:37:07 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
Use the default GTK file save dialog on Windows. Prevent some (probably) unnecessary filename encoding conversions.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/geany.docbook
trunk/src/callbacks.c
trunk/src/dialogs.c
trunk/src/document.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/ChangeLog 2007-07-06 12:37:07 UTC (rev 1671)
@@ -2,6 +2,9 @@
* doc/geany.docbook, src/editor.c, src/editor.h, src/keybindings.c,
src/keybindings.h: Add keybinding for select current paragraph.
+ * doc/geany.docbook, src/callbacks.c, src/dialogs.c, src/document.c:
+ Use the default GTK file save dialog on Windows.
+ Prevent some (probably) unnecessary filename encoding conversions.
2007-07-05 Enrico Tröger <enrico.troeger(a)uvena.de>
Modified: trunk/doc/geany.docbook
===================================================================
--- trunk/doc/geany.docbook 2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/doc/geany.docbook 2007-07-06 12:37:07 UTC (rev 1671)
@@ -2821,10 +2821,10 @@
<row>
<entry>GEANY_USE_WIN32_DIALOG</entry>
<entry>Set this to 1 if you want to use the default Windows
- file open dialog instead GTK's file open dialog. The default
- Windows file open dialog is missing some nice features like
- choosing a filetype or an encoding. Do not touch this
- setting when building on a non-Win32 system.</entry>
+ file open and save dialogs instead GTK's file open and save
+ dialogs. The default Windows file dialogs are missing some nice
+ features like choosing a filetype or an encoding. Do not touch
+ this setting when building on a non-Win32 system.</entry>
<entry>0</entry>
</row>
</tbody>
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/src/callbacks.c 2007-07-06 12:37:07 UTC (rev 1671)
@@ -856,8 +856,11 @@
gboolean rename_file = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(lookup_widget(app->save_filesel, "check_rename")));
+#ifdef G_OS_WIN32
+ utf8_filename = g_strdup(new_filename);
+#else
utf8_filename = utils_get_utf8_from_locale(new_filename);
-
+#endif
// check if file exists and ask whether to overwrite or not
if (g_file_test(new_filename, G_FILE_TEST_EXISTS))
{
@@ -907,10 +910,14 @@
{
if (rename_file)
{ // delete the previous file name
+#ifdef G_OS_WIN32
+ g_unlink(doc_list[idx].file_name);
+#else
gchar *old_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
g_unlink(old_filename);
g_free(old_filename);
+#endif
}
// create a new tm_source_file object otherwise tagmanager won't work correctly
tm_workspace_remove_object(doc_list[idx].tm_file, TRUE);
Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c 2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/src/dialogs.c 2007-07-06 12:37:07 UTC (rev 1671)
@@ -56,8 +56,8 @@
#if ! GEANY_USE_WIN32_DIALOG
static GtkWidget *add_file_open_extra_widget();
+static void on_save_as_new_tab_toggled(GtkToggleButton *togglebutton, gpointer user_data);
#endif
-static void on_save_as_new_tab_toggled(GtkToggleButton *togglebutton, gpointer user_data);
/* This shows the file selection dialog to open a file. */
@@ -269,7 +269,7 @@
* the file was saved. */
gboolean dialogs_show_save_as()
{
-#ifdef G_OS_WIN32
+#if GEANY_USE_WIN32_DIALOG
return win32_show_file_dialog(FALSE);
#else
gint idx = document_get_cur_idx(), resp;
@@ -318,13 +318,18 @@
// If the current document has a filename we use that as the default.
if (doc_list[idx].file_name != NULL)
{
+#ifdef G_OS_WIN32
+ gchar *locale_filename = doc_list[idx].file_name;
+#else
gchar *locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
-
+#endif
if (g_path_is_absolute(locale_filename))
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(app->save_filesel), locale_filename);
else
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(app->save_filesel), locale_filename);
+#ifndef G_OS_WIN32
g_free(locale_filename);
+#endif
}
else
{
@@ -344,8 +349,16 @@
if (app->default_open_path != NULL && *app->default_open_path != '\0')
{
if (g_path_is_absolute(app->default_open_path))
+ {
+#ifdef G_OS_WIN32
gtk_file_chooser_set_current_folder(
GTK_FILE_CHOOSER(app->save_filesel), app->default_open_path);
+#else
+ gchar *def_path = utils_get_locale_from_utf8(app->default_open_path);
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(app->save_filesel), def_path);
+ g_free(def_path);
+#endif
+ }
}
g_free(fname);
}
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/src/document.c 2007-07-06 12:37:07 UTC (rev 1671)
@@ -969,7 +969,9 @@
gchar *data;
FILE *fp;
gint bytes_written, len;
+#ifndef G_OS_WIN32
gchar *locale_filename = NULL;
+#endif
if (! DOC_IDX_VALID(idx)) return FALSE;
// the changed flag should exclude the readonly flag, but check it anyway for safety
@@ -1043,12 +1045,16 @@
{
len = strlen(data);
}
+#ifdef G_OS_WIN32
+ fp = fopen(doc_list[idx].file_name, "wb"); // this should fix the windows \n problem
+#else
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
- fp = fopen(locale_filename, "wb"); // this should fix the windows \n problem
+ fp = fopen(locale_filename, "w");
g_free(locale_filename);
+#endif
if (fp == NULL)
{
- msgwin_status_add(_("Error saving file (%s)."), strerror(errno));
+ msgwin_status_add(_("Error saving file (%s)."), g_strerror(errno));
utils_beep();
g_free(data);
return FALSE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1670
http://svn.sourceforge.net/geany/?rev=1670&view=rev
Author: eht16
Date: 2007-07-06 03:19:28 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
Fix wrong REVISION value.
Modified Paths:
--------------
trunk/win32-config.h
Modified: trunk/win32-config.h
===================================================================
--- trunk/win32-config.h 2007-07-06 10:16:51 UTC (rev 1669)
+++ trunk/win32-config.h 2007-07-06 10:19:28 UTC (rev 1670)
@@ -322,7 +322,7 @@
code using `volatile' can become incorrect without. Disable with care. */
/* #undef volatile */
-#define REVISION "SVN"
+#define REVISION "-1"
/* Define if you want to detect a running instance */
#define HAVE_SOCKET 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 1669
http://svn.sourceforge.net/geany/?rev=1669&view=rev
Author: eht16
Date: 2007-07-06 03:16:51 -0700 (Fri, 06 Jul 2007)
Log Message:
-----------
Add keybinding for select current paragraph.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/geany.docbook
trunk/src/editor.c
trunk/src/editor.h
trunk/src/keybindings.c
trunk/src/keybindings.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-05 18:19:56 UTC (rev 1668)
+++ trunk/ChangeLog 2007-07-06 10:16:51 UTC (rev 1669)
@@ -1,3 +1,9 @@
+2007-07-06 Enrico Tröger <enrico.troeger(a)uvena.de>
+
+ * doc/geany.docbook, src/editor.c, src/editor.h, src/keybindings.c,
+ src/keybindings.h: Add keybinding for select current paragraph.
+
+
2007-07-05 Enrico Tröger <enrico.troeger(a)uvena.de>
* src/search.c: Fix usage of wrong dialog pointer.
Modified: trunk/doc/geany.docbook
===================================================================
--- trunk/doc/geany.docbook 2007-07-05 18:19:56 UTC (rev 1668)
+++ trunk/doc/geany.docbook 2007-07-06 10:16:51 UTC (rev 1669)
@@ -1931,6 +1931,12 @@
</entry>
</row>
<row>
+ <entry>Select current paragraph</entry>
+ <entry>Selects the current paragraph under the cursor which is
+ defined by two empty lines around it.
+ </entry>
+ </row>
+ <row>
<entry>Insert alternative whitespace</entry>
<entry>Inserts a tabulator character when spaces should be used for
indentation and inserts space characters of the amount of a
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2007-07-05 18:19:56 UTC (rev 1668)
+++ trunk/src/editor.c 2007-07-06 10:16:51 UTC (rev 1669)
@@ -2351,6 +2351,84 @@
}
+/* 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 */
+static gint find_paragraph_stop(ScintillaObject *sci, gint line, gint direction)
+{
+ gboolean found_end = FALSE;
+ gint step;
+ gchar *line_buf, *x;
+
+ // first check current line and return -1 if it is empty to skip creating of a selection
+ line_buf = x = sci_get_line(sci, line);
+ while (isspace(*x))
+ x++;
+ if (*x == '\0')
+ {
+ g_free(line_buf);
+ return -1;
+ }
+
+ if (direction == UP)
+ step = -1;
+ else
+ step = 1;
+
+ while (! found_end)
+ {
+ line += step;
+
+ // sci_get_line checks for sanity of the given line, sci_get_line always return a string
+ // containing at least '\0' so no need to check for NULL
+ line_buf = x = sci_get_line(sci, line);
+
+ // check whether after skipping all whitespace we are at end of line and if so, assume
+ // this line as end of paragraph
+ while (isspace(*x))
+ x++;
+ if (*x == '\0')
+ {
+ found_end = TRUE;
+ if (line == -1)
+ // called on the first line but there is no previous line so return line 0
+ line = 0;
+ }
+ g_free(line_buf);
+ }
+ return line;
+}
+
+
+void editor_select_paragraph(ScintillaObject *sci)
+{
+ gint pos_start, pos_end, line_start, line_found;
+
+ g_return_if_fail(sci != NULL);
+
+ line_start = SSM(sci, SCI_LINEFROMPOSITION, SSM(sci, SCI_GETCURRENTPOS, 0, 0), 0);
+
+ line_found = find_paragraph_stop(sci, line_start, UP);
+ if (line_found == -1)
+ return;
+
+ // find_paragraph_stop returns the emtpy line(previous to the real start of the paragraph),
+ // so use the next line for selection start
+ if (line_found > 0)
+ line_found++;
+
+ pos_start = SSM(sci, SCI_POSITIONFROMLINE, line_found, 0);
+
+ line_found = find_paragraph_stop(sci, line_start, DOWN);
+ pos_end = SSM(sci, SCI_POSITIONFROMLINE, line_found, 0);
+
+ // if not on the last line of the document, end the selection on the previous line
+ if (line_found < (SSM(sci, SCI_GETLINECOUNT, 0, 0) -1))
+ pos_end--;
+
+ SSM(sci, SCI_SETSEL, pos_start, pos_end);
+}
+
+
void editor_finalize()
{
g_hash_table_destroy(editor_prefs.auto_completions);
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2007-07-05 18:19:56 UTC (rev 1668)
+++ trunk/src/editor.h 2007-07-06 10:16:51 UTC (rev 1669)
@@ -136,6 +136,8 @@
void editor_select_word(ScintillaObject *sci);
+void editor_select_paragraph(ScintillaObject *sci);
+
void editor_insert_alternative_whitespace(ScintillaObject *sci);
void editor_finalize();
Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c 2007-07-05 18:19:56 UTC (rev 1668)
+++ trunk/src/keybindings.c 2007-07-06 10:16:51 UTC (rev 1669)
@@ -289,7 +289,9 @@
0, 0, "edit_suppresscompletion", _("Suppress construct completion"));
keys[GEANY_KEYS_EDIT_SELECTWORD] = fill(cb_func_edit,
- 0, 0, "edit_selectword", _("Select current word"));
+ GDK_w, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectword", _("Select current word"));
+ keys[GEANY_KEYS_EDIT_SELECTPARAGRAPH] = fill(cb_func_edit,
+ GDK_p, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectparagraph", _("Select current paragraph"));
keys[GEANY_KEYS_EDIT_INSERTALTWHITESPACE] = fill(cb_func_edit,
0, 0, "edit_insertwhitespace", _("Insert alternative whitespace"));
@@ -1129,6 +1131,9 @@
case GEANY_KEYS_EDIT_SELECTWORD:
editor_select_word(doc_list[idx].sci);
break;
+ case GEANY_KEYS_EDIT_SELECTPARAGRAPH:
+ editor_select_paragraph(doc_list[idx].sci);
+ break;
case GEANY_KEYS_EDIT_INSERTALTWHITESPACE:
editor_insert_alternative_whitespace(doc_list[idx].sci);
break;
Modified: trunk/src/keybindings.h
===================================================================
--- trunk/src/keybindings.h 2007-07-05 18:19:56 UTC (rev 1668)
+++ trunk/src/keybindings.h 2007-07-06 10:16:51 UTC (rev 1669)
@@ -128,6 +128,7 @@
GEANY_KEYS_EDIT_GOTONEXTMARKER,
GEANY_KEYS_EDIT_GOTOPREVIOUSMARKER,
GEANY_KEYS_EDIT_SELECTWORD,
+ GEANY_KEYS_EDIT_SELECTPARAGRAPH,
GEANY_KEYS_EDIT_INSERTALTWHITESPACE,
GEANY_KEYS_EDIT_AUTOCOMPLETE,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.