Working on autocompletion.
h3rald h3rald@h3rald.com
Sat, 01 Jun 2024 14:24:39 +0200
2 files changed,
15 insertions(+),
26 deletions(-)
M
minpkg/core/shell.nim
→
minpkg/core/shell.nim
@@ -42,23 +42,14 @@ if words.len == 0:
word = ed.lineText else: word = words[words.len-1] - if word.startsWith("'"): - return symbols.mapIt("'" & $it) - if word.startsWith("~"): - return symbols.mapIt("~" & $it) - if word.startsWith("?"): - return symbols.mapIt("?" & $it) - if word.startsWith("@"): - return symbols.mapIt("@" & $it) - if word.startsWith("#"): - return symbols.mapIt("#" & $it) - if word.startsWith(">"): - return symbols.mapIt(">" & $it) if word.contains("."): - let dicts = word.split(".") var op: MinOperator var dict: MinValue var path = "" + if ['?', '@', '\'', '~', '#'].contains(word[0]): + word = word[1..^1] + path &= word[0] + let dicts = word.split(".") for d in dicts: if dict.isNil: if i.scope.symbols.hasKey(d):@@ -76,10 +67,16 @@ elif op.kind == minValOp and op.val.kind == minDictionary:
dict = op.val path &= d & "." return dict.dVal.keys.toSeq.mapIt(path & it) - if word.startsWith("("): - return symbols.mapIt("(" & $it) - if word.startsWith("<"): - return toSeq(MINSYMBOLS.readFile.parseJson.pairs).mapIt("<" & $it[0]) + if word.startsWith("'"): + return symbols.mapIt("'" & $it) + if word.startsWith("~"): + return symbols.mapIt("~" & $it) + if word.startsWith("?"): + return symbols.mapIt("?" & $it) + if word.startsWith("@"): + return symbols.mapIt("@" & $it) + if word.startsWith("#"): + return symbols.mapIt("#" & $it) if word.startsWith("$"): return toSeq(envPairs()).mapIt("$" & $it[0]) if word.startsWith("\""):@@ -106,14 +103,6 @@ dir = getCurrentDir()
return toSeq(walkDir(dir, true)).filterIt( it.path.toLowerAscii.startsWith(f.toLowerAscii)).mapIt("\"$1\"" % [ it.path.replace("\\", "/")]) - if word.startsWith("*"): - let filterProc = proc (it: string): bool = - let op = i.scope.symbols[it] - if op.kind == minProcOp and not op.mdl.isNil: - return true - else: - return op.kind == minValOp and op.val.kind == minDictionary - return symbols.filter(filterProc).mapIt("*" & $it) return symbols proc p(s: string, color = fgWhite) =
M
minpkg/lib/min_global.nim
→
minpkg/lib/min_global.nim
@@ -1133,7 +1133,7 @@ else:
raiseInvalid("Cannot convert a quotation to float.") def.symbol("prompt") do (i: In): - i.eval(""""[$1]\n$$ " (.) => %""") + i.eval(""""[$1]\n$$ " (pwd) => %""") def.symbol("quotesym") do (i: In): let vals = i.expect("str")