diff options
| author | hallgren <hallgren@chalmers.se> | 2012-03-19 15:24:35 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2012-03-19 15:24:35 +0000 |
| commit | 0d57b9fa091c13fcfc5e2779dab23734435c0341 (patch) | |
| tree | 61705457264ed0680b39120e9b96c88e4225d162 /src | |
| parent | 428c2184fa1443842ccce99a4a802f21d783021f (diff) | |
minibar: word-for-word replacement fix
Turn off the highlighting that indicates that word-for-word replacement is
enabled when it is no longer available (e.g if a word is deleted and there no
longer is a complete parse).
Diffstat (limited to 'src')
| -rw-r--r-- | src/www/minibar/minibar_input.js | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/www/minibar/minibar_input.js b/src/www/minibar/minibar_input.js index a1f4a3aec..a2f72bde1 100644 --- a/src/www/minibar/minibar_input.js +++ b/src/www/minibar/minibar_input.js @@ -73,12 +73,20 @@ Input.prototype.change_language=function () { } -Input.prototype.clear_all1=function() { +Input.prototype.clear_all2=function() { with(this) { - remove_typed_input(); current.input=""; previous=null; - surface.innerHTML=""; + clear(surface) + if(surface.typed) surface.appendChild(surface.typed) + } +} + + +Input.prototype.clear_all1=function() { + with(this) { + remove_typed_input(); + clear_all2(); translations.clear(); } } @@ -224,12 +232,14 @@ Input.prototype.generate_random=function() { } Input.prototype.add_words=function(s) { - with(this) { - var ws=s.split(" "); - for(var i=0;i<ws.length;i++) - add_word1(ws[i]+" "); - get_completions(); - } + this.add_words1(s); + this.get_completions(); +} + +Input.prototype.add_words1=function(s) { + var ws=s.split(" "); + for(var i=0;i<ws.length;i++) + if(ws[i]) this.add_word1(ws[i]+" "); } Input.prototype.word=function(s) { @@ -294,6 +304,7 @@ Input.prototype.get_tree1=function(parse_output) { && parse_output[0].trees.length==1) server.linearize({to:current.from,tree:parse_output[0].trees[0]}, bind(get_tree2,this)); + else end_structural_editing(); } } @@ -303,6 +314,17 @@ Input.prototype.get_tree2=function(lin) { && lin[0].text+" "==current.input && lin[0].brackets) enable_structural_editing(lin[0].brackets) + else end_structural_editing(); + } +} + +Input.prototype.end_structural_editing=function() { + var t=this; + if(t.surface.structural_editing_enabled) { + var s=t.current.input; + t.clear_all2() + t.add_words1(s); + t.surface.structural_editing_enabled=false; } } @@ -323,6 +345,7 @@ Input.prototype.enable_structural_editing=function(brackets) { var typed=surface.typed; surface.innerHTML=""; add_bs(brackets); + t.surface.structural_editing_enabled=true; if(typed) surface.appendChild(typed); } } |
