aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/sciteco.7.template10
-rw-r--r--src/qregisters.cpp27
2 files changed, 32 insertions, 5 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template
index 6c48f20..00c8366 100644
--- a/doc/sciteco.7.template
+++ b/doc/sciteco.7.template
@@ -636,7 +636,10 @@ There is at most one unnamed buffer in the ring, identified
by the empty name.
Named buffers are buffers with an associated file name.
The file might or might not already exist in the file system.
-The file name uses the host system's path seperator.
+The file name uses the host system's directory separator, but for
+the sake of macro portability the directory separators are
+normalized to \(lq/\(rq when accessing the current buffer's
+file name with the \(lq*\(rq Q-Register.
File names are always tried to be normalized to absolute
paths to make them independant of \*(ST's current working
directory.
@@ -897,6 +900,11 @@ buffer in ring.
The unnamed buffer has an empty name.
If the current document is a register, this returns the
name or id of the buffer last edited.
+Buffer file names are \fItried\fP to be made absolute paths
+by \*(ST, but this might not always be possible.
+Also, file names accessed with the \(lq*\(rq register will
+always have forward-slash directory separators even if they
+are displayed differently in the user interface.
The \(lq*\(rq register may also be edited but changing its
string contents has no effect on the file name of the buffer.
Setting the numeric part of the \(lq*\(rq register,
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);