Sha256: 91dc1b204101b2117484c4223741d974986b3080d0286faf5c02e66bcf4f0d6a

Contents?: true

Size: 786 Bytes

Versions: 8

Compression:

Stored size: 786 Bytes

Contents

include Wx

module Fugit
	class Console < Panel
		attr_accessor :input, :output

		def initialize(parent)
			super(parent, ID_ANY)

			@input = TextCtrl.new(self, ID_ANY, nil, nil, Size.new(20, 20), TE_PROCESS_ENTER)
			@output = TextCtrl.new(self, ID_ANY, nil, nil, Size.new(20, 20), NO_BORDER|TE_MULTILINE|TE_READONLY|TE_DONTWRAP)

			box = BoxSizer.new(VERTICAL)
			box.add(@output, 1, EXPAND)
			box.add(@input, 0, EXPAND)
			self.set_sizer(box)

			evt_text_enter(@input.get_id(), :on_run_command)
		end

		def on_run_command(event)
			cmd = @input.get_value
			begin
				result = IO.popen(cmd).readlines
				@output.append_text("> #{cmd}\n#{result}\n")
			rescue
				@output.append_text("> #{cmd}\nThere was an error running the command\n")
			end
			@input.clear
		end

	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tekkub-fugit-0.0.0 lib/fugit/console.rb
tekkub-fugit-0.0.1 lib/fugit/console.rb
tekkub-fugit-0.0.2 lib/fugit/console.rb
tekkub-fugit-0.0.3 lib/fugit/console.rb
tekkub-fugit-0.0.4 lib/fugit/console.rb
tekkub-fugit-0.0.5 lib/fugit/console.rb
tekkub-fugit-0.0.6 lib/fugit/console.rb
tekkub-fugit-0.0.7 lib/fugit/console.rb