diff options
Diffstat (limited to 'lib/bottompanel/messages.tcl')
-rw-r--r--[-rwxr-xr-x] | lib/bottompanel/messages.tcl | 172 |
1 files changed, 118 insertions, 54 deletions
diff --git a/lib/bottompanel/messages.tcl b/lib/bottompanel/messages.tcl index 51c96ce..e70c0a2 100755..100644 --- a/lib/bottompanel/messages.tcl +++ b/lib/bottompanel/messages.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 _MESSAGES_TCL ] } { +set _MESSAGES_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Implements messages text for the bottom panel of the project tab @@ -32,14 +37,16 @@ class Messages { common set_shortcuts {} ;# Currently set shortcut bindigs for messages text common shortcuts_cat {messages} ;# Key shortcut categories related to messages text # Normal font for messages text - common messages_normal_font [font create \ - -family $::DEFAULT_FIXED_FONT \ - -size -12] + common messages_normal_font [font create \ + -family $::DEFAULT_FIXED_FONT \ + -size [expr {int(-12 * $::font_size_factor)}] \ + ] # Bold font for messages text - common messages_bold_font [font create \ - -family $::DEFAULT_FIXED_FONT \ - -size -12 \ - -weight bold] + common messages_bold_font [font create \ + -family $::DEFAULT_FIXED_FONT \ + -size [expr {int(-12 * $::font_size_factor)}] \ + -weight bold \ + ] # Definition of popup menu for messages text common MESSAGESMENU { {command {Select all} {Ctrl+A} 0 "select_all_messages_text" @@ -64,13 +71,13 @@ class Messages { # Variables related to object initialization private variable parent ;# Widget: parent widget - private variable gui_initialized 0 ;# Bool: GUI initialized + private variable msg_gui_initialized 0 ;# Bool: GUI initialized # Variables related to search bar private variable search_frame ;# Widget: Search bar frame - private variable last_find_index {} ;# String: Index of last found occurence of the search string - private variable search_string ;# String: Search string - private variable search_string_length ;# Int: Length of the search string + private variable last_find_index {} ;# String: Index of last found occurrence of the search string + private variable search_string {} ;# String: Search string + private variable search_string_length 0 ;# Int: Length of the search string private variable search_entry ;# Widget: Search bar entry box private variable search_find_next ;# Widget: Button "Next" private variable search_find_prev ;# Widget: Button "Prev" @@ -90,20 +97,25 @@ class Messages { # @return void public method PrepareMessages {_parent} { set parent $_parent - set gui_initialized 0 + set msg_gui_initialized 0 } ## Inform this tab than it has became active # @return void public method MessagesTabRaised {} { + $this bottomnotebook_pageconfigure {Messages} "-image ::ICONS::16::kcmsystem" focus $messages_text } ## Create GUI of messages tab # @return void public method CreateMessagesGUI {} { - if {$gui_initialized} {return} - set gui_initialized 1 + if {$msg_gui_initialized} {return} + set msg_gui_initialized 1 + + if {${::DEBUG}} { + puts "CreateMessagesGUI \[ENTER\]" + } ## Create GUI of main frame set main_frame [frame $parent.main_frame] @@ -180,7 +192,7 @@ class Messages { -state disabled \ ] DynamicHelp::add $search_frame.find_next_but \ - -text [mc "Find next occurence of search string"] + -text [mc "Find next occurrence of search string"] # Button: "Prev" set search_find_prev [ttk::button $search_frame.find_prev_but \ -image ::ICONS::16::up0 \ @@ -189,7 +201,7 @@ class Messages { -state disabled \ ] DynamicHelp::add $search_frame.find_prev_but \ - -text [mc "Find previous occurence of search string"] + -text [mc "Find previous occurrence of search string"] # Button: "Close" pack [ttk::button $search_frame.close_but \ -image ::ICONS::16::button_cancel \ @@ -216,7 +228,8 @@ class Messages { -variable ::Todo::match_case \ -command "$this messages_text_perform_search 1 1.0" \ ] -side left -padx 5 - + # Show the search bar frame + messages_text_find_dialog 0 messages_text_shortcuts_reevaluate unset parent @@ -225,18 +238,18 @@ class Messages { ## Select all text in messages text # @return void public method select_all_messages_text {} { - if {!$gui_initialized} {CreateMessagesGUI} + if {!$msg_gui_initialized} {CreateMessagesGUI} $messages_text tag add sel 1.0 end } ## Copy selected text in messages text into clipboard # @return void public method copy_messages_text {} { - if {!$gui_initialized} {CreateMessagesGUI} + if {!$msg_gui_initialized} {CreateMessagesGUI} clipboard clear if {[llength [$messages_text tag nextrange sel 1.0]]} { clipboard append [$messages_text get sel.first sel.last] - } { + } else { clipboard append [$messages_text get 1.0 end] } } @@ -244,7 +257,7 @@ class Messages { ## Create bindings for defined key shortcuts for messages text # @return void public method messages_text_shortcuts_reevaluate {} { - if {!$gui_initialized} {CreateMessagesGUI} + if {!$msg_gui_initialized} {CreateMessagesGUI} # Unset previous configuration foreach key $set_shortcuts { @@ -286,11 +299,11 @@ class Messages { ## Define popup menu for messages text # @return void public method messages_text_makePopupMenu {} { - if {!$gui_initialized} {return} + if {!$msg_gui_initialized} {return} if {[winfo exists $menu]} { destroy $menu } - menuFactory $MESSAGESMENU $menu 0 "$this " 0 {} + menuFactory $MESSAGESMENU $menu 0 "$this " 0 {} [namespace current] $menu entryconfigure [::mc "Find next"] -state disabled $menu entryconfigure [::mc "Find previous"] -state disabled } @@ -308,14 +321,14 @@ class Messages { ## Clear all content of messages text # @return void public method clear_messages_text {} { - if {!$gui_initialized} {CreateMessagesGUI} + if {!$msg_gui_initialized} {CreateMessagesGUI} $messages_text configure -state normal $messages_text delete 0.0 end $messages_text configure -state disabled } - ## Goto line (in editor) which is somehow related to some tag in messages text + ## Go to line (in editor) which is somehow related to some tag in messages text # @parm int x - relative x coordinate in messages text widget # @parm int y - relative y coordinate in messages text widget # @return void @@ -323,7 +336,7 @@ class Messages { # Determinate line number for editor set idx [$messages_text index @$x,$y] set line [$messages_text get "$idx linestart" "$idx lineend"] - # Focus on editor and goto that line + # Focus on editor and go to that line # Message from As31 assembler if {[regexp {^(Error)|(Warning)\, line \d+} $line line]} { @@ -331,16 +344,15 @@ class Messages { set lineNum 0 } - if {$lineNum} { - $this editor_procedure {} focus_in {} - $this editor_procedure {} goto $lineNum + if {!$lineNum} { + return } # Message from ASEM-51 assembler } elseif {[regexp {^([^\(\)]+\(\d+(\,\d+)?\)\: \w+)} $line line]} { if {![regexp {\(\d+(\,\d+)?\):} $line lineNum]} { set lineNum 0 - } { + } else { set lineNum [string range $lineNum 1 end-2] set lineNum [lindex [split $lineNum {,}] 0] } @@ -353,9 +365,8 @@ class Messages { } } } - if {$lineNum} { - $this editor_procedure {} focus_in {} - $this editor_procedure {} goto "$lineNum" + if {!$lineNum} { + return } # GNU error message (from SDCC or ASL) @@ -369,10 +380,7 @@ class Messages { } } } - - set linenum [string trim $linenum {:}] - $this editor_procedure {} focus_in {} - $this editor_procedure {} goto $linenum + set lineNum [string trim $linenum {:}] # Message from MCU8051IDE assembler } elseif {[regexp {at \d+ in [^\:]+\:} $line line]} { @@ -385,18 +393,23 @@ class Messages { } } } - regexp {\d+} $line lineNum - $this editor_procedure {} focus_in {} - $this editor_procedure {} goto $lineNum + + } else { + return } + + $this editor_procedure {} goto $lineNum + after idle " + $this editor_procedure {} focus_in {} + " } ## Append text at the end of messages text # @parm String txt - Text to append - # @return Bool - True if error occured + # @return Bool - True if error occurred public method messages_text_append {txt} { - if {!$gui_initialized} {CreateMessagesGUI} + if {!$msg_gui_initialized} {CreateMessagesGUI} # Enable the messages text widget $messages_text configure -state normal @@ -414,6 +427,8 @@ class Messages { set warn 0 set suc 0 + set spec 0 + # Determinate number of the last line in the widget set row [expr {int([$messages_text index end]) - 1}] @@ -425,10 +440,29 @@ class Messages { set err 1 # check for an error - } elseif {[regexp {^(\|EN\|.*)|^(File access error:)|^(FAILED)|^(Compilation FAILED)|^(Pre-processing FAILED !)|^(Error:)|(^@@@@@ .+ @@@@@$)|(^.*returned errorcode.*)|^(Cannot open input file)|^(Cannot open file)|^(Errors in pass1, assembly aborted)|^(Errors in pass2, assembly aborted)} $text error]} { + } elseif {[regexp {^(\|EN\|.*)|^(File access error:)|^(FAILED)|^(Compilation FAILED)|^(Pre-processing FAILED !)|^(Error:)|(^@@@@@ .+ @@@@@$)|(^.*returned errorcode.*)|^(Cannot open input file)|^(Cannot open file)|^(Errors in pass1, assembly aborted)|^(Errors in pass2, assembly aborted)|(: command not found)|(cannot generate code for target 'mcs51')} $text error]} { set len [string length $error] set ern 1 + if {[regexp {: command not found} $text error]} { + set spec 2 + set len [string length $text] + } elseif {[regexp {cannot generate code for target 'mcs51'} $text error]} { + set spec 3 + set len [string length $text] + } + + # a special case of error; unable to find C debug file -- relevant only if user wants to start + #+ simulation right after compilation + } elseif {[regexp {^Unable to find \".*\"$} $text error]} { + set spec 1 + set len [string length $error] + if {$::X::compilation_start_simulator} { + set ern 1 + } else { + set warn 1 + } + # check for warning which points to specific line in source code } elseif {[regexp {^(\|WL\|.*)|^(Notice at \d+ in [^\:]+\:)|^(Warning at \d+ in [^\:]+\:)|^(.+:\d+: warning.*)|^(Warning\, line \d+)} $text warning]} { set len [string length $warning] @@ -453,9 +487,25 @@ class Messages { regsub {^(\|[EWS][LN]\|)} $text {} text # Insert specified text - $messages_text insert end $text + $messages_text insert end [regsub -all "\a" [regsub -all {\\} [regsub -all {\\\\} $text "\a"] {}] {\\}] $messages_text insert end "\n" + switch -- $spec { + 0 {} + 1 { ;# Unable to find "<some file>.cdb" + $messages_text insert end [mc " |\n"] + $messages_text insert end [mc " +-- Most probably that indicates that you have disabled debugging switch, if it is not that what you want then go to\n"] + $messages_text insert end [mc " \[Main Menu\] --> \[Configure\] --> \[Compiler configuration\] --> \[C language\] --> \[General\] and enable \"--debug\" compiler switch.\n"] + } + 2 { ;# /bin/sh: sdcc: command not found + $messages_text insert end [mc " |\n"] + $messages_text insert end [mc " +-- Most probably that indicates that you have not installed SDCC compiler\n"] + } + 3 { ;# cannot generate code for target 'mcs51' + $messages_text insert end [mc " |\n"] + $messages_text insert end [mc " +-- That means that your SDCC compiler does not support MCS-51 architecture, please install SDCC with support for 8051\n"] + } + } # Insert appropriate text tags if {$err || $ern || $war || $warn || $suc} { @@ -482,6 +532,11 @@ class Messages { $messages_text see end $messages_text configure -state disabled + # Change tab icon if some warning or error was displayed there + if {$err || $ern || $warn || $war} { + $this bottomnotebook_pageconfigure {Messages} "-image ::ICONS::16::status_unknown" + } + return [expr {$err || $ern}] } @@ -494,14 +549,19 @@ class Messages { } ## Show search bar + # @parm Bool do_focus_entrybox - Automatically focus the search EntryBox # @return void - public method messages_text_find_dialog {} { + public method messages_text_find_dialog {{do_focus 1}} { if {![winfo ismapped $search_frame]} { pack $search_frame -before $main_frame -side top -anchor w $search_entry delete 0 end - focus -force $search_entry - } { - focus -force $search_entry + if {$do_focus} { + focus -force $search_entry + } + } else { + if {$do_focus} { + focus -force $search_entry + } } } @@ -532,12 +592,12 @@ class Messages { if {$forw__back} { set direction {-forwards} - } { + } else { set direction {-backwards} } if {${::Todo::match_case}} { set last_find_index [$messages_text search $direction -- $search_string $from] - } { + } else { set last_find_index [$messages_text search $direction -nocase -- $search_string $from] } if {$last_find_index == {}} { @@ -546,7 +606,7 @@ class Messages { $search_find_prev configure -state disabled $menu entryconfigure [::mc "Find next"] -state disabled $menu entryconfigure [::mc "Find previous"] -state disabled - } { + } else { $search_entry configure -style StringFound.TEntry $search_find_next configure -state normal $search_find_prev configure -state normal @@ -562,7 +622,7 @@ class Messages { } } - ## Find next occurence of the search string + ## Find next occurrence of the search string # @return void public method messages_text_find_next {} { if {![winfo ismapped $search_frame]} { @@ -574,7 +634,7 @@ class Messages { messages_text_perform_search 1 $last_find_index+${search_string_length}c } - ## Find previous occurence of the search string + ## Find previous occurrence of the search string # @return void public method messages_text_find_prev {} { if {![winfo ismapped $search_frame]} { @@ -630,3 +690,7 @@ class Messages { $messages_text tag add hyper_link_over [lindex $range 0] [lindex $range 1] } } + +# >>> File inclusion guard +} +# <<< File inclusion guard |