allowed exit on escape
This commit is contained in:
parent
bd899ebbf3
commit
dced0c0438
2 changed files with 13 additions and 10 deletions
6
base.nim
6
base.nim
|
@ -174,9 +174,9 @@ proc runDMenu*(data: Info, opts: varargs[string], rofi: bool = false): string =
|
||||||
#echo cmd
|
#echo cmd
|
||||||
#
|
#
|
||||||
# Run command and get output
|
# Run command and get output
|
||||||
let output = execCmdEx(cmd)
|
var output = execCmdEx(cmd)
|
||||||
let option:string = strip(output[0])
|
output.output.stripLineEnd()
|
||||||
return option
|
return output.output
|
||||||
|
|
||||||
proc outputData*(data: Info, args: varargs[string]): string {.discardable.} =
|
proc outputData*(data: Info, args: varargs[string]): string {.discardable.} =
|
||||||
var output = ""
|
var output = ""
|
||||||
|
|
|
@ -7,15 +7,18 @@ proc doCalculation(calc: string) =
|
||||||
var info = newInfo("Calculator")
|
var info = newInfo("Calculator")
|
||||||
let ans_cmd_terse = "echo \"" & calc & "\" | qalc +u8 -terse -color=never | awk '!/^>/ && !/^$/ {gsub(/^[ \\t]+|[ \\t]+$/, \"\", $0); print}'"
|
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_cmd_full = "echo \"" & calc & "\" | qalc +u8 -color=never | awk '!/^>/ && !/^$/ {gsub(/^[ \\t]+|[ \\t]+$/, \"\", $0); print}'"
|
||||||
let ans_full = execCmdEx(ans_cmd_full)
|
var ans_full = execCmdEx(ans_cmd_full)
|
||||||
let ans_terse = execCmdEx(ans_cmd_terse)
|
ans_full.output.stripLineEnd()
|
||||||
let answers = @[strip(ans_terse.output),
|
var ans_terse = execCmdEx(ans_cmd_terse)
|
||||||
strip(ans_full.output)]
|
ans_terse.output.stripLineEnd()
|
||||||
|
let answers = @[strip(ans_full.output),
|
||||||
|
strip(ans_terse.output)]
|
||||||
let args = concat(answers,@["exit"])
|
let args = concat(answers,@["exit"])
|
||||||
let cmd = outputData(info, args)
|
var cmd = outputData(info, args)
|
||||||
|
cmd.stripLineEnd()
|
||||||
if cmd in answers:
|
if cmd in answers:
|
||||||
discard execCmd("echo \"" & strip(cmd) & "\" | xclip")
|
discard execCmd("echo " & quote(cmd) & " | xclip")
|
||||||
elif cmd == "exit":
|
elif cmd == "exit" or cmd == "":
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
doCalculation(cmd)
|
doCalculation(cmd)
|
||||||
|
|
Loading…
Reference in a new issue