Skip to content

Commit

Permalink
aisingapore#465 - support escape chars in live mode, eg '
Browse files Browse the repository at this point in the history
this change adds support for escape characters in live mode, for eg when using keyboard step ' will give error and requires creative syntax to type a '

idea for solution is from solving a similar problem during recent development of personal side project - tagui for python
  • Loading branch information
kensoh committed Jun 25, 2019
1 parent c50ba1f commit a529e55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/tagui_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,9 @@ source_string = source_string.replace(/\+\+\+\+\+/g,'+'); source_string = source
source_string = source_string.replace(/\+\+\+/g,'+'); source_string = source_string.replace(/\+\+/g,'+');
return source_string;} // replacing multiple variations of + to handle user typos of double spaces etc

function escape_bs(input_string) { // helper function to escape backslash characters
return input_string.replace(/\\/g,'\\\\');}
function escape_bs(input_string) { // helper function to escape backslash characters and friends
escaped_string = input_string.replace(/\\/g,'\\\\').replace(/\'/g,'\\\'').replace(/\n/g,'\\n').replace(/\r/g,'\\r');
return escaped_string.replace(/\t/g,'\\t').replace(/\f/g,'\\f').replace(/\v/g,'\\v').replace(/\"/g,'\\\"');}

function is_coordinates(input_params) { // helper function to check if string is (x,y) coordinates
if ((input_params.length > 4) && (input_params.substr(0,1) == '(') && (input_params.substr(-1) == ')')
Expand Down
5 changes: 3 additions & 2 deletions src/test/positive_test.signature
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,9 @@ source_string = source_string.replace(/\+\+\+\+\+/g,'+'); source_string = source
source_string = source_string.replace(/\+\+\+/g,'+'); source_string = source_string.replace(/\+\+/g,'+');
return source_string;} // replacing multiple variations of + to handle user typos of double spaces etc

function escape_bs(input_string) { // helper function to escape backslash characters
return input_string.replace(/\\/g,'\\\\');}
function escape_bs(input_string) { // helper function to escape backslash characters and friends
escaped_string = input_string.replace(/\\/g,'\\\\').replace(/\'/g,'\\\'').replace(/\n/g,'\\n').replace(/\r/g,'\\r');
return escaped_string.replace(/\t/g,'\\t').replace(/\f/g,'\\f').replace(/\v/g,'\\v').replace(/\"/g,'\\\"');}

function is_coordinates(input_params) { // helper function to check if string is (x,y) coordinates
if ((input_params.length > 4) && (input_params.substr(0,1) == '(') && (input_params.substr(-1) == ')')
Expand Down

0 comments on commit a529e55

Please sign in to comment.