You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
" inserts a quote, displayed as ", printed as \", treated as a single char in text navigation.
\ opens a menu, \n inserts a newline, displayed as \n, printed as \n, treated as a single char in text navigation.
\\ inserts a backslash, displayed as ⫽, represented as \\, printed as \\, treated as a single char in text navigation.
Data Structures
Each texty construct has a replacement table (one table may be shared by multiple constructs):
- A string entry has a src and display string, saying that occurrences of src in source text should be treated as a single character, and displayed as display.
- A regex entry has a src Regex and a display template. The template can use $n to refer to the regex's n'th capture group. Behaves like the (potentially infinite) set of string replacements that stands for.
- A ban list gives a set of characters that may start escape sequences and cannot be entered on their own.
Each Text has:
A source string, and an index into it.
An optional display string and an index into it. If None, it's implied to be identical to the source string.
Code
To navigate right, check if there's a source pattern in the replacement table for this construct. If so, skip that many bytes in the source string and a number of bytes equal to the size of the replacement in the display string.
To navigate left, do the same but checking if something in the replacement table matches on the left. This is annoying for Regexes: each Regex will need a compiled version that starts with $ and one that ends with ^.
To delete, do the same as navigating left, but modify the string to remove the matches.
To insert a single character, call Text.insert_char(), which errors if the character is in the ban list.
To insert an escape sequence, call Text.insert_escape_sequence(), which errors if the sequence does not match something in the replacement table. If it does match, it inserts the src&display matches into the src&display strings. (And sets the display string to Some if it was None.)
Text.as_str() becomes Text.as_source_str() and Text.as_display_str(). If the display string is None, as_display_str() references the source string (as they're implied to be equal).
unwrap_text() returns as_source_str() or as_display_str() depending on the mode.
path_to_root() also returns either as_source_str() or as_display_str() depending on the mode. I think.
The text was updated successfully, but these errors were encountered:
Desired Behavior
In a JSON string:
"
inserts a quote, displayed as"
, printed as\"
, treated as a single char in text navigation.\
opens a menu,\n
inserts a newline, displayed as\n
, printed as\n
, treated as a single char in text navigation.\\
inserts a backslash, displayed as⫽
, represented as\\
, printed as\\
, treated as a single char in text navigation.Data Structures
- A string entry has a
src
anddisplay
string, saying that occurrences ofsrc
in source text should be treated as a single character, and displayed asdisplay
.- A regex entry has a
src
Regex and adisplay
template. The template can use$n
to refer to the regex's n'th capture group. Behaves like the (potentially infinite) set of string replacements that stands for.- A ban list gives a set of characters that may start escape sequences and cannot be entered on their own.
None
, it's implied to be identical to the source string.Code
$
and one that ends with^
.Text.insert_char()
, which errors if the character is in the ban list.Text.insert_escape_sequence()
, which errors if the sequence does not match something in the replacement table. If it does match, it inserts the src&display matches into the src&display strings. (And sets the display string toSome
if it wasNone
.)Text.as_str()
becomesText.as_source_str()
andText.as_display_str()
. If the display string is None,as_display_str()
references the source string (as they're implied to be equal).unwrap_text()
returnsas_source_str()
oras_display_str()
depending on the mode.path_to_root()
also returns eitheras_source_str()
oras_display_str()
depending on the mode. I think.The text was updated successfully, but these errors were encountered: