added utils_replace_filename()

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@21 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2005-11-27 20:49:50 +00:00
parent c9d315b247
commit 2a18ec4879
2 changed files with 22 additions and 0 deletions

View File

@ -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);
}

View File

@ -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