Skip to content

Commit

Permalink
REPL: support setting sl and tl by :set (fix #451)
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Sep 30, 2022
1 parent 3dcc122 commit a5e0166
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion include/REPL.awk
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function prompt( i, p, temp) {
# %s : source languages, separated by "+"
# 's' is the format-control character for string

# %S : source languages (English names), seperated by "+"
# %S : source languages (English names), separated by "+"
if (p ~ /%S/) {
temp = getName(Option["sls"][1])
for (i = 2; i <= length(Option["sls"]); i++)
Expand Down Expand Up @@ -144,6 +144,15 @@ function repl(line, command, group, name, i, value, words) {
name = words[2]
value = words[3]
Option[name] = value
# :set sl and :set tl should work as intended
# TODO: support multiple language codes
if (name == "sl") {
delete Option["sls"]
Option["sls"][1] = Option["sl"]
} else if (name == "tl") {
delete Option["tl"]
Option["tl"][1] = value
}
} else if (command ~ /^:show$/) {
name = words[2]
print prettify("welcome-submessage", toString(Option[name], 1, 0, 1))
Expand All @@ -155,6 +164,8 @@ function repl(line, command, group, name, i, value, words) {
value = words[2]
Option["engine"] = value
initHttpService()
} else if (command ~ /^:reset$/) {
# TODO: reset source and target languages, etc.
} else {
match(command, /^[{(\[]?((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)[})\]]?$/, group)
if (RSTART) {
Expand Down

0 comments on commit a5e0166

Please sign in to comment.