On Sun, Feb 15, 2004 at 01:34:43PM -0500, Jeremy Maitin-Shepard wrote:
> In order to implement Emacs-style mini-buffer C-g handling, such that
> if there is an active (selected) region, C-g clears/deactivates the
> region, and otherwise cancels the read from the mini-buffer, it would
> be useful for there to be a function which indicates whether there is
> an active mark.  

> It might also be useful for there to be a function to
> return the substring which the active region contains, and a function
> which indicates the position of the mark.

I added WEdln.mark, as it is clearly missing (attached needed until
I make a new release). The following code should retrieve selection
then.

function getsel(wedln)
    local mk, pt=wedln:mark(), wedln:point()
    if mk==-1 then return end
    return string.sub(wedln:contents(), 
                      math.min(pt, mk)+1,
                      math.max(pt, mk))
end

-- 
Tuomo
Index: wedln-wrappers.c
===================================================================
--- wedln-wrappers.c    (revision 1306)
+++ wedln-wrappers.c    (revision 1307)
@@ -227,3 +227,14 @@
 {
        return wedln->edln.point;
 }
+
+/*EXTL_DOC
+ * Get current mark (start of selection) for \var{wedln}.
+ * Return value of -1 indicates that there is no mark, and
+ * 0 is the beginning of the line.
+ */
+EXTL_EXPORT_MEMBER
+int wedln_mark(WEdln *wedln)
+{
+       return wedln->edln.mark;
+}

Reply via email to