Class: Window

Inherits:
Object show all
Defined in:
lib/xiki/window.rb

Class Method Summary collapse

Class Method Details

.adjust(type, direction) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/xiki/window.rb', line 85

def self.adjust type, direction

  if type == "size"
    case direction
    when "wider"; View.frame_width += 1
    when "narrower"; View.frame_width -= 1
    when "taller"; View.frame_height += 1
    when "shorter"; View.frame_height -= 1
    end

  elsif type == "wider"

  end

  nil

end

.colorizedObject



119
120
121
122
123
# File 'lib/xiki/window.rb', line 119

def self.colorized
  View.kill if View.file.nil?
  Styles.toggle
  nil
end

.dimensions(action = nil, preset = nil) ⇒ Object

Show dimension options, and invoke corresponding proc



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/xiki/window.rb', line 32

def self.dimensions action=nil, preset=nil

  if action == "current"
    # width, height, left, top
    return "#{View.frame_width}, #{View.frame_height}, #{$el.frame_parameter(nil, :left)}, #{$el.frame_parameter(nil, :top)}"
  end

  txt = File.read(File.expand_path("#{Xiki.dir}menu/dimensions_config.menu"))

  txt.sub! /\n\n.+/m, "\n"

  txt = txt.split("\n")

  # Any after blank line will be ignored


  # If just presets/, list all presets

  if ! preset
    return txt.map { |o|
      o = o.match(/(\w.+?)\/(.+)/)
      next if ! o
      "#{o[1]}--#{o[2]}"
      "- #{o[1]}/\n"
    }.join("")
  end

  # If preset passed, apply it

  View.kill if View.name == "@window/dimensions/presets/"
  txt = txt.find { |o| o =~ /^[ +-]*#{preset}\// }

  txt = txt[/\/(.+)/, 1]
  self.dimensions_set txt

  nil

end

.dimensions_set(txt) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/xiki/window.rb', line 71

def self.dimensions_set txt

  # If just numbers and commas
  if txt =~ /^[0-9, ]+$/
    txt = txt.split(/, */).map{|o| o.to_i}
    View.dimensions_set *txt
    return
  end

  # Otherwise, it's code so just eval

  eval txt
end


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/xiki/window.rb', line 3

def self.menu
  "
  - .dimensions/
    - presets/
    - @dimensions config/
    - .adjust/
      - position/
        - up/
        - down/
        - left/
        - right/
      - size/
        - wider/
        - narrower/
        - taller/
        - shorter/
    - current/
  - .visibility/
    - full/
    - high/
    - medium/
    - low/
    - .colorized/
    - .scroll bars/
  - .scroll bars/
  "
end

.scroll_barsObject



125
126
127
128
129
130
131
# File 'lib/xiki/window.rb', line 125

def self.scroll_bars
  result = $el.scroll_bar_mode
  View.frame_width += View.scroll_bars ? -3 : 3
  #     View.scroll_bars = false
  View.kill if View.name == "@window/visibility/"
  nil
end

.visibility(choice = nil) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/xiki/window.rb', line 104

def self.visibility choice=nil
  choices = {
    'full'=>"(100 85)",
    'high'=>"(85 70)",
    'medium'=>"(70 55)",
    'low'=>"(40 30)",
    }

  numbers = choices[choice]
  raise ".flash - '#{choice}' isn't a valid choice for View.visibility!" if numbers.nil?

  $el.el4r_lisp_eval "(set-frame-parameter nil 'alpha '#{numbers})"   # full visibility
  View.kill if View.name == "@window/visibility/"
end