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.



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

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')

  @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 = TkScrollText.new(right_frame,
    {'wrap'=>  'none'}.update(Arcadia.style('edit'))
  )
  @text.show
  @text.show_v_scroll
  @text.show_h_scroll

  @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' => 'red',
     'borderwidth'=>1,
     'relief'=> 'flat'
  )

  @text.tag_configure('bord_msg',
     #'foreground' => '#b9b8b9'
     'foreground' => '#7c9b10'
  )
  @text.tag_configure('sel', 
    'background'=>parent.conf('hightlight.sel.color.background'),
    'foreground'=>parent.conf('hightlight.sel.color.foreground')
  )
  pop_up_menu
end

Instance Attribute Details

#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

#pop_up_menuObject



63
64
65
66
67
68
69
70
71
72
73
74
75
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
# File 'ext/ae-output/ae-output.rb', line 63

def pop_up_menu
  @pop_up = TkMenu.new(
    :parent=>@text,
    :tearoff=>0,
    :title => 'Menu'
  )
  @pop_up.configure(Arcadia.style('menu'))
  
  @pop_up.insert('end',
    :command,
    :state=>'disabled',
    :label=>'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=>'Save',
    :hidemargin => false,
    :command=> proc{save_as}
  )



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

  @pop_up.insert('end',
    :command,
    :label=>'Set no wrap',
    :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



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'ext/ae-output/ae-output.rb', line 117

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
    #EditorContract.instance.file_saved(self,'file' =>@file)
  end
end

#save_asObject



133
134
135
136
137
138
139
# File 'ext/ae-output/ae-output.rb', line 133

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