From 5565dc1b1421807f242d0e402895aecbd0749851 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 4 May 2015 20:02:08 +0300 Subject: client: update selected type prompt based on cursor --- src/client/textanalysis.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/client/textanalysis.js') 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, }; }); -- cgit v1.3.1