X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fbuffer.rb;h=d40a6267d193cb01905c38efbf38bfad581463ba;hb=073e1f40024d7721ada08bce7c38d87883ec62f6;hp=fa1afe623592aeadf26e985186967bb2c2b91f91;hpb=ed8fb69fdee2f63aa6fc4e9e632c59cb58fcf00e;p=sup diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index fa1afe6..d40a626 100644 --- a/lib/sup/buffer.rb +++ b/lib/sup/buffer.rb @@ -177,6 +177,7 @@ EOS @textfields = {} @flash = nil @shelled = @asking = false + @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/ self.class.i_am_the_instance self end @@ -262,7 +263,7 @@ EOS get_status_and_title @focus_buf # must be called outside of the ncurses lock end - print "\033]2;#{title}\07" if title + print "\033]2;#{title}\07" if title && @in_x Ncurses.mutex.lock unless opts[:sync] == false @@ -397,7 +398,7 @@ EOS def ask_with_completions domain, question, completions, default=nil ask domain, question, default do |s| - completions.select { |x| x =~ /^#{s}/i }.map { |x| [x, x] } + completions.select { |x| x =~ /^#{Regexp::escape s}/i }.map { |x| [x, x] } end end @@ -413,7 +414,7 @@ EOS raise "william screwed up completion: #{partial.inspect}" end - completions.select { |x| x =~ /^#{target}/i }.map { |x| [prefix + x, x] } + completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] } end end @@ -422,7 +423,7 @@ EOS prefix, target = partial.split_on_commas_with_remainder target ||= prefix.pop || "" prefix = prefix.join(", ") + (prefix.empty? ? "" : ", ") - completions.select { |x| x =~ /^#{target}/i }.map { |x| [prefix + x, x] } + completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] } end end @@ -435,7 +436,7 @@ EOS if dir [[s.sub(full, dir), "~#{name}"]] else - users.select { |u| u =~ /^#{name}/ }.map do |u| + users.select { |u| u =~ /^#{Regexp::escape name}/ }.map do |u| [s.sub("~#{name}", "~#{u}"), "~#{u}"] end end @@ -454,7 +455,7 @@ EOS elsif File.directory?(answer) spawn_modal "file browser", FileBrowserMode.new(answer) else - answer + File.expand_path answer end end @@ -556,7 +557,6 @@ EOS def ask_getch question, accept=nil raise "impossible!" if @asking - @asking = true accept = accept.split(//).map { |x| x[0] } if accept @@ -569,6 +569,7 @@ EOS Ncurses.refresh end + @asking = true ret = nil done = false until done