Exemplo n.º 1
0
def add_children_on_expanded(asker, old, new, bindings):
    children = []
    for p in lists.iterator(asker, lists.from_dict(bindings)):
        k = asker.ask(fields.get_field(first(), p)).firm_answer
        v = asker.ask(fields.get_field(second(), p)).firm_answer
        prefix = strings.string_concat(k, T.from_str(": "))
        new_node = node_from_term(asker, v)
        new_node = updates.update(
            updates.apply_to(headline(), strings.prepend_str(prefix)),
            new_node
        )
        children.append(new_node)
    return asker.reply(answer=updates.update(
        fields.set_field(all_children(), T.from_list(children)), 
        new
    ))
Exemplo n.º 2
0
def outline_to_lines(asker, root):
    debug()
    result = asker.ask(fields.get_field(cached_lines(), root)).answer
    if result is not None:
        return asker.reply(answer=result)
    base_headline = asker.ask(fields.get_field(headline(), root)).firm_answer
    root = asker.refresh(root)
    prefix = "* " if convert.check_hard(asker, is_pointer(), root) else "  "
    full_headline = strings.string_concat(T.from_str(prefix), base_headline)
    root = asker.refresh(root)
    children = asker.ask(fields.get_field(visible_children(), root)).firm_answer
    body = empty_lines()
    for child in lists.iterator(asker, children):
        section = asker.ask(outline_to_lines(child)).firm_answer
        body = concat_lines(body, section)
    result = concat_lines(one_line(full_headline), indent_lines(body))
    asker.update(updates.set_field(cached_lines(), result), root)
    return asker.reply(answer=result)