Class: RETerm::Components::Entry

Inherits:
RETerm::Component show all
Includes:
RETerm::CDKComponent
Defined in:
lib/reterm/components/entry.rb

Overview

CDK Entry Component

Direct Known Subclasses

PasswordEntry

Constant Summary

Constants included from LogHelpers

LogHelpers::LOG_FILE

Instance Attribute Summary collapse

Attributes inherited from RETerm::Component

#activatable, #activate_focus, #highlight_focus, #window

Instance Method Summary collapse

Methods included from RETerm::CDKComponent

#activatable?, #activate!, #bind_key, #cdk?, #colors=, #component, #deactivate!, #draw!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=

Methods inherited from RETerm::Component

#activatable?, #activate!, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch

Methods included from KeyBindings

#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?

Methods included from LogHelpers

#logger

Methods included from EventDispatcher

#dispatch, #handle

Constructor Details

#initialize(args = {}) ⇒ Entry

Initialize the Entry component

Parameters:

  • args (Hash) (defaults to: {})

    entry params

Options Hash (args):

  • :title (String)

    title to assign to entry

  • :label (String)

    label to assign to entry

  • :min (Integer)

    min entry length

  • :max (Integer)

    max entry length

[View source]

18
19
20
21
22
23
24
25
# File 'lib/reterm/components/entry.rb', line 18

def initialize(args={})
  super
  @title    = args[:title] || ""
  @label    = args[:label] || ""
  @min_len  = args[:min]   || 0
  @max_len  = args[:max]   || 100
  @min_size = args[:size]  || 0
end

Instance Attribute Details

#titleObject

Returns the value of attribute title.


7
8
9
# File 'lib/reterm/components/entry.rb', line 7

def title
  @title
end

Instance Method Details

#requested_colsObject

[View source]

31
32
33
# File 'lib/reterm/components/entry.rb', line 31

def requested_cols
  [@title.size, @label.size, @min_size].max + 3
end

#requested_rowsObject

[View source]

27
28
29
# File 'lib/reterm/components/entry.rb', line 27

def requested_rows
  5
end

#valueObject

[View source]

35
36
37
# File 'lib/reterm/components/entry.rb', line 35

def value
  component.getValue
end

#value=(v) ⇒ Object

[View source]

39
40
41
# File 'lib/reterm/components/entry.rb', line 39

def value=(v)
  component.setValue(v)
end