class GitPrepareBranch::Screen
Attributes
context[RW]
description[RW]
display[RW]
heading[RW]
heading_style[RW]
name[R]
title[RW]
Public Class Methods
new(name)
click to toggle source
# File lib/git-prepare-branch/screen.rb, line 11 def initialize(name) @name = name end
Public Instance Methods
add_command(key, name, command, options={})
click to toggle source
# File lib/git-prepare-branch/screen.rb, line 15 def add_command(key, name, command, options={}) commands[key] = Command.new(key, name, command, options) end
commands()
click to toggle source
# File lib/git-prepare-branch/screen.rb, line 19 def commands @commands ||= {} end
handle_keypress(key, context)
click to toggle source
# File lib/git-prepare-branch/screen.rb, line 23 def handle_keypress key, context help if ['h', '?'].include?(key) exit if ['q', CommandKeys::CTRL_C, CommandKeys::CTRL_D].include?(key) return unless commands.keys.include?(key) commands[key].call(context) end
help()
click to toggle source
# File lib/git-prepare-branch/screen.rb, line 30 def help terminal.clear terminal.say "DESCRIPTION" terminal.hr terminal.say "#{description}\n\n" terminal.say "COMMANDS" terminal.hr commands.each_with_object('') do |(key, command), result| terminal.say "#{key} #{command.name.ljust(longest_command_name_length)} #{command.description}" terminal.say "\n" end terminal.prompt_to_continue end
longest_command_name_length()
click to toggle source
# File lib/git-prepare-branch/screen.rb, line 44 def longest_command_name_length @longest_command_name_length ||= commands.collect{|(_, c)| c.name.length}.max end
Private Instance Methods
terminal()
click to toggle source
# File lib/git-prepare-branch/screen.rb, line 50 def terminal context.terminal end