diff options
| author | Alon Levy <alon@pobox.com> | 2015-05-04 20:02:08 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-05-04 20:02:08 +0300 |
| commit | 5565dc1b1421807f242d0e402895aecbd0749851 (patch) | |
| tree | 1b6bf70783f5771058dceb20f3c1076cd4c82719 /src/client/textanalysis.js | |
| parent | 630fc2c06e774806920ac8a5ec94bce1d49651e4 (diff) | |
client: update selected type prompt based on cursor
Diffstat (limited to 'src/client/textanalysis.js')
| -rw-r--r-- | src/client/textanalysis.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/client/textanalysis.js b/src/client/textanalysis.js index 354ac760..22a11527 100644 --- a/src/client/textanalysis.js +++ b/src/client/textanalysis.js @@ -12,10 +12,8 @@ var separator_string = rz_config.separator_string; var typeindex = 0, nodetypes = model_types.nodetypes, nodetypes_count = nodetypes.length, - default_nodetype = nodetypes[0], - node_name_to_type = {}; - -util.assert(nodetypes.indexOf(default_nodetype) !== -1); + node_name_to_type = {}, + nodetype_to_index = _.object(nodetypes, _.range(nodetypes.length)); var _get_lastnode, get_lastnode = function (editgraph, cursor) { @@ -619,6 +617,11 @@ function init(main_graph) .onValue(auto_suggest__update_from_graph); } +function selected_type_set(typename) +{ + typeindex = nodetype_to_index[typename] || 0; +} + return { init:init, textAnalyser:textAnalyser, @@ -643,6 +646,7 @@ return { typeindex = (typeindex + nodetypes_count - 1) % nodetypes_count; return selectedType(); }, + selected_type_set: selected_type_set, selected_type: selectedType, }; }); |
