find_ini(options.inifile)
read_ini()
parse_config()
+ parse_global()
end
def find_ini(option_inifile)
end
def read_ini()
- @config = IniFile.load(@inifile, :default=>'global')
+ @config = IniFile.load(@inifile, :default => 'global')
if(@config.nil?)
puts "Initialization file not found or not readable"
exit
sec = @config[section]
if(section == "global")
@global = sec
+ next
end
if(not sec.has_key?('Type'))
puts "Section incomplete, ignored: "+ section
end
end
+ def parse_global()
+ if(@global.has_key?('list_size'))
+ @global['list_size'] = @global['list_size'].to_i
+ if(@global['list_size'] == 0)
+ @global['list_size'] = 25
+ end
+ else
+ @global['list_size'] = 25
+ end
+ end
+
end
require_relative 'windows'
require_relative 'buffer'
-def make_bufwins(sections)
+def make_bufwins(sections,size)
bufwins = []
sections.each { |section_name,section|
- bufwin = Buff_Win.new(Ncurses.COLS()-Ncurses.COLS()/4,
- Ncurses.COLS()/4,
+ bufwin = Buff_Win.new(Ncurses.COLS()-size*Ncurses.COLS()/100,
+ size*Ncurses.COLS()/100,
section)
bufwins.push(bufwin)
}
end
end
-def redraw_all(list,bufwins,curr_bufwin)
+def redraw_all(list,bufwins,curr_bufwin, size)
bufwins.each do |bufwin|
- bufwin.move_resize(Ncurses.COLS()-Ncurses.COLS()/4,Ncurses.COLS()/4)
+ bufwin.move_resize(Ncurses.COLS()-size*Ncurses.COLS()/100,size*Ncurses.COLS()/100)
end
- list.resize(Ncurses.LINES(), Ncurses.COLS()/4)
+ list.resize(Ncurses.LINES(), size*Ncurses.COLS()/100)
list.clear()
list.print_list()
list.refresh()
Ncurses.init_pair(10, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK)
- list = List_Win.new(inistruct.sections)
- bufwins = make_bufwins(inistruct.sections)
+ list = List_Win.new(inistruct.sections, inistruct.global['list_size'])
+ bufwins = make_bufwins(inistruct.sections, inistruct.global['list_size'])
entry = 0
cur_bufwin = bufwins[entry]
cur_bufwin.show_win()
cur_bufwin.show_win()
list.print_list(entry=entry)
when 12 #ctrl+L
- redraw_all(list,bufwins,cur_bufwin)
+ redraw_all(list,bufwins,cur_bufwin, inistruct.global['list_size'])
when 18 #ctrl+R
cur_bufwin.update(force=true)
when Ncurses::KEY_RESIZE
- redraw_all(list,bufwins,cur_bufwin)
+ redraw_all(list,bufwins,cur_bufwin, inistruct.global['list_size'])
when Ncurses::KEY_LEFT
cur_bufwin.hscroll(scroll=-1)
when Ncurses::KEY_RIGHT
class List_Win
- def initialize(sections)
+ def initialize(sections, size)
@params = sections
- @win = Ncurses::WINDOW.new(0, Ncurses.COLS()/4, 0, 0)
+ @win = Ncurses::WINDOW.new(0, size*Ncurses.COLS()/100, 0, 0)
@win.border(*([0]*8))
@win.keypad(true)
@win.timeout(1000)