class BBS::Editor::Chrome
What the editor draws round the text: the reversed title bar with the count of characters, and the bottom row with the key hints or the save-or-quit question. Each method returns the bytes to write, moving a BBS::Cursor.
Public Class Methods
# File lib/bbs/editor/chrome.rb, line 16 def initialize(cursor, title:, single_line:, max:, cols:, rows:) @cursor = cursor @title = title @single = single_line @max = max @cols = cols @rows = rows @count = nil end
Draws for cursor (a BBS::Cursor) on a screen cols × rows.
- title
-
the text of the title bar
- single_line
-
whether RETURN saves, which the hints tell
- max
-
the most characters the text may hold, or
nilfor no count
Public Instance Methods
Source
# File lib/bbs/editor/chrome.rb, line 40 def count(length) return '' unless @max count = "#{length}/#{@max} ".rjust("#{@max}/#{@max} ".length) return '' if count == @count @count = count out = @cursor.move(1, @cols - 1 - count.length) @cursor.wrote(count.length + 1) "#{out}#{Ansi::REVERSE} #{count}#{Ansi::REVERSE_OFF}" end
The count of length characters at the right of the title bar, when there is a limit; empty when there is none or it shows already.
Source
# File lib/bbs/editor/chrome.rb, line 30 def hints menu = @cursor.petscii? ? 'STOP/←' : 'Esc' bottom(@single ? "#{enter_key} save #{menu} quit" : "#{menu}: save or quit") end
The bottom row with the key hints.
Source
# File lib/bbs/editor/chrome.rb, line 36 def question = bottom("S save Q quit #{enter_key} back")
The bottom row asking whether to save or quit.
Source
# File lib/bbs/editor/chrome.rb, line 27 def title = reversed(@title)
The title bar, written at the cursor (the top left).