lib/sup/buffer.rb in sup-0.4 vs lib/sup/buffer.rb in sup-0.5

- old
+ new

@@ -165,10 +165,19 @@ Variables: the same as status-bar-text hook. Return value: a string to be used as the terminal title. EOS + HookManager.register "extra-contact-addresses", <<EOS +A list of extra addresses to propose for tab completion, etc. when the +user is entering an email address. Can be plain email addresses or can +be full "User Name <email@domain.tld>" entries. + +Variables: none +Return value: an array of email address strings. +EOS + def initialize @name_map = {} @buffers = [] @focus_buf = nil @dirty = true @@ -261,11 +270,12 @@ else raise "status must be supplied if draw_screen is called within a sync" if opts[:sync] == false get_status_and_title @focus_buf # must be called outside of the ncurses lock end - print "\033]2;#{title}\07" if title && @in_x + ## http://rtfm.etla.org/xterm/ctlseq.html (see Operating System Controls) + print "\033]0;#{title}\07" if title && @in_x Ncurses.mutex.lock unless opts[:sync] == false ## disabling this for the time being, to help with debugging ## (currently we only have one buffer visible at a time). @@ -453,11 +463,11 @@ if answer.empty? spawn_modal "file browser", FileBrowserMode.new elsif File.directory?(answer) spawn_modal "file browser", FileBrowserMode.new(answer) else - answer + File.expand_path answer end end answer end @@ -490,10 +500,11 @@ recent = Index.load_contacts(AccountManager.user_emails, :num => 10).map { |c| [c.full_address, c.email] } contacts = ContactManager.contacts.map { |c| [ContactManager.alias_for(c), c.full_address, c.email] } completions = (recent + contacts).flatten.uniq.sort + completions += HookManager.run("extra-contact-addresses") || [] answer = BufferManager.ask_many_emails_with_completions domain, question, completions, default if answer answer.split_on_commas.map { |x| ContactManager.contact_for(x.downcase) || PersonManager.person_for(x) } end @@ -555,11 +566,10 @@ tf.value end def ask_getch question, accept=nil raise "impossible!" if @asking - @asking = true accept = accept.split(//).map { |x| x[0] } if accept status, title = get_status_and_title @focus_buf Ncurses.sync do @@ -568,9 +578,10 @@ Ncurses.move Ncurses.rows - 1, question.length + 1 Ncurses.curs_set 1 Ncurses.refresh end + @asking = true ret = nil done = false until done key = Ncurses.nonblocking_getch or next if key == Ncurses::KEY_CANCEL