allowed exit on escape

This commit is contained in:
Paul Wilde 2022-05-09 20:12:05 +01:00
parent bd899ebbf3
commit dced0c0438
2 changed files with 13 additions and 10 deletions

View file

@ -174,9 +174,9 @@ proc runDMenu*(data: Info, opts: varargs[string], rofi: bool = false): string =
#echo cmd
#
# Run command and get output
let output = execCmdEx(cmd)
let option:string = strip(output[0])
return option
var output = execCmdEx(cmd)
output.output.stripLineEnd()
return output.output
proc outputData*(data: Info, args: varargs[string]): string {.discardable.} =
var output = ""

View file

@ -7,15 +7,18 @@ proc doCalculation(calc: string) =
var info = newInfo("Calculator")
let ans_cmd_terse = "echo \"" & calc & "\" | qalc +u8 -terse -color=never | awk '!/^>/ && !/^$/ {gsub(/^[ \\t]+|[ \\t]+$/, \"\", $0); print}'"
let ans_cmd_full = "echo \"" & calc & "\" | qalc +u8 -color=never | awk '!/^>/ && !/^$/ {gsub(/^[ \\t]+|[ \\t]+$/, \"\", $0); print}'"
let ans_full = execCmdEx(ans_cmd_full)
let ans_terse = execCmdEx(ans_cmd_terse)
let answers = @[strip(ans_terse.output),
strip(ans_full.output)]
var ans_full = execCmdEx(ans_cmd_full)
ans_full.output.stripLineEnd()
var ans_terse = execCmdEx(ans_cmd_terse)
ans_terse.output.stripLineEnd()
let answers = @[strip(ans_full.output),
strip(ans_terse.output)]
let args = concat(answers,@["exit"])
let cmd = outputData(info, args)
var cmd = outputData(info, args)
cmd.stripLineEnd()
if cmd in answers:
discard execCmd("echo \"" & strip(cmd) & "\" | xclip")
elif cmd == "exit":
discard execCmd("echo " & quote(cmd) & " | xclip")
elif cmd == "exit" or cmd == "":
return
else:
doCalculation(cmd)