Method: Window.dimensions
- Defined in:
- lib/xiki/window.rb
.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.("#{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 |