1# 2# tkextlib/tcllib/history.rb 3# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) 4# 5# * Part of tcllib extension 6# * Provides a history for Entry widgets 7# 8 9require 'tk' 10require 'tk/entry' 11require 'tkextlib/tcllib.rb' 12 13# TkPackage.require('history', '0.1') 14TkPackage.require('history') 15 16module Tk::Tcllib 17 module History 18 PACKAGE_NAME = 'history'.freeze 19 def self.package_name 20 PACKAGE_NAME 21 end 22 23 def self.package_version 24 begin 25 TkPackage.require('history') 26 rescue 27 '' 28 end 29 end 30 end 31end 32 33module Tk::Tcllib::History 34 extend TkCore 35 36 def self.init(entry, length=None) 37 tk_call_without_enc('::history::init', entry.path, length) 38 entry.extend(self) # add methods to treat history to the entry widget 39 end 40 41 def self.remove(entry) 42 tk_call_without_enc('::history::remove', entry.path) 43 entry 44 end 45 46 def history_remove 47 tk_call_without_enc('::history::remove', @path) 48 self 49 end 50 51 def history_add(text) 52 tk_call('::history::add', @path, text) 53 self 54 end 55 56 def history_get 57 simplelist(tk_call_without_enc('::history::get', @path)) 58 end 59 60 def history_clear 61 tk_call_without_enc('::history::clear', @path) 62 self 63 end 64 65 def history_configure(opt, value) 66 tk_call('::history::configure', @path, opt, value) 67 self 68 end 69 70 def history_configinfo(opt) 71 tk_call('::history::configure', @path, opt) 72 end 73end 74