diff options
author | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
commit | 47aa8b00b2b11df13a100489e0f904a4947177ef (patch) | |
tree | b35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/bottompanel/terminal.tcl | |
parent | 5b8466f7fae0e071c0f4eda13051c93313910028 (diff) |
Import Upstream version 1.4.7
Diffstat (limited to 'lib/bottompanel/terminal.tcl')
-rw-r--r--[-rwxr-xr-x] | lib/bottompanel/terminal.tcl | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/lib/bottompanel/terminal.tcl b/lib/bottompanel/terminal.tcl index 6c373f8..894fd3b 100755..100644 --- a/lib/bottompanel/terminal.tcl +++ b/lib/bottompanel/terminal.tcl @@ -2,7 +2,7 @@ # Part of MCU 8051 IDE ( http://mcu8051ide.sf.net ) ############################################################################ -# Copyright (C) 2007-2009 by Martin Ošmera # +# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera # # martin.osmera@gmail.com # # # # This program is free software; you can redistribute it and#or modify # @@ -21,6 +21,11 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ +# >>> File inclusion guard +if { ! [ info exists _TERMINAL_TCL ] } { +set _TERMINAL_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Provides terminal emulator for bottom notebook @@ -40,7 +45,7 @@ class Terminal { private variable terminal_frame ;# Widget: ID of terminal container frame private variable wrapper_frame ;# Widget: Wrapper frame for $terminal_frame private variable parent ;# Widget: Parent frame - private variable gui_initialized 0 ;# Bool: GUI initialized + private variable term_gui_initialized 0 ;# Bool: GUI initialized private variable terminal_pid {} ;# Int: PID of terminal emulator destructor { @@ -52,7 +57,7 @@ class Terminal { # @return void public method PrepareTerminal {_parent} { set parent $_parent - set gui_initialized 0 + set term_gui_initialized 0 } ## Inform this tab than it has became active @@ -64,8 +69,8 @@ class Terminal { ## Create GUI # @return void public method CreateTerminalEmulGUI {} { - if {$gui_initialized || !${::PROGRAM_AVALIABLE(urxvt)}} {return} - set gui_initialized 1 + if {$term_gui_initialized || !${::PROGRAM_AVAILABLE(urxvt)}} {return} + set term_gui_initialized 1 set wrapper_frame [frame $parent.wrapper_frame -relief sunken -bd 2] pack $wrapper_frame -fill both -expand 1 @@ -83,7 +88,7 @@ class Terminal { set pwd [pwd] if {[catch { cd [$this cget -projectPath] - }]} { + }]} then { cd ~ } if {[catch { @@ -93,13 +98,13 @@ class Terminal { -fg ${configuration(fg)} \ -fn "xft:$configuration(font_family):pixelsize=$configuration(font_size)" & \ ] - } result]} { + } result]} then { tk_messageBox \ -parent . \ -icon warning \ -type ok \ -title [mc "Unable to find urxvt"] \ - -message [mc "Unable to execute program \"urxvt\", terminal emulator is eiter not avaliable or badly configured."] + -message [mc "Unable to execute program \"urxvt\", terminal emulator is eiter not available or badly configured."] puts stderr $result } cd $pwd @@ -110,22 +115,32 @@ class Terminal { ## Restart terminal emulator # @return void public method terminal_restart {} { - if {!$gui_initialized} {return} - if {!${::PROGRAM_AVALIABLE(urxvt)}} {return} - catch { - exec kill $terminal_pid + if {!$term_gui_initialized} {return} + if {!${::PROGRAM_AVAILABLE(urxvt)}} {return} + foreach pid $terminal_pid { + if {$pid == [pid] || $pid == 0} { + continue + } + catch { + exec -- kill $pid + } } } ## Kill terminal emulator # @return void public method terminal_kill_childern {} { - if {$gui_initialized} { + if {$term_gui_initialized} { if {[info exists terminal_frame] && [winfo exists $terminal_frame]} { bind $terminal_frame <Destroy> {} } - catch { - exec kill $terminal_pid + foreach pid $terminal_pid { + if {$pid == [pid] || $pid == 0} { + continue + } + catch { + exec -- kill $pid + } } } } @@ -133,3 +148,7 @@ class Terminal { # Initialize NS variables array set ::Terminal::configuration ${::Terminal::configuration_def} + +# >>> File inclusion guard +} +# <<< File inclusion guard |