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
67
68
69
70
71
72
73
74
# 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')
  @auto_open_file = false
  @parent = parent
  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)

#----
  @ck = parent.frame.root.add_check_button(
    parent.name,
    Arcadia.text('ext.output.checkbutton.auto_open_file.hint'),
    proc{ @auto_open_file = @ck.cget('onvalue')==@ck.cget('variable').value.to_i},
    GO_UP_GIF)
#---
  @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('system_error_msg',
  'background' => Arcadia.conf('hightlight.system_error.background'),
  'foreground' => Arcadia.conf('hightlight.system_error.foreground'),
  'borderwidth'=>1,
  'relief'=> 'groove'
  )
  @text.tag_configure('info_msg',
  'foreground' => Arcadia.conf('hightlight.edge.foreground')
  )
  @text.tag_configure('prompt',
    'foreground' => Arcadia.conf('hightlight.prompt.foreground')
  )
  @text.tag_configure('sel',
  'background'=>Arcadia.conf('hightlight.sel.background'),
  'foreground'=>Arcadia.conf('hightlight.sel.foreground')
  )
  @text.bind_append("KeyPress", "%K"){|_keysym| input(_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

#auto_open_file?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'ext/ae-output/ae-output.rb', line 76

def auto_open_file?
  @auto_open_file
end

#input(_char) ⇒ Object



80
81
82
83
84
85
# File 'ext/ae-output/ae-output.rb', line 80

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

#pop_up_menuObject



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
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'ext/ae-output/ae-output.rb', line 88

def pop_up_menu
  #@pop_up = TkMenu.new(
  @pop_up = Arcadia.wf.menu(
  :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



144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'ext/ae-output/ae-output.rb', line 144

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



159
160
161
162
163
164
165
166
# File 'ext/ae-output/ae-output.rb', line 159

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