Rather than 0 for continue and non-zero for stop,
use Efalse for don't continue, Errors for abort,
and normal values for continue.
This makes it similar to event handlers which stop being called after
Efalse.
Also cause a False return from python code to be Efalse.
Signed-off-by: NeilBrown <neil@brown.name>
{
struct docs *doc = ci->home->doc_data;
struct pane *p;
{
struct docs *doc = ci->home->doc_data;
struct pane *p;
list_for_each_entry(p, &doc->collection->children, siblings) {
int r;
r = comm_call(ci->comm2, "callback:doc", p);
list_for_each_entry(p, &doc->collection->children, siblings) {
int r;
r = comm_call(ci->comm2, "callback:doc", p);
+ if (r > ret)
+ ret = r;
+ if (r == Efalse)
+ return ret;
+ if (r < Efalse)
}
DEF_CMD(docs_callback_choose)
}
DEF_CMD(docs_callback_choose)
else if (PyLong_Check(ret))
rv = PyLong_AsLong(ret);
else if (PyBool_Check(ret))
else if (PyLong_Check(ret))
rv = PyLong_AsLong(ret);
else if (PyBool_Check(ret))
+ rv = (ret == Py_True) ? 1 : Efalse;
else if (PyUnicode_Check(ret) && PyUnicode_GET_LENGTH(ret) >= 1)
rv = CHAR_RET(PyUnicode_READ_CHAR(ret, 0));
else
else if (PyUnicode_Check(ret) && PyUnicode_GET_LENGTH(ret) >= 1)
rv = CHAR_RET(PyUnicode_READ_CHAR(ret, 0));
else
* So return this one and keep looking.
*/
h->ret = p;
* So return this one and keep looking.
*/
h->ret = p;
} else {
/* Want the pane that is after nothing, so
* the first. This one. All done.
*/
h->ret = p;
} else {
/* Want the pane that is after nothing, so
* the first. This one. All done.
*/
h->ret = p;
}
}
name = pane_attr_get(ci->focus, "doc-name");
if (!name)
}
}
name = pane_attr_get(ci->focus, "doc-name");
if (!name)
if (strcmp(name, h->name) == 0) {
if (h->want_prev) {
/* Want the previous one, which is
* already in ->ret
*/
if (strcmp(name, h->name) == 0) {
if (h->want_prev) {
/* Want the previous one, which is
* already in ->ret
*/
} else {
/* Want the next one, so clear name
* and keep going.
*/
h->name = NULL;
} else {
/* Want the next one, so clear name
* and keep going.
*/
h->name = NULL;
}
} else {
if (h->want_prev) {
/* This might be what I want - keep it in case */
h->ret = p;
}
} else {
if (h->want_prev) {
/* This might be what I want - keep it in case */
h->ret = p;
} else {
/* Don't want this - just keep going */
} else {
/* Don't want this - just keep going */
def each_doc(self, key, focus, **a):
if self.docs_scanned > 5:
# already handle 5 docs - stop now
def each_doc(self, key, focus, **a):
if self.docs_scanned > 5:
# already handle 5 docs - stop now
if focus['doc-name'] == self['doc-name']:
if focus['doc-name'] == self['doc-name']:
if "text" not in focus["doc-type"]:
if "text" not in focus["doc-type"]:
self.docs_scanned += 1
self.gather_completions(focus, None)
self.docs_scanned += 1
self.gather_completions(focus, None)
def next_completion(self, dir):
if self.current < 0:
def next_completion(self, dir):
if self.current < 0:
focus = a['focus']
if focus.notify("doc:done", "test") > 0:
choice.append(focus)
focus = a['focus']
if focus.notify("doc:done", "test") > 0:
choice.append(focus)
+ return False
+ return 1
focus.call("docs:byeach", lambda key,**a:choose(choice, a))
if len(choice):
par = focus.call("ThisPane", ret='pane')
focus.call("docs:byeach", lambda key,**a:choose(choice, a))
if len(choice):
par = focus.call("ThisPane", ret='pane')
focus = a['focus']
if focus['email-sent'] == 'no':
choice.append(focus)
focus = a['focus']
if focus['email-sent'] == 'no':
choice.append(focus)
+ return False
+ return 1
focus.call("docs:byeach", lambda key,**a:choose(choice, a))
if len(choice):
par = focus.call("PopupTile", "MD3tsa", ret='pane')
focus.call("docs:byeach", lambda key,**a:choose(choice, a))
if len(choice):
par = focus.call("PopupTile", "MD3tsa", ret='pane')
focus = a['focus']
if focus['email-sent'] == 'no':
choice.append(focus)
focus = a['focus']
if focus['email-sent'] == 'no':
choice.append(focus)
+ return False
+ return 1
focus.call("docs:byeach", lambda key,**a:choose(choice, a))
if len(choice):
par = focus.call("ThisPane", ret='pane')
focus.call("docs:byeach", lambda key,**a:choose(choice, a))
if len(choice):
par = focus.call("ThisPane", ret='pane')