Kaydet (Commit) 2a18ec48 authored tarafından Enrico Tröger's avatar Enrico Tröger

added utils_replace_filename()


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@21 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst c9d315b2
......@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
......@@ -1853,3 +1854,21 @@ void utils_switch_document(gint direction)
}
}
void utils_replace_filename(gint idx)
{
gint pos = sci_get_current_position(doc_list[idx].sci);
gchar *filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc_list[idx].file_type)->extension, NULL);
gchar *filename = g_path_get_basename(doc_list[idx].file_name);
sci_set_current_position(doc_list[idx].sci, 0);
sci_set_search_anchor(doc_list[idx].sci);
// stop if filebase was not found
if (sci_search_next(doc_list[idx].sci, SCFIND_MATCHCASE, filebase) == -1) return;
sci_replace_sel(doc_list[idx].sci, filename);
g_free(filebase);
g_free(filename);
sci_set_current_position(doc_list[idx].sci, pos);
}
......@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
......@@ -190,4 +191,6 @@ gchar *utils_get_setting_string(GKeyFile *config, const gchar *section, const gc
void utils_switch_document(gint direction);
void utils_replace_filename(gint idx);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment