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:
parent
c9d315b247
commit
2a18ec4879
19
src/utils.c
19
src/utils.c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user