bin/sup in sup-0.7 vs bin/sup in sup-0.8

- old
+ new

@@ -6,11 +6,11 @@ require 'fileutils' require 'trollop' require 'fastthread' require "sup" -BIN_VERSION = "0.7" +BIN_VERSION = "0.8" unless Redwood::VERSION == BIN_VERSION $stderr.puts <<EOS Error: version mismatch! @@ -65,13 +65,13 @@ global_keymap = Keymap.new do |k| k.add :quit_ask, "Quit Sup, but ask first", 'q' k.add :quit_now, "Quit Sup immediately", 'Q' k.add :help, "Show help", '?' k.add :roll_buffers, "Switch to next buffer", 'b' -# k.add :roll_buffers_backwards, "Switch to previous buffer", 'B' + k.add :roll_buffers_backwards, "Switch to previous buffer", 'B' k.add :kill_buffer, "Kill the current buffer", 'x' - k.add :list_buffers, "List all buffers", 'B' + k.add :list_buffers, "List all buffers", ';' k.add :list_contacts, "List contacts", 'C' k.add :redraw, "Redraw screen", :ctrl_l k.add :search, "Search all messages", '\\', 'F' k.add :search_unread, "Show all unread messages", 'U' k.add :list_labels, "List labels", 'L' @@ -79,15 +79,46 @@ k.add :compose, "Compose new message", 'm', 'c' k.add :nothing, "Do nothing", :ctrl_g k.add :recall_draft, "Edit most recent draft message", 'R' end +## the following magic enables wide characters when used with a ruby +## ncurses.so that's been compiled against libncursesw. (note the w.) why +## this works, i have no idea. much like pretty much every aspect of +## dealing with curses. cargo cult programming at its best. +## +## BSD users: if libc.so.6 is not found, try installing compat6x. +require 'dl/import' +module LibC + extend DL::Importable + setlocale_lib = case Config::CONFIG['arch'] + when /darwin/; "libc.dylib" + when /cygwin/; "cygwin1.dll" + else; "libc.so.6" + end + + Redwood::log "dynamically loading setlocale() from #{setlocale_lib}" + begin + dlload setlocale_lib + extern "void setlocale(int, const char *)" + Redwood::log "setting locale..." + LibC.setlocale(6, "") # LC_ALL == 6 + rescue RuntimeError => e + Redwood::log "cannot dlload setlocale(); ncurses wide character support probably broken." + Redwood::log "dlload error was #{e.class}: #{e.message}" + if Config::CONFIG['arch'] =~ /bsd/ + Redwood::log "BSD variant detected. You may have to install a compat6x package to acquire libc." + end + end +end + def start_cursing Ncurses.initscr Ncurses.noecho Ncurses.cbreak Ncurses.stdscr.keypad 1 + Ncurses.use_default_colors Ncurses.curs_set 0 Ncurses.start_color $cursing = true end @@ -227,21 +258,21 @@ when :roll_buffers_backwards bm.roll_buffers_backwards when :kill_buffer bm.kill_buffer_safely bm.focus_buf when :list_buffers - bm.spawn_unless_exists("Buffer List") { BufferListMode.new } + bm.spawn_unless_exists("buffer list", :system => true) { BufferListMode.new } when :list_contacts b, new = bm.spawn_unless_exists("Contact List") { ContactListMode.new } b.mode.load_in_background if new when :search query = BufferManager.ask :search, "search all messages: " next unless query && query !~ /^\s*$/ SearchResultsMode.spawn_from_query query when :search_unread SearchResultsMode.spawn_from_query "is:unread" when :list_labels - labels = LabelManager.listable_labels.map { |l| LabelManager.string_for l } + labels = LabelManager.all_labels.map { |l| LabelManager.string_for l } user_label = bm.ask_with_completions :label, "Show threads with label (enter for listing): ", labels unless user_label.nil? if user_label.empty? bm.spawn_unless_exists("Label list") { LabelListMode.new } if user_label && user_label.empty? else