Class: OutputView

Inherits:
Object
  • Object
show all
Defined in:
ext/ae-output/ae-output.rb

Overview

require “base/a-utils”

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ OutputView

Returns a new instance of OutputView.



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
# File 'ext/ae-output/ae-output.rb', line 15

def initialize(parent=nil)
  #left_frame = TkFrame.new(parent.frame.hinner_frame, Arcadia.style('panel')).place('x' => '0','y' => '0','relheight' => '1','width' => '25')
  #right_frame = TkFrame.new(parent.frame.hinner_frame, Arcadia.style('panel')).place('x' => '25','y' => '0','relheight' => '1','relwidth' => '1','width' => '-25')
  parent.frame.root.add_button(
    parent.name,
    Arcadia.text('ext.output.button.clear.hint'),
    proc{parent.main_frame.text.delete('1.0','end')}, 
    CLEAR_GIF)

#    @button_u = Tk::BWidget::Button.new(left_frame, Arcadia.style('toolbarbutton')){
#      image  TkPhotoImage.new('dat' => CLEAR_GIF)
#      helptext 'Clear'
#      #foreground 'blue'
#      command proc{parent.main_frame.text.delete('1.0','end')}
#      #relief 'groove'
#      pack('side' =>'top', 'anchor'=>'n',:padx=>0, :pady=>0)
#    }

  @text = TkArcadiaText.new(parent.frame.hinner_frame,
  {'wrap'=>  'none'}.update(Arcadia.style('edit'))
  )
  @text.extend(TkScrollableWidget).show
  @text.extend(TkInputThrow)
  @text.tag_configure('simple_msg',
  #   'background' => '#d9d994',
  'borderwidth'=>1,
  'relief'=> 'flat'
  )
  @text.tag_configure('debug_msg',
  #   'background' => '#f6c9f6',
  #   'foreground' => '#000000',
  'borderwidth'=>1,
  'relief'=> 'flat'
  )
  @text.tag_configure('error_msg',
  #  'background' => '#f6c9f6',
  'foreground' => Arcadia.conf('hightlight.string.foreground'),
  'borderwidth'=>1,
  'relief'=> 'flat'
  )
  @text.tag_configure('bord_msg',
  #'foreground' => '#b9b8b9'
  'foreground' => Arcadia.conf('hightlight.comment.foreground')
  )
  @text.tag_configure('sel',
  'background'=>Arcadia.conf('hightlight.sel.background'),
  'foreground'=>Arcadia.conf('hightlight.sel.foreground')
  )
  @text.bind_append("KeyPress"){|e| input(e.keysym)}
  @input_buffer = nil
  pop_up_menu        
end

Instance Attribute Details

#input_bufferObject

Returns the value of attribute input_buffer.



14
15
16
# File 'ext/ae-output/ae-output.rb', line 14

def input_buffer
  @input_buffer
end

#textObject (readonly)

Returns the value of attribute text.



13
14
15
# File 'ext/ae-output/ae-output.rb', line 13

def text
  @text
end

Instance Method Details

#input(_char) ⇒ Object



68
69
70
71
72
73
# File 'ext/ae-output/ae-output.rb', line 68

def input(_char)
  case _char
    when 'Return'
      @input_buffer = @text.get("insert linestart","insert").sub(Output::PROMPT,'').strip
  end
end

#pop_up_menuObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'ext/ae-output/ae-output.rb', line 76

def pop_up_menu
  @pop_up = TkMenu.new(
  :parent=>@text,
  :tearoff=>0,
  :title => 'Menu'
  )
  @pop_up.extend(TkAutoPostMenu)
  @pop_up.configure(Arcadia.style('menu'))

  @pop_up.insert('end',
  :command,
  :state=>'disabled',
  :label=>Arcadia.text('ext.output.menu.output'),
  :background=>Arcadia.conf('titlelabel.background'),
  :font => "#{Arcadia.conf('menu.font')} bold",
  :hidemargin => true
  )


  #Arcadia.instance.main_menu.update_style(@pop_up)
  @pop_up.insert('end',
  :command,
  :label=>Arcadia.text('ext.output.menu.save'),
  :hidemargin => false,
  :command=> proc{save_as}
  )



  @pop_up.insert('end',
  :command,
  :label=>Arcadia.text('ext.output.menu.wrap'),
  :hidemargin => false,
  :command=> proc{@text.configure('wrap'=>'word');@text.hide_h_scroll}
  )

  @pop_up.insert('end',
  :command,
  :label=>Arcadia.text('ext.output.menu.nowrap'),
  :hidemargin => false,
  :command=> proc{@text.configure('wrap'=>'none');@text.show_h_scroll}
  )




  @text.bind("Button-3",
  proc{|x,y|
    _x = TkWinfo.pointerx(@text)
    _y = TkWinfo.pointery(@text)
    @pop_up.popup(_x,_y)
  },
  "%x %y")
end

#saveObject



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'ext/ae-output/ae-output.rb', line 131

def save
  if !@file
    save_as
  else
    f = File.new(@file, "w")
    begin
      if f
        f.syswrite(@text.value)
      end
    ensure
      f.close unless f.nil?
    end
  end
end

#save_asObject



146
147
148
149
150
151
152
# File 'ext/ae-output/ae-output.rb', line 146

def save_as
  @file = Tk.getSaveFile("filetypes"=>[["Ruby Files", [".rb", ".rbw"]],["All Files", [".*"]]])
  @file = nil if @file == ""  # cancelled
  if @file
    save
  end
end