attempt to add nested tab completion
parent
7f90082bec
commit
3c44769bd8
|
@ -2452,9 +2452,8 @@ class Core
|
||||||
|
|
||||||
def cmd_grep_tabs(str, words)
|
def cmd_grep_tabs(str, words)
|
||||||
# @todo, make sure this works, just guessed to start
|
# @todo, make sure this works, just guessed to start
|
||||||
tabs = []
|
tabs = @@grep_opts.fmt.keys || [] # default to use grep's options
|
||||||
tabs += @@grep_opts.fmt.keys if (str and not str =~ /\w/)
|
tabs = driver.tab_complete(str, words) if (str and str =~ /\w/) # if not an opt, use normal tab comp.
|
||||||
#tabs += driver.tab_complete_stub(str)
|
|
||||||
tabs
|
tabs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ module DispatcherShell
|
||||||
# a design problem in the Readline module and depends on the
|
# a design problem in the Readline module and depends on the
|
||||||
# Readline.basic_word_break_characters variable being set to \x00
|
# Readline.basic_word_break_characters variable being set to \x00
|
||||||
#
|
#
|
||||||
def tab_complete(str)
|
def tab_complete(str, previous_words = [])
|
||||||
# Check trailing whitespace so we can tell 'x' from 'x '
|
# Check trailing whitespace so we can tell 'x' from 'x '
|
||||||
str_match = str.match(/\s+$/)
|
str_match = str.match(/\s+$/)
|
||||||
str_trail = (str_match.nil?) ? '' : str_match[0]
|
str_trail = (str_match.nil?) ? '' : str_match[0]
|
||||||
|
@ -288,13 +288,13 @@ module DispatcherShell
|
||||||
self.tab_words = str_words
|
self.tab_words = str_words
|
||||||
|
|
||||||
# Pop the last word and pass it to the real method
|
# Pop the last word and pass it to the real method
|
||||||
tab_complete_stub(self.tab_words.pop)
|
tab_complete_stub(self.tab_words.pop, previous_words)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Performs tab completion of a command, if supported
|
# Performs tab completion of a command, if supported
|
||||||
# Current words can be found in self.tab_words
|
# Current words can be found in self.tab_words
|
||||||
#
|
#
|
||||||
def tab_complete_stub(str)
|
def tab_complete_stub(str, previous_words = [])
|
||||||
items = []
|
items = []
|
||||||
|
|
||||||
return nil if not str
|
return nil if not str
|
||||||
|
@ -333,15 +333,15 @@ module DispatcherShell
|
||||||
str = Regexp.escape(str)
|
str = Regexp.escape(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
# XXX - This still doesn't fix some Regexp warnings:
|
# @todo - This still doesn't fix some Regexp warnings:
|
||||||
# ./lib/rex/ui/text/dispatcher_shell.rb:171: warning: regexp has `]' without escape
|
# ./lib/rex/ui/text/dispatcher_shell.rb:171: warning: regexp has `]' without escape
|
||||||
|
|
||||||
# Match based on the partial word
|
# Match based on the partial word
|
||||||
items.find_all { |e|
|
items.find_all { |e|
|
||||||
e =~ /^#{str}/
|
e =~ /^#{str}/
|
||||||
# Prepend the rest of the command (or it gets replaced!)
|
# Prepend the rest of the command, and all previous_words (or it all gets replaced!)
|
||||||
}.map { |e|
|
}.map { |e|
|
||||||
tab_words.dup.push(e).join(' ')
|
(previous_words + tab_words).push(e).join(' ')
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue