X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;ds=sidebyside;f=lib%2Fsup%2Fbuffer.rb;h=f053f676e53262f2680c52b46fb21134d437d69e;hb=aa5608229171a78694c64d0a30375e765ffe86e0;hp=cb61e12ffd19df6a2ccc0a2df7c54ec80066938e;hpb=697763248dd4fdbaaf2d0702358e67cc3d45f37e;p=sup diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index cb61e12..f053f67 100644 --- a/lib/sup/buffer.rb +++ b/lib/sup/buffer.rb @@ -108,10 +108,16 @@ class Buffer @w.attrset Colormap.color_for(opts[:color] || :none, opts[:highlight]) s ||= "" - maxl = @width - x - @w.mvaddstr y, x, s[0 ... maxl] - unless s.length >= maxl || opts[:no_fill] - @w.mvaddstr(y, x + s.length, " " * (maxl - s.length)) + maxl = @width - x # maximum display width width + stringl = maxl # string "length" + ## the next horribleness is thanks to ruby's lack of widechar support + stringl += 1 while stringl < s.length && s[0 ... stringl].display_length < maxl + @w.mvaddstr y, x, s[0 ... stringl] + unless opts[:no_fill] + l = s.display_length + unless l >= maxl + @w.mvaddstr(y, x + l, " " * (maxl - l)) + end end end @@ -190,8 +196,6 @@ EOS @flash = nil @shelled = @asking = false @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/ - - self.class.i_am_the_instance self end def buffers; @name_map.to_a; end @@ -462,7 +466,7 @@ EOS end if answer - answer = + answer = if answer.empty? spawn_modal "file browser", FileBrowserMode.new elsif File.directory?(answer) @@ -478,7 +482,7 @@ EOS ## returns an array of labels def ask_for_labels domain, question, default_labels, forbidden_labels=[] default_labels = default_labels - forbidden_labels - LabelManager::RESERVED_LABELS - default = default_labels.join(" ") + default = default_labels.to_a.join(" ") default += " " unless default.empty? # here I would prefer to give more control and allow all_labels instead of @@ -489,7 +493,7 @@ EOS return unless answer - user_labels = answer.split(/\s+/).map { |l| l.intern } + user_labels = answer.to_set_of_symbols user_labels.each do |l| if forbidden_labels.include?(l) || LabelManager::RESERVED_LABELS.include?(l) BufferManager.flash "'#{l}' is a reserved label!" @@ -502,7 +506,7 @@ EOS def ask_for_contacts domain, question, default_contacts=[] default = default_contacts.map { |s| s.to_s }.join(" ") default += " " unless default.empty? - + 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] } @@ -717,6 +721,7 @@ EOS Ncurses.sync do Ncurses.endwin system command + Ncurses.stdscr.keypad 1 Ncurses.refresh Ncurses.curs_set 0 end