Skip to content

Commit

Permalink
add labeled arguments and some UI polish
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.textmate.org/trunk/Bundles/OCaml Experimental Completions.tmbundle@6532 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
David Powers committed Feb 5, 2007
1 parent 7e0be06 commit 4ecb820
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions Commands/Complete vals.tmCommand
Expand Up @@ -60,22 +60,37 @@ def convert_to_snippet str
if last == '-' and depth == 0 if last == '-' and depth == 0
args << token.join.chomp('-').strip args << token.join.chomp('-').strip
token = [] token = []
else
token << c
end end
else else
token << c token << c
end end
last = c last = c
end end
args << token.join.chomp('-').strip i = 1
args = args.map_i { |i, a| "\$\{#{i+1}:#{e_sn(a.strip)}\}" } args = args.map do |a|
a.strip!
i += 1
if a =~ /^\S+:/
if a =~ /^\?/
i += 1
"\$\{#{i - 1}:~#{a[/^\S+:/]}\$\{#{i}:#{e_sn(a[/:(.*)$/, 1])}\}}"
else
"~#{a[/^\S+:/]}\$\{#{i}:#{e_sn(a[/:(.*)$/, 1])}\}"
end
else
"\$\{#{i}:#{e_sn(a)}\}"
end
end
snippet = "#{funname} #{args.join(' ')}" snippet = "#{funname} #{args.join(' ')}"
e_sn($line[0...$linepos]) + snippet + e_sn($line[$linepos..-1]) e_sn($line[0...$linepos]) + snippet + e_sn($line[$linepos..-1])
end end
modulename = extract_module_from_line modulename = extract_module_from_line
possible_completions = OCamlCompletion::cmigrep('.', :values, [modulename]).split(/\n/) possible_completions = OCamlCompletion::cmigrep('.', :values, [modulename]).split(/\n/).select { |l| l !~ /^(from file|external)/ }.sort.uniq
possible_completions = possible_completions.map do |c| possible_completions = possible_completions.map do |c|
chash = Hash.new chash = Hash.new
chash['completion'] = c chash['completion'] = c
Expand All @@ -93,7 +108,9 @@ choice = PropertyList.load(cio.read)
if !choice['returnButton'] || choice['returnButton'] != 'Cancel' if !choice['returnButton'] || choice['returnButton'] != 'Cancel'
selection = choice['result']['returnArgument'].to_i selection = choice['result']['returnArgument'].to_i
snippettxt = plist['possibleCompletions'][selection]['completion'] snippettxt = plist['possibleCompletions'][selection]['completion']
puts convert_to_snippet(snippettxt) print convert_to_snippet(snippettxt)
else
print e_sn($line)
end end
</string> </string>
<key>fallbackInput</key> <key>fallbackInput</key>
Expand Down
Binary file modified Support/nibs/CompletionsWindow.nib/keyedobjects.nib
Binary file not shown.

0 comments on commit 4ecb820

Please sign in to comment.