aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-03-10 18:35:00 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-03-10 18:35:00 +0100
commita0d1231340617ab28a941f723793ad7be242ca0c (patch)
tree68d3e0aea009e034a6abafc4dd3a89629641db37 /src
parent67b846c099968439c415ae18fcc6736bdd26e233 (diff)
downloadsciteco-a0d1231340617ab28a941f723793ad7be242ca0c.tar.gz
always normalize directory separators to "/" in the "*" Q-Register
* on Windows, this register contained backward slashes. This means that macros working with that register had to cope with both forward and backward slashes. * The file names are still displayed in the native style by the UI * This approach also has disadvantages: What if the user wants to insert the current file name somewhere where "\" is expected? However, this seems to be an unlikely case and the use can still replace the "/" with "\" again. * Avoid some virtual method calls in QRegisterBufferInfo
Diffstat (limited to 'src')
-rw-r--r--src/qregisters.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/qregisters.cpp b/src/qregisters.cpp
index 20f6e99..acb12cf 100644
--- a/src/qregisters.cpp
+++ b/src/qregisters.cpp
@@ -318,7 +318,22 @@ QRegisterBufferInfo::get_integer(void)
gchar *
QRegisterBufferInfo::get_string(void)
{
- return g_strdup(ring.current->filename ? : "");
+ gchar *str = g_strdup(ring.current->filename ? : "");
+
+ /*
+ * On platforms with a default non-forward-slash directory
+ * separator (i.e. Windows), Buffer::filename will have
+ * the wrong separator.
+ * To make the life of macros that evaluate "*" easier,
+ * the directory separators are normalized to "/" here.
+ * This does not change the size of the string, so
+ * get_string_size() still works.
+ */
+#if G_DIR_SEPARATOR != '/'
+ g_strdelimit(str, G_DIR_SEPARATOR_S, '/');
+#endif
+
+ return str;
}
gsize
@@ -330,7 +345,8 @@ QRegisterBufferInfo::get_string_size(void)
gint
QRegisterBufferInfo::get_character(gint position)
{
- if (position < 0 || position >= (gint)get_string_size())
+ if (position < 0 ||
+ position >= (gint)QRegisterBufferInfo::get_string_size())
return -1;
return ring.current->filename[position];
@@ -339,11 +355,14 @@ QRegisterBufferInfo::get_character(gint position)
void
QRegisterBufferInfo::edit(void)
{
+ gchar *str;
+
QRegister::edit();
QRegisters::view.ssm(SCI_BEGINUNDOACTION);
- QRegisters::view.ssm(SCI_SETTEXT, 0,
- (sptr_t)(ring.current->filename ? : ""));
+ str = QRegisterBufferInfo::get_string();
+ QRegisters::view.ssm(SCI_SETTEXT, 0, (sptr_t)str);
+ g_free(str);
QRegisters::view.ssm(SCI_ENDUNDOACTION);
QRegisters::view.undo_ssm(SCI_UNDO);