]> git.neil.brown.name Git - edlib.git/commitdiff
python: expose RXL constants.
authorNeilBrown <neil@brown.name>
Sat, 26 Sep 2020 00:46:15 +0000 (10:46 +1000)
committerNeilBrown <neil@brown.name>
Sat, 26 Sep 2020 00:46:15 +0000 (10:46 +1000)
RXL_ANCHORED and RXL_BACKTRACK are needed in python code, so expose
them.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
lang-python.c
python/lib-diff.py
python/render-calc.py

index 5830bb212107e1d835cf97ca4bbb12fc332d90cc..fb3d55b65a73f7ca414dbc732b3f289cb24a8b4b 100644 (file)
@@ -470,7 +470,7 @@ Module features
 - [ ] should Efallthrough be an exception?
 - [ ] Print error name when there is a python error
 - [ ] edlib.log can crash if there are '%' if the buffer.
-- [ ] expose rexel constants
+- [X] expose rexel constants
 - [ ] report error if release mark which isn't ours.
 - [X] create a library of support functions like doc_next, doc_prev etc.
 - [ ] Log loading of modules - Can I provide version info?
index ffb547d52716c15eb540d89df11abb28cbfab958..7a9951068a4f8e0aa119cbec4a3ed0eedb9eca14 100644 (file)
@@ -57,6 +57,7 @@ struct doc_ref {
 };
 #include "core.h"
 #include "misc.h"
+#include "rexel.h"
 
 #define SAFE_CI {.key=safe_cast NULL,\
                 .home=safe_cast NULL,\
@@ -2565,6 +2566,10 @@ void edlib_init(struct pane *ed safe)
        PyModule_AddIntMacro(m, TIME_IDLE);
        PyModule_AddIntMacro(m, TIME_REFRESH);
 
+       PyModule_AddIntMacro(m, RXL_ANCHORED);
+       PyModule_AddIntMacro(m, RXL_BACKTRACK);
+
+
        PyModule_AddIntConstant(m, "WEOF", 0x1FFFFF);
        call_comm("global-set-command", ed, &python_load, 0, NULL, "python-load");
        call_comm("global-set-command", ed, &python_load_module,
index 0969d16f990e28937f416f05cda311035841461a..9cc2005f299471c1cc28b4a2af61ecc85445e7a1 100644 (file)
@@ -226,7 +226,8 @@ class DiffPane(edlib.Pane):
         except edlib.commandfailed:
             focus.call("Message", "Not on a diff hunk - no '@@' line")
             return 1
-        cmd = focus.call("make-search", ptn, 3, ret='comm')
+        cmd = focus.call("make-search", ptn,
+                         edlib.RXL_ANCHORED|edlib.RXL_BACKTRACK, ret='comm')
         m2 = m.dup()
         focus.call("doc:content", m2, cmd)
         f = cmd("getcapture", "len", focus, 1)-1
index 26152f48d8042efa73ca9ec68f290417423457ba..bfac1d6b7a1cfc5590b3a9f90a3d4d4d05ea379d 100644 (file)
@@ -11,7 +11,9 @@ class CalcView(edlib.Pane):
         edlib.Pane.__init__(self, focus)
         self.vars = {}
         self.varcnt = 0
-        self.getvar = focus.call("make-search", "> ([a-z0-9]+) = ", 3, ret='comm')
+        self.getvar = focus.call("make-search", "> ([a-z0-9]+) = ",
+                                 edlib.RXL_ANCHORED|edlib.RXL_BACKTRACK,
+                                 ret='comm')
 
     def handle_enter(self, key, focus, mark, **a):
         "handle-list/K:Enter/K:M:Enter"
@@ -84,7 +86,8 @@ class CalcView(edlib.Pane):
             if c and c == '\n':
                 c = focus.following(m)
                 if c and c == '>':
-                    self.getvar("reinit", focus, 3)
+                    self.getvar("reinit", focus,
+                                edlib.RXL_ANCHORED | edlib.RXL_BACKTRACK)
                     focus.call("doc:content", m.dup(), self.getvar)
                     nm = self.getvar("interp", focus, "\\1", ret='str')
                     # replace this line