summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb
blob: a01a4ebfcce56e719684fe4cce5336795842f458 (plain)
1
2
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
30
31
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
70
71
72
73
#
#  tkextlib/tcllib/history.rb
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
#   * Part of tcllib extension
#   * Provides a history for Entry widgets
#

require 'tk'
require 'tk/entry'
require 'tkextlib/tcllib.rb'

# TkPackage.require('history', '0.1')
TkPackage.require('history')

module Tk::Tcllib
  module History
    PACKAGE_NAME = 'history'.freeze
    def self.package_name
      PACKAGE_NAME
    end

    def self.package_version
      begin
        TkPackage.require('history')
      rescue
        ''
      end
    end
  end
end

module Tk::Tcllib::History
  extend TkCore

  def self.init(entry, length=None)
    tk_call_without_enc('::history::init', entry.path, length)
    entry.extend(self)  # add methods to treat history to the entry widget
  end

  def self.remove(entry)
    tk_call_without_enc('::history::remove', entry.path)
    entry
  end

  def history_remove
    tk_call_without_enc('::history::remove', @path)
    self
  end

  def history_add(text)
    tk_call('::history::add', @path, text)
    self
  end

  def history_get
    simplelist(tk_call_without_enc('::history::get', @path))
  end

  def history_clear
    tk_call_without_enc('::history::clear', @path)
    self
  end

  def history_configure(opt, value)
    tk_call('::history::configure', @path, opt, value)
    self
  end

  def history_configinfo(opt)
    tk_call('::history::configure', @path, opt)
  end
end