from the end of the display, a positive number is counted forward from
the start. A line number of zero is the centre of the display.
-- "Move-CursorXY" does not adjust the display, but moved the point as
+- "Move-CursorXY" does not adjust the display, but moves the point as
close as possible to the x,y position passed in the message.
- The num1 argument will report if the message is due to a mouse click
- (1) or release (2) or motion (3). If it was "release" then
- "render-lines" will check if the attribute "active-tag" appears in the
- markup for that location. If it does then a message is sent to the
- stack with a key formed from "Activate:" followed by the value
- of "active-tag". "mark" will be a mark at the location, "str1" will be
- the tag, and "str2" will be all attributes active at that location.
+ The str1 argument can indicate that a context-dependant action, if
+ any, could be performed. If the content at the target location has
+ a tag named "action-" followed by the value in str1, then the value of
+ that tag is used as a command name and is sent to the focus with
+ all attributes at that location passed as "str1". "mark" will be the
+ location that the cursor is about to move to, and "mark2" will be the
+ mark that will be moved.
- "Move-Line" moves the cursor (point) forward or backward some number
of lines based on the num1 argument. "render-lines" attempts to keep
the following line is prefixed with the value of the
attribute.
- active-tag:$tag If a mouse-click happens on text with this attribute,
- Activate:$tag is called with:
+ action-$name:$command If a mouse-click happens on text with this attribute,
+ then depending on the name the command will be called with:
->mark being a new mark at the location
- ->str being $tag
- ->str2 being all attributes active at the location
+ ->mark2 being the point that will be moved there.
+ ->str being all attributes at that location.
+ $name is "activate" for a mouse-1 release.
+ This command can also be triggered by calling "Action"
+ passing the name as ->str.
only on pygtk:
NN font size
static bool cond_append(struct buf *b safe, char *txt safe, char *tag safe,
int offset, int *pos safe)
{
- char *tagf = "active-tag:email-";
+ char *tagf = "action-activate:email-";
int prelen = 1 + strlen(tagf) + strlen(tag) + 1 + 1;
int postlen = 1 + 3;
int len = prelen + strlen(txt) + postlen;
call("doc:set:autoclose", docp, 1);
attr_set_str(&docp->attrs, "render-simple", "format");
attr_set_str(&docp->attrs, "heading", "");
- attr_set_str(&docp->attrs, "line-format", "<active-tag:menu-select>%name</>");
+ attr_set_str(&docp->attrs, "line-format", "<action-activate:menu-select>%name</>");
attr_set_str(&docp->attrs, "done-key", ci->str2 ?: "menu-done");
/* No borders, just a shaded background to make menu stand out */
attr_set_str(&docp->attrs, "borders", "");
key_add(menu_map, "menu-add", &menu_add);
key_add(menu_map, "K:ESC", &menu_abort);
key_add(menu_map, "K:Enter", &menu_done);
- key_add(menu_map, "Activate:menu-select", &menu_done);
+ key_add(menu_map, "menu-select", &menu_done);
}
void edlib_init(struct pane *ed safe)
attr_set_int(&m2->attrs, "emacs:track-selection", 0);
call("Move-CursorXY", ci->focus,
- 2, m, NULL, moved, NULL, NULL, ci->x, ci->y);
+ 0, m, "activate", moved, NULL, NULL, ci->x, ci->y);
/* That action might have closed a pane. Better check... */
if (ci->focus->damaged & DAMAGED_CLOSED) {
/* Do nothing */
# The "tag" leads to a pane attribute 'url:tag' which hold the full url.
#
# "render:url-view" is an overlay pane which:
-# - responds to map-attr for render:url, adding the active-tag attr
-# - handles Activate:url to also activate the url
+# - responds to map-attr for render:url, adding the action-activate attr
+# - handles Acivate:url to also activate the url
import edlib
if str1 == "render:url-end":
leng = -1
comm2("attr:callback", focus, leng, mark,
- "fg:cyan-60,underline,active-tag:url,url-tag="+tg, 120)
+ "fg:cyan-60,underline,action-activate:Activate:url,url-tag="+tg, 120)
return 1
- def handle_click(self, key, focus, mark, str2, **a):
+ def handle_click(self, key, focus, mark, str1, **a):
"handle:Activate:url"
- a = str2.split(',')
+ a = str1.split(',')
tag=""
for w in a:
if w.startswith("url-tag="):
def handle_enter(self, key, focus, mark, **a):
"handle:K:Enter"
- return focus.call("Activate", mark)
+ return focus.call("Action", "activate", mark)
edlib.editor.call("global-set-command", "url:mark-up", mark_urls)
edlib.editor.call("global-set-command", "attach-render-url-view", attach_url)
return 1
def handle_toggle_hide(self, key, focus, mark, **a):
- "handle-list/Activate:email-hide/email:select:hide"
+ "handle-list/email-hide/email:select:hide"
return self.handle_vis(focus, mark, "hide")
def handle_toggle_full(self, key, focus, mark, **a):
- "handle-list/Activate:email-full/email:select:full"
+ "handle-list/email-full/email:select:full"
return self.handle_vis(focus, mark, "full")
def handle_toggle_extras(self, key, focus, mark, **a):
- "handle-list/Activate:email-extras/email:select:extras/doc:char-X"
+ "handle-list/email-extras/email:select:extras/doc:char-X"
if not mark:
# a mark at the first "sep" part will identify the headers
mark = edlib.Mark(focus)
return 1
def handle_save(self, key, focus, mark, **a):
- "handle-list/Activate:email-save/email:select:save"
+ "handle-list/email-save/email:select:save"
file = focus.call("doc:get-attr", "multipart-prev:email:filename", mark, ret='str')
if not file:
return 1
def handle_external(self, key, focus, mark, **a):
- "handle-list/Activate:email-external view/email:select:external view"
+ "handle-list/email-external view/email:select:external view"
type = focus.call("doc:get-attr", "multipart-prev:email:content-type", mark, ret='str')
prefix = focus.call("doc:get-attr", "multipart-prev:email:prefix", mark, ret='str')
ext = focus.call("doc:get-attr", "multipart-prev:email:ext", mark, ret='str')
return 1;
}
-static char *get_active_tag(const char *a)
+static char *get_action_tag(const char *tag safe, const char *a)
{
+ int taglen = strlen(tag);
char *t;
char *c;
if (!a)
return NULL;
- t = strstr(a, ",active-tag:");
- if (!t)
- return NULL;
- t += 12;
+ do {
+ t = strstr(a, ",action-");
+ if (!t)
+ return NULL;
+ a = t+1;
+ } while (!(strncmp(t+8, tag, taglen) == 0 &&
+ t[8+taglen] == ':'));
+
+ t += 8 + taglen + 1;
c = strchr(t, ',');
return strndup(t, c?c-t: (int)strlen(t));
}
DEF_CMD(render_lines_set_cursor)
{
- /* ->num is
- * 1 if this resulted from a click
- * 2 if from a release
- * 3 if from motion
- * 0 any other reason.
+ /* ->str gives a context specific action to perform
+ * If the attributes at the location include
+ * action-$str then the value of that attribute
+ * is send as a command
*/
struct pane *p = ci->home;
struct pane *focus = ci->focus;
struct rl_data *rl = p->data;
+ const char *action = ci->str;
struct mark *m;
struct mark *m2 = NULL;
struct xy cih;
if (m2) {
char *tag, *xyattr;
- if (ci->num == 2) { /* Mouse release */
+ if (action) {
xyattr = pane_attr_get(m->mdata, "xyattr");
- tag = get_active_tag(xyattr);
- if (tag) {
- char *c = NULL;
- asprintf(&c, "Activate:%s", tag);
- if (c)
- call(c, focus, 0, m2, tag,
- 0, ci->mark, xyattr);
- free(c);
- }
+ tag = get_action_tag(action, xyattr);
+ if (tag)
+ call(tag, focus, 0, m2, xyattr,
+ 0, ci->mark);
}
m = m2;
} else {
return 1;
}
-DEF_CMD(render_lines_activate)
+DEF_CMD(render_lines_action)
{
- /* If there is an active-tag: at '->mark', send Activate:tag
+ /* If there is an action-$str: at '->mark', send the command
* to the focus
*/
struct mark *m = ci->mark;
int offset;
char *attr, *tag;
- if (!m)
+ if (!m || !ci->str)
return Enoarg;
v = vmark_first(p, rl->typenum, p);
return Efallthrough;
measure_line(p, focus, v, offset);
attr = pane_attr_get(v->mdata, "cursattr");
- tag = get_active_tag(attr);
- if (tag) {
- char *c = NULL;
- asprintf(&c, "Activate:%s", tag);
- if (c)
- call(c, focus, 0, m, tag,
- 0, NULL, attr);
- free(c);
- }
+ tag = get_action_tag(ci->str, attr);
+ if (tag)
+ call(tag, focus, 0, m, attr);
return 1;
}
/* Make it easy to stop ignoring point */
key_add(rl_map, "Abort", &render_lines_abort);
- key_add(rl_map, "Activate", &render_lines_activate);
+ key_add(rl_map, "Action", &render_lines_action);
key_add(rl_map, "Close", &render_lines_close);
key_add(rl_map, "Close:mark", &render_lines_close_mark);