summaryrefslogtreecommitdiff
path: root/lib/leftpanel/filelist.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leftpanel/filelist.tcl')
-rw-r--r--[-rwxr-xr-x]lib/leftpanel/filelist.tcl842
1 files changed, 488 insertions, 354 deletions
diff --git a/lib/leftpanel/filelist.tcl b/lib/leftpanel/filelist.tcl
index c5f5c14..4c65e36 100755..100644
--- a/lib/leftpanel/filelist.tcl
+++ b/lib/leftpanel/filelist.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,12 +21,17 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _FILELIST_TCL ] } {
+set _FILELIST_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides:
# - List of opened files
# - List of project files
-# - Filesystem browser
+# - File system browser
# - Management of opened files, project files and code editors
# --------------------------------------------------------------------------
@@ -42,7 +47,7 @@ class FileList {
# String: Textvariable for dialog "Open with ..."
common open_with ${::CONFIG(OPEN_WITH_DLG)}
common open_with_cnfr 0 ;# Bool: Confirm dialog "Open with ..."
- common count 0 ;# Instances counter
+ common fl_lst_count 0 ;# Instances counter
common file_indexes {} ;# List of line indexes (auxiliary variable for opening multiple files)
common ac_index_in_fl ;# Index of actual editor filelist
common default_encoding {utf-8} ;# Default encoding
@@ -55,7 +60,7 @@ class FileList {
}
# Font for opened file in project files list
common opened_file_font [font create \
- -weight bold \
+ -weight normal \
-slant roman \
-size -12 \
-family $::DEFAULT_FIXED_FONT \
@@ -69,6 +74,8 @@ class FileList {
]
# Font for icon borders
common icon_border_font [font create \
+ -weight normal \
+ -slant roman \
-size -12 \
-family $::DEFAULT_FIXED_FONT \
]
@@ -115,12 +122,12 @@ class FileList {
{command {Move to bottom} {} 12 "filelist_move_bottom" {bottom}
"Move this file to the bottom of the list"}
{separator}
- {cascade "Sort items by" 11 "" .sort_by false 1 {
+ {cascade "Sort items by" 11 "sort_incr" .sort_by false 1 {
{command {Document Name} {} 9 "sort_file_list N 1" {} {}}
{command {File URL} {} 5 "sort_file_list U 1" {} {}}
{command {File Size in B} {} 5 "sort_file_list S 1" {} {}}
}}
- {cascade "Open with" 6 "" .open_with false 1 {
+ {cascade "Open with" 6 "fileopen" .open_with false 1 {
{command {gvim} {} 1 "filelist_open_with 1 gvim" {gvim} {}}
{command {emacs} {} 1 "filelist_open_with 1 emacs" {emacs} {}}
{command {kwrite} {} 0 "filelist_open_with 1 kwrite" {kwrite} {}}
@@ -211,7 +218,7 @@ class FileList {
}
## PUBLIC
- public variable actualEditor ;# Object number of currently selected editor
+ public variable actualEditor 0 ;# Object number of currently selected editor
public variable actualEditor2 -2 ;# Object number of currently selected editor in the second view
public variable ProjectDir ;# Reference to directory of actual project
public variable editors {} ;# list of editor objects
@@ -284,9 +291,11 @@ class FileList {
private variable PanelVisible $::CONFIG(LEFT_PANEL) ;# Bool: panel visible
private variable PanelSize $::CONFIG(LEFT_PANEL_SIZE) ;# Panel width (in pixels)
- private variable editor_to_freeze_obj ;# Object: Editor to freeze after simulator startup
+ private variable editor_to_freeze_obj ;# Object: Editor to freeze after simulator start-up
private variable filetabs_frm ;# Widget: Frame contaning the tab bar
private variable filetabs_nb ;# Widget: Tab bar's notebook widget
+ private variable switchfile_in_progress 0 ;# Bool: Method switchfile is in progress
+ private variable last_selected_item {} ;# String: ID of the last selected opened file
## PROTECTED
protected variable file_count 0 ;# counter of opened files
@@ -300,8 +309,8 @@ class FileList {
## object constructor
constructor {} {
# increment instance counter
- incr count
- set obj_idx $count
+ incr fl_lst_count
+ set obj_idx $fl_lst_count
}
## Object destructor
@@ -322,7 +331,7 @@ class FileList {
# @parm List filelist - List of files to open (full filenames including path)
# @parm Bool editor_sw_lock - Enable aoutomatic file switching during simulation
# @return void
- public method initiate_FileList {parentPane projectDir FileList editor_sw_lock} {
+ public method initalize_FileList {parentPane projectDir FileList editor_sw_lock} {
# Object variables
set parent $parentPane ;# ID of parent container widget
@@ -335,36 +344,34 @@ class FileList {
# Create notebook frame
set leftPanel [frame $parentPane.frm_FileList_leftPanel]
# Create notebook
- set notebook [NoteBook $leftPanel.nb_FileList \
- -side top -arcradius 4 -bg {#EEEEEE} \
- ]
+ set notebook [ModernNoteBook $leftPanel.nb_FileList]
# Create tab "Hide"
$notebook insert end "button_SH" -image ::ICONS::16::2leftarrow \
- -raisecmd "$this filelist_show_hide" \
+ -raisecmd [list $this filelist_show_hide] \
-helptext [mc "Hide this panel"]
# Create tab for list of opened files
set listbox_opened_files_frame [$notebook insert end "opened_files" \
-image ::ICONS::16::fileopen \
- -raisecmd "$this Left_panel_set_active_page opened_files" \
+ -raisecmd [list $this Left_panel_set_active_page opened_files] \
-helptext [mc "Opened files"] \
]
# Create tab for list of project files
set listbox_project_files_frame [$notebook insert end "project_files" \
-image ::ICONS::16::project_open \
- -raisecmd "$this Left_panel_set_active_page project_files" \
+ -raisecmd [list $this Left_panel_set_active_page project_files] \
-helptext [mc "Files in the project"] \
]
# Create tab for file system browser
set fs_browser_frame [$notebook insert end "fs_browser" \
-image ::ICONS::16::exec \
- -raisecmd "$this Left_panel_set_active_page fs_browser" \
- -helptext [mc "Filesystem browser"] \
+ -raisecmd [list $this Left_panel_set_active_page fs_browser] \
+ -helptext [mc "File system browser"] \
-createcmd [list $this CreateFSBrowserGUI] \
]
# Create tab for SFR watches
set sfr_watches_frame [$notebook insert end "sfr_watches" \
-image ::ICONS::16::kcmmemory \
- -raisecmd "$this Left_panel_set_active_page sfr_watches" \
+ -raisecmd [list $this Left_panel_set_active_page sfr_watches] \
-helptext [mc "List of SFR's"] \
-createcmd [list $this CreateSFRWatchesGUI] \
]
@@ -377,9 +384,9 @@ class FileList {
# Register notebook status bar tips
notebook_Sbar_set {filelist} [list \
button_SH [mc "Hide the panel"] \
- opened_files [mc "Opended files"] \
+ opened_files [mc "Opened files"] \
project_files [mc "Files of the current project"] \
- fs_browser [mc "Filesystem browser"] \
+ fs_browser [mc "File system browser"] \
sfr_watches [mc "Special Function Registers"] \
]
$notebook bindtabs <Enter> "notebook_Sbar filelist"
@@ -389,7 +396,6 @@ class FileList {
set lsbox_frame [frame $listbox_opened_files_frame.lsbox_frame]
set listbox_opened_files_bm [text $lsbox_frame.icon_border \
-font $icon_border_font \
- -cursor left_ptr \
-width 2 \
-bd 0 \
-pady 1 \
@@ -397,17 +403,23 @@ class FileList {
-bg {#DDDDDD} \
-exportselection 0 \
-takefocus 0 \
- -cursor hand1 \
+ -cursor hand2 \
]
$listbox_opened_files_bm tag configure center -justify center
$listbox_opened_files_bm delete 1.0 end
setStatusTip -widget $listbox_opened_files_bm \
-text [mc "Bookmarks for opened files"]
set listbox_opened_files [ListBox $lsbox_frame.listbox_opened_files \
- -selectmode single -selectfill 0 -bg white \
- -selectbackground white -highlightcolor {#BBBBFF} \
- -selectforeground {#0000FF} -bd 1 \
- -highlightthickness 0 -deltay 15 -padx 14 \
+ -selectmode single \
+ -selectfill 0 \
+ -bg {#FFFFFF} \
+ -selectbackground {#FFFFFF} \
+ -highlightcolor {#BBBBFF} \
+ -selectforeground {#0000FF} \
+ -bd 1 \
+ -highlightthickness 0 \
+ -deltay 15 \
+ -padx 14 \
-yscrollcommand "$this filelist_o_scrollbar_set" \
]
setStatusTip -widget $listbox_opened_files \
@@ -420,7 +432,7 @@ class FileList {
# Create popup menu for icon border
set IB_o_menu $listbox_opened_files_bm.ib_o_menu
- menuFactory $OPENEDFILESIBMENU $IB_o_menu 0 "$this " 0 {}
+ menuFactory $OPENEDFILESIBMENU $IB_o_menu 0 "$this " 0 {} [namespace current]
# Create bottom frame
set listbox_opened_files_bottom_frame [frame $listbox_opened_files_frame.bottom_frame]
@@ -474,6 +486,9 @@ class FileList {
# Frame for opened files
set listbox_opened_files_top_frame [frame \
$listbox_opened_files_frame.listbox_opened_files_top_frame]
+ pack [label $listbox_opened_files_top_frame.listbox_opened_files_label \
+ -text [mc "Opened Files:"] -anchor w \
+ ] -fill x -side top -anchor w -pady 5
# Button box for "Opened files"
set opened_files_buttonBox [frame \
$listbox_opened_files_top_frame.opened_files_buttonBox]
@@ -481,22 +496,18 @@ class FileList {
set main_frame [frame $parentPane.main_frame]
# Create filetabs notebook
- set filetabs_frm [frame $main_frame.filetabs_frm -height 16]
+ set filetabs_frm [frame $main_frame.filetabs_frm]
pack [ttk::button $filetabs_frm.add_button \
-image ::ICONS::16::filenew \
-command {::X::__new} \
-style Flat.TButton \
- ] -side left
- set filetabs_nb [NoteBook $filetabs_frm.filetabs_nb \
- -side top -arcradius 4 -bg {#EEEEEE} \
- -font [font create -family {Helvetica} -size -12] \
- ]
- pack configure $filetabs_nb.c -fill x -expand 0
- pack $filetabs_nb -fill x -anchor sw -side left -expand 1
- $filetabs_nb bindtabs <Enter> "$this file_details_win_create_from_ftnb"
- $filetabs_nb bindtabs <Leave> "$this file_details_win_hide"
- $filetabs_nb bindtabs <Motion> "$this file_details_win_move"
- $filetabs_nb bindtabs <ButtonRelease-3> "$this filetabs_nb_popup_menu %X %Y"
+ ] -side left
+ set filetabs_nb [ModernNoteBook $filetabs_frm.filetabs_nb -nomanager 1]
+ pack [$filetabs_nb get_nb] -fill x -anchor sw -side left -expand 1
+ $filetabs_nb bindtabs <Enter> [list $this file_details_win_create_from_ftnb]
+ $filetabs_nb bindtabs <Leave> [list $this file_details_win_hide]
+ $filetabs_nb bindtabs <Motion> [list $this file_details_win_move]
+ $filetabs_nb bindtabs <ButtonRelease-3> [list $this filetabs_nb_popup_menu %X %Y]
pack [ttk::button $filetabs_frm.close_button \
-image ::ICONS::16::fileclose \
-command {::X::__close} \
@@ -527,7 +538,7 @@ class FileList {
"Move selected file to the top of the list"}
{bottom "Move item to bottom" {bottom} {filelist_move_bottom}
"Move selected file to the bottom of the list"}
- }
+ } [namespace current]
# Pack GUI components of tab "Opened files"
pack $opened_files_buttonBox -side left
@@ -543,7 +554,6 @@ class FileList {
set ls_frame [frame $listbox_project_files_frame.ls_frame]
set listbox_project_files_bm [text $ls_frame.icon_border \
-font $icon_border_font \
- -cursor left_ptr \
-width 2 \
-bd 0 \
-pady 1 \
@@ -551,16 +561,22 @@ class FileList {
-bg {#DDDDDD} \
-exportselection 0 \
-takefocus 0 \
- -cursor hand1 \
+ -cursor hand2 \
]
$listbox_project_files_bm delete 1.0 end
$listbox_project_files_bm tag configure center -justify center
setStatusTip -widget $listbox_project_files_bm \
-text [mc "Bookmarks for project files"]
set listbox_project_files [ListBox $ls_frame.listbox_project_files \
- -selectmode single -highlightthickness 0 -bd 1 -padx 0 \
- -selectbackground white -bg white -deltay 15 \
- -selectforeground {#0000FF} -highlightcolor {#BBBBFF} \
+ -selectmode single \
+ -highlightthickness 0 \
+ -bd 1 \
+ -padx 0 \
+ -selectbackground {#FFFFFF} \
+ -bg {#FFFFFF} \
+ -deltay 15 \
+ -selectforeground {#0000FF} \
+ -highlightcolor {#BBBBFF} \
-yscrollcommand "$this filelist_p_scrollbar_set" \
]
setStatusTip -widget $listbox_project_files \
@@ -573,7 +589,7 @@ class FileList {
# Create popup menu for icon border
set IB_p_menu $listbox_project_files.ib_o_menu
- menuFactory $PROJECTFILESIBMENU $IB_p_menu 0 "$this " 0 {}
+ menuFactory $PROJECTFILESIBMENU $IB_p_menu 0 "$this " 0 {} [namespace current]
# Create search panel
set search_panel [frame $listbox_project_files_frame.search_panel]
@@ -584,7 +600,7 @@ class FileList {
]
DynamicHelp::add $project_search_entry -text [mc "Search for file"]
setStatusTip -widget $project_search_entry \
- -text [mc "Search for certain file name in list of project files"]
+ -text [mc "Search for certain file name in list of project files"]
pack $project_search_entry -side left -fill x -expand 1
set project_search_clear_button [ttk::button \
$search_panel.clear_button \
@@ -602,7 +618,7 @@ class FileList {
# Create header (label and icon bar) for tab "Project files"
set topFrame [frame $listbox_project_files_frame.listbox_project_files_top_frame]
pack [label $topFrame.listbox_project_files_label \
- -text [mc "Project files:"] -anchor w \
+ -text [mc "Project Files:"] -anchor w \
] -fill x -side top -anchor w -pady 5
set project_files_buttonBox [frame $topFrame.listbox_project_files_buttonBox]
pack $project_files_buttonBox -side bottom -anchor w -expand 0
@@ -624,7 +640,7 @@ class FileList {
{remove "Remove this file from the project" {editdelete}
{filelist_remove_file_from_project}
"Exclude this file from list of files of this project"}
- }
+ } [namespace current]
# Evaluate icon bars button states (tab "Project files")
FileList_project_disEna_buttons
@@ -668,15 +684,15 @@ class FileList {
DynamicHelp::add $button_bar.but_proj_open -text [mc "Files in the current project"]
setStatusTip -widget $button_bar.but_proj_open \
-text [mc "Files of the current project"]
- # Button "Filesystem browser"
+ # Button "File system browser"
pack [ttk::button $button_bar.but_fs_browser \
-image ::ICONS::16::exec \
-style ToolButton.TButton \
-command "$this filelist_show_up fs_browser" \
]
- DynamicHelp::add $button_bar.but_fs_browser -text [mc "Filesystem browser"]
+ DynamicHelp::add $button_bar.but_fs_browser -text [mc "File system browser"]
setStatusTip -widget $button_bar.but_fs_browser \
- -text [mc "Filesystem browser"]
+ -text [mc "File system browser"]
# Button "SFR watches"
pack [ttk::button $button_bar.but_sfr_watches \
-image ::ICONS::16::kcmmemory \
@@ -689,13 +705,13 @@ class FileList {
# Show the left panel
if {$PanelVisible != 0} {
- pack $notebook -expand 1 -fill both
+ pack [$notebook get_nb] -expand 1 -fill both -padx 5 -pady 5
# Raise active page in the panel notebook
catch {
$notebook raise $active_page
}
- } {
+ } else {
set last_sash $PanelSize
pack $button_bar -side top -anchor nw
}
@@ -741,7 +757,7 @@ class FileList {
# Create popup menus
set opened_files_menu $listbox_opened_files.opened_files_menu
set project_files_menu $listbox_project_files.project_files_menu
- set filetabs_pu_menu $filetabs_nb.filetabs_pu_menu
+ set filetabs_pu_menu [$filetabs_nb get_nb].filetabs_pu_menu
filelist_makePopupMenu
# Create Editor object for each file in $filelist and insert it into ListBox of opened files
@@ -786,7 +802,7 @@ class FileList {
$actualEditor < [llength $editors]
&&
$actualEditor >= 0
- } { ;# Valid value
+ } then { ;# Valid value
$listbox_opened_files selection set [lindex [$listbox_opened_files items] $actualEditor]
set actualEditor -1
switchfile
@@ -795,7 +811,7 @@ class FileList {
set actualEditor -1
if {![llength $editors]} {
editor_new
- } {
+ } else {
$listbox_opened_files selection set [lindex [$listbox_opened_files items] 0]
switchfile
}
@@ -822,20 +838,20 @@ class FileList {
if {$pwin_orient == {vertical}} {
if {!$multiview_sash_pos} {
- set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
- }
- set minsize 300
- } {
- if {!$multiview_sash_pos} {
set multiview_sash_pos [expr {[winfo height $pagesManager] / 2}]
}
set minsize 80
+ } else {
+ if {!$multiview_sash_pos} {
+ set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
+ }
+ set minsize 300
}
$multiview_paned_win paneconfigure $pagesManager -minsize $minsize
$multiview_paned_win paneconfigure $pagesManager2 -minsize $minsize
pack [[lindex $editors $actualEditor2] cget -ed_sc_frame] \
-in $pagesManager2 -fill both -expand 1
- } {
+ } else {
pack $pagesManager -fill both -expand 1
}
foreach editor $editors {
@@ -843,12 +859,12 @@ class FileList {
}
# Set panel width
- update idle
+ update idletasks
if {$PanelVisible != 0} {
$parent paneconfigure $leftPanel -minsize 155
$parent configure -sashwidth 2
$parent sash place 0 $PanelSize 0
- } {
+ } else {
$parent paneconfigure $leftPanel -minsize 0
$parent configure -sashwidth 0
$parent sash place 0 25 2
@@ -858,10 +874,10 @@ class FileList {
# Update multiview sash position
if {$splitted} {
- update idle
+ update idletasks
if {$pwin_orient == {vertical}} {
$multiview_paned_win sash place 0 0 $multiview_sash_pos
- } {
+ } else {
$multiview_paned_win sash place 0 $multiview_sash_pos 0
}
}
@@ -890,7 +906,7 @@ class FileList {
set eol [lindex $file_eol $index]
set read_only [lindex $file_ro_mode $index]
regexp -line -- {^.*$} [$this get_file_notes_data $index] note
- } {
+ } else {
if {![$listbox_project_files exists $item]} {
return
}
@@ -901,7 +917,7 @@ class FileList {
set eol [lindex $data 1]
set encoding [lindex $data 2]
set read_only [lindex $data 3]
- } {
+ } else {
set filename "[lindex $data 5][lindex $data 0]"
set eol [lindex $data 8]
set encoding [lindex $data 9]
@@ -919,7 +935,6 @@ class FileList {
# Create window
set ::FILEDETAILSWIN [frame .file_details_win -bg {#AADDFF}]
set file_details_win [frame ${::FILEDETAILSWIN}.frm -bg {#FFFFFF}]
- bind ${::FILEDETAILSWIN} <Button-1> "catch {destroy ${::FILEDETAILSWIN}}"
# Determinate file type and set appropriate icon
set ext [string trimleft [file extension $filename] {.}]
@@ -987,7 +1002,7 @@ class FileList {
}
if {$size < 1024} {
append size { B}
- } {
+ } else {
set kB [expr {$size / 1024}]
set B [expr {$size % 1024}]
set MB [expr {$kB / 1024}]
@@ -1021,8 +1036,12 @@ class FileList {
-fg {#0000AA} \
-anchor w -bg {#FFFFFF} \
] -row 0 -column 0 -sticky w -pady 0
+ set path [file dirname $filename]
+ if {$::MICROSOFT_WINDOWS} {
+ regsub -all {/} $path "\\" path
+ }
grid [label $main_frame.path_value \
- -text [file dirname $filename] \
+ -text $path \
-anchor w -bg {#FFFFFF} \
] -row 0 -column 1 -sticky w -pady 0
@@ -1116,6 +1135,17 @@ class FileList {
] -row 9 -column 0 -sticky w -pady 0 -columnspan 2
}
+ # Configure the window in a way that it will close when the user clicks on it
+ foreach w [concat $file_details_win \
+ $main_frame \
+ [pack slaves $file_details_win] \
+ [pack slaves $header] \
+ [grid slaves $main_frame] \
+ ] \
+ {
+ bind $w <Button-1> [list $this file_details_win_hide]
+ }
+
# Pack main frame
grid columnconfigure $main_frame 0 -minsize 90
pack $main_frame -fill both -expand 1 -padx 8 -pady 3
@@ -1167,14 +1197,14 @@ class FileList {
destroy $filetabs_pu_menu
}
- menuFactory $PROJECTFILESMENU $project_files_menu 0 "$this " 0 {}
- menuFactory $OPENEDFILESMENU $opened_files_menu 0 "$this " 0 {}
- menuFactory $FILETABSPUMENU $filetabs_pu_menu 0 "$this " 0 {}
+ menuFactory $PROJECTFILESMENU $project_files_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $OPENEDFILESMENU $opened_files_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $FILETABSPUMENU $filetabs_pu_menu 0 "$this " 0 {} [namespace current]
foreach program {gvim emacs kwrite gedit} \
program_name {gvim emacs kwrite gedit} \
{
- if {!$::PROGRAM_AVALIABLE($program)} {
+ if {!$::PROGRAM_AVAILABLE($program)} {
foreach menu [list $project_files_menu $opened_files_menu $filetabs_pu_menu] {
${menu}.open_with entryconfigure [::mc $program_name] -state disabled
}
@@ -1192,14 +1222,21 @@ class FileList {
}
## Reload the current file
+ # @parm Object target_editor - Editor object where the reload is supposed to take place
+ # @parm Bool force - Don't ask whether the file should be saved first, in case it was modified
# @return Bool - result
- public method filelist_reload_file {} {
- if {$splitted && $selectedView} {
- set editor_idx $actualEditor2
- } {
- set editor_idx $actualEditor
+ public method filelist_reload_file {{target_editor {}} {force 0}} {
+ if {$target_editor == {}} {
+ if {$splitted && $selectedView} {
+ set editor_idx $actualEditor2
+ } else {
+ set editor_idx $actualEditor
+ }
+ set editor [lindex $editors $editor_idx]
+ } else {
+ set editor_idx [lsearch -ascii -exact $editors $target_editor]
+ set editor $target_editor
}
- set editor [lindex $editors $editor_idx]
# Local variables
set fullFileName [$editor cget -fullFileName] ;# Full filename
@@ -1209,7 +1246,7 @@ class FileList {
![file exists $fullFileName] ||
[file isdirectory $fullFileName] ||
(!$::MICROSOFT_WINDOWS && ![file readable $fullFileName])
- } {
+ } then {
tk_messageBox \
-title [mc "File not found"] \
-icon error \
@@ -1221,7 +1258,7 @@ class FileList {
if {$fullFileName != {}} {
# Prompt user is the file was modified
- if {[$editor cget -modified] != 0} {
+ if {!$force && ([$editor cget -modified] != 0)} {
set response [tk_messageBox \
-title [mc "Are you sure ?"] \
-icon question \
@@ -1254,9 +1291,11 @@ class FileList {
fconfigure $file -encoding $enc
set data {}
if {[regsub -all {[\u0000-\u0008\u000B-\u000C\u000E-\u001F\u007F-\u009F]} [read $file] {} data]} {
- tk_messageBox -parent . \
- -type ok -icon warning \
- -title [mc "Binary File Opened - MCU 8015 IDE"] \
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon warning \
+ -title [mc "Binary File Opened - MCU 8015 IDE"] \
-message [mc "The file %s is binary, saving it will result corrupted file." $fullFileName]
}
[$editor cget -editor] insert end [regsub -all {\r\n?} $data "\n"]
@@ -1376,13 +1415,17 @@ class FileList {
$this todo_switch_editor $ac
if {${::ASMsyntaxHighlight::validation_L1}} {
[lindex $editors $actualEditor] parse_current_line
- } {
+ } else {
[lindex $editors $actualEditor] adjust_instruction_details
}
set file_indexes {}
}
+ public method is_splitted {} {
+ return $splitted
+ }
+
## Switch from Normal mode to Simulator mode
# @return void
public method freeze {} {
@@ -1393,7 +1436,7 @@ class FileList {
# Freeze editor
if {$splitted && $selectedView} {
set editor_to_freeze $actualEditor2
- } {
+ } else {
set editor_to_freeze $actualEditor
}
set idx 0
@@ -1401,7 +1444,7 @@ class FileList {
if {$idx == $editor_to_freeze} {
$editor freeze
set editor_to_freeze_obj $editor
- } {
+ } else {
$editor disable
}
incr idx
@@ -1414,7 +1457,7 @@ class FileList {
$project_files_menu entryconfigure [::mc "Close file"] -state disabled
}
- ## This method should be called immediately after simulator startup
+ ## This method should be called immediately after simulator start-up
#+ in order to inform editors about the change
# @return void
public method now_frozen {} {
@@ -1446,13 +1489,21 @@ class FileList {
$project_files_menu entryconfigure [::mc "Close file"] -state normal
if {$simulator_editor_obj != {}} {
- $listbox_opened_files itemconfigure [lindex \
- $file_descriptors [lsearch -ascii -exact \
- $editors $simulator_editor_obj \
- ] \
- ] -fg {#000000}
+ set idx [lsearch -ascii -exact $editors $simulator_editor_obj]
+ if {$idx != -1} {
+ $listbox_opened_files itemconfigure [lindex $file_descriptors $idx] -fg {#000000}
+ } else {
+ set simulator_editor_obj {}
+ }
}
set simulator_editor_obj {}
+
+ if {$splitted && $selectedView} {
+ set editor_idx $actualEditor2
+ } else {
+ set editor_idx $actualEditor
+ }
+ focus -force [[lindex $editors $editor_idx] cget -editor]
}
## Set variable containing ID of active page
@@ -1471,12 +1522,12 @@ class FileList {
public method getLeftPanelSize {} {
if {$PanelVisible} {
return $PanelSize
- } {
+ } else {
return $last_sash
}
}
- ## Set panel width acording to current sash position
+ ## Set panel width according to current sash position
# @return void
public method left_panel_set_size {} {
set PanelSize [lindex [$parent sash coord 0] 0]
@@ -1497,12 +1548,12 @@ class FileList {
if {$PanelVisible} {
$parent paneconfigure $leftPanel -minsize 0
- pack forget $notebook
+ pack forget [$notebook get_nb]
# Show button bar
pack $button_bar -side top -anchor nw
# Move the paned window sash and remember current position
set last_sash [lindex [$parent sash coord 0] 0]
- update idle
+ update idletasks
$parent sash place 0 25 2
# Hide the sash
bind $parent <Button> {break}
@@ -1512,16 +1563,16 @@ class FileList {
return 0
# Show the panel
- } {
+ } else {
$parent paneconfigure $leftPanel -minsize 155
$notebook raise $active_page
# Hide button bar
pack forget $button_bar
# Show the panel
- pack $notebook -expand 1 -fill both
+ pack [$notebook get_nb] -expand 1 -fill both -padx 5 -pady 5
# Restore the paned window sash position to the previous state
- update idle
+ update idletasks
$parent sash place 0 $last_sash 0
# Show the sash
bind $parent <Button> {}
@@ -1548,11 +1599,17 @@ class FileList {
set index [$listbox_opened_files index $item] ;# Item index
set target [expr {$index - 1}] ;# Target index
+ if {$last_selected_item == $item} {
+ return
+ }
+ set last_selected_item $item
+
# 1st item cannot be moved up
if {$index == 0} {return}
- # Move item in listbox
+ # Move item in listbox and the notebook
$listbox_opened_files move $item $target
+ $filetabs_nb move $item $target
# Move item in list of bookmarks and icon border
if {[lindex $opened_files_bookmarks $index] != [lindex $opened_files_bookmarks $target]} {
# Determinate bookmark flag for source and target index
@@ -1568,12 +1625,12 @@ class FileList {
$listbox_opened_files_bm delete $target.0 [list $target.0 lineend]
if {$trg_bm} {
$listbox_opened_files_bm image create $index.0 \
- -image ::ICONS::16::bookmark \
+ -image ::ICONS::16::bookmark \
-align center
}
if {$idx_bm} {
$listbox_opened_files_bm image create $target.0 \
- -image ::ICONS::16::bookmark \
+ -image ::ICONS::16::bookmark \
-align center
}
}
@@ -1595,6 +1652,7 @@ class FileList {
# Move item in listbox
$listbox_opened_files move $item $target
+ $filetabs_nb move $item $target
# Move item in list of bookmarks and icon border
if {[lindex $opened_files_bookmarks $index] != [lindex $opened_files_bookmarks $target]} {
# Determinate bookmark flag for source and target index
@@ -1633,6 +1691,7 @@ class FileList {
# Move item
$listbox_opened_files move $item 0
+ $filetabs_nb move $item 0
# Move item in list of bookmarks
set bm [lindex $opened_files_bookmarks $index]
set opened_files_bookmarks [lreplace $opened_files_bookmarks $index $index]
@@ -1660,6 +1719,7 @@ class FileList {
# Move item in listbox
$listbox_opened_files move $item end
+ $filetabs_nb move $item end
# Move item in list of bookmarks
set bm [lindex $opened_files_bookmarks $index]
set opened_files_bookmarks [lreplace $opened_files_bookmarks $index $index]
@@ -1682,6 +1742,11 @@ class FileList {
## Show up editor asociated with the currently selected item in the file list (opened files)
# @return void
public method switchfile {} {
+ if {$switchfile_in_progress} {
+ return
+ }
+ set switchfile_in_progress 1
+
# Ensure that autocompletion window is closed
::Editor::close_completion_popup_window_NOW
@@ -1691,6 +1756,10 @@ class FileList {
# Adjust filetabs notebook
set page [lindex [$filetabs_nb pages] $editor_idx]
+ if {$page == {}} {
+ set switchfile_in_progress 0
+ return
+ }
$filetabs_nb raise $page
$filetabs_nb see $page
@@ -1699,13 +1768,13 @@ class FileList {
if {$editor_idx == $actualEditor} {
set selectedView 0
}
- } {
+ } else {
if {$editor_idx == $actualEditor2} {
set selectedView 1
}
}
- # Show up the coresponding editor
+ # Show up the corresponding editor
rightPanel_switch_editor_vars $editor_idx
$this todo_switch_editor_vars $editor_idx
# Right/Bottom view selected
@@ -1724,7 +1793,7 @@ class FileList {
set editor [lindex $editors $actualEditor2]
# Left/Top view selected
- } {
+ } else {
if {$editor_idx != $actualEditor} {
if {!$do_not_forget_editor && $actualEditor >= 0} {
set editor [lindex $editors $actualEditor]
@@ -1741,10 +1810,11 @@ class FileList {
set do_not_forget_editor 0
$opened_search_entry delete 0 end
- update idle
+ update idletasks
editor_procedure {} Configure {}
editor_procedure {} scroll {scroll +0 lines}
editor_procedure {} highlight_visible_area {}
+ editor_procedure {} check_file_change_notif {}
update
rightPanel_switch_page $editor_idx
$this todo_switch_editor $editor_idx
@@ -1756,13 +1826,13 @@ class FileList {
# Adjust command line status
if {$editor_command_line_on} {
$editor cmd_line_force_on
- } {
+ } else {
$editor cmd_line_force_off
}
# Adjust tab "Instruction details" on the right panel
if {${::ASMsyntaxHighlight::validation_L1}} {
$editor parse_current_line
- } {
+ } else {
$editor adjust_instruction_details
}
# move arrow image
@@ -1776,6 +1846,8 @@ class FileList {
${::editor_RO_MODE} [expr {[$editor get_language] == 1}]
# Focus on the editor
focus -force [$editor cget -editor]
+ update
+ set switchfile_in_progress 0
}
## Switch to the next editor
@@ -1809,7 +1881,7 @@ class FileList {
if {$item == $actualEditor || $item == $actualEditor2} {
set item {end-1}
}
- } {
+ } else {
set item {end}
}
$listbox_opened_files selection set [lindex $file_descriptors $item]
@@ -1825,7 +1897,7 @@ class FileList {
# Is the file part of the project ?
if {[getItemNameFromProjectList [$editor cget -fullFileName]] != {}} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Append to project"] -state $state
@@ -1835,7 +1907,7 @@ class FileList {
set item_idx [$listbox_opened_files index $item]
if {$item_idx == 0} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Move up"] -state $state
@@ -1847,7 +1919,7 @@ class FileList {
# Items: "Move down" and "Move to bottom"
if {($item_idx + 1) >= [llength [$listbox_opened_files items]]} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Move down"] -state $state
@@ -1908,7 +1980,7 @@ class FileList {
} {
$opened_files_menu entryconfigure [::mc $entry] -state normal
}
- # It is not so easy to open the file with an external editor on Microsoft Windows as
+ # It is not so easy to open the file with an external editor on Microsoft Windows as
# it is on a POSIX system, that's why this feature is disabled here
if {$::MICROSOFT_WINDOWS} {
$opened_files_menu entryconfigure [::mc {Open with}] -state disabled
@@ -1922,7 +1994,7 @@ class FileList {
set fullFileName [[lindex $editors [lsearch $file_descriptors $item]] cget -fullFileName]
if {$fullFileName == {} || [getItemNameFromProjectList $fullFileName] != {}} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Append to project"] -state $state
@@ -1987,26 +2059,34 @@ class FileList {
# Parse record
set rfi 0
foreach var {
- file_name active o_bookmark p_bookmark
- file_index read_only file_line file_md5
- file_path file_BMs file_BPs eol
- enc sh notes
- } {
- set $var [lindex $record $rfi]
- incr rfi
+ file_name active o_bookmark p_bookmark
+ file_index read_only file_line file_md5
+ file_path file_BMs file_BPs eol
+ enc sh notes
+ } {
+ set $var [lindex $record $rfi]
+ incr rfi
}
# Adjust file path
- if {[string index $file_path 0] != {/}} {
- set file_path "$project_path/$file_path"
+ if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
+ if {[string index $file_path 0] != {/}} {
+ set file_path "$project_path/$file_path"
+ }
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $file_path]} {
+ set file_path "$project_path/$file_path"
+ }
}
# Determinate full file name
set full_file_name "$file_path$file_name"
# Check for file usebility
if {
- ![file exists $full_file_name] ||
- [file isdirectory $full_file_name] ||
+ ![file exists $full_file_name]
+ ||
+ [file isdirectory $full_file_name]
+ ||
(!$::MICROSOFT_WINDOWS && ![file readable $full_file_name])
} then {
lappend file_indexes_fb {}
@@ -2014,19 +2094,6 @@ class FileList {
continue
}
- # Compare file MD5
- if {[catch {
- if {[md5::md5 -hex -file $file_path$file_name] != $file_md5} {
- lappend changed_files $file_path$file_name
- }
- }]} then {
- tk_messageBox \
- -icon warning \
- -type ok \
- -title [mc "Unknown error"] \
- -message [mc "Raised error during md5 checking file %s. Maybe md5 extension is not correctly loaded." $file_name]
- }
-
# Chech for valid EOL and Encoding
if {$eol != {lf} && $eol != {cr} && $eol != {crlf}} {
set eol $default_eol
@@ -2041,6 +2108,20 @@ class FileList {
puts stderr "Read only flag -- using default (0)"
}
+ # Compare file MD5
+ if {[catch {
+ if {!$read_only && [md5::md5 -hex -file $file_path$file_name] != $file_md5} {
+ lappend changed_files $file_path$file_name
+ }
+ }]} then {
+ tk_messageBox \
+ -parent . \
+ -icon warning \
+ -type ok \
+ -title [mc "Unknown error"] \
+ -message [mc "Error raised during md5 checking file %s. Maybe md5 extension is not correctly loaded." $file_name]
+ }
+
# Insert bookmark to icon border for project files
if {[llength $project_files_bookmarks]} {
$listbox_project_files_bm insert end "\n"
@@ -2049,7 +2130,7 @@ class FileList {
lappend project_files_bookmarks 1
$listbox_project_files_bm image create [list {end-1l} linestart] \
-image ::ICONS::16::bookmark -align center
- } {
+ } else {
lappend project_files_bookmarks 0
}
$listbox_project_files_bm tag add center 0.0 end
@@ -2068,7 +2149,7 @@ class FileList {
$sh $notes \
]
continue
- } {
+ } else {
$listbox_project_files insert end #auto \
-font $opened_file_font -fill {#000000} \
-text $file_name -data [list $file_path$file_name $eol $enc $read_only]
@@ -2110,16 +2191,7 @@ class FileList {
# Invoke progress dialog
set max [llength $file_indexes_fb]
if {!$max} {set max 1}
- create_progress_bar .prgDl \
- . \
- ::FileList::open_files_cur_file \
- {} \
- ::FileList::open_files_progress \
- $max \
- [mc "Opening project files"] \
- ::ICONS::16::fileopen \
- [mc "Abort"] \
- {set ::FileList::open_files_abort 1}
+ .prgDl.f.progressbar configure -maximum $max
# Adjust lists of files to open
if {!$keep_order} {
@@ -2136,7 +2208,7 @@ class FileList {
# Check for validity of list of file indexes
if {$unopened_files != {}} {
set file_indexes $file_indexes_fb
- } {
+ } else {
for {set i 0} {$i < $num_of_opened_files} {incr i} {
if {[lsearch -ascii -exact $file_indexes $i] == -1} {
set file_indexes $file_indexes_fb
@@ -2168,7 +2240,7 @@ class FileList {
incr i -1
set file_indexes [lrange $file_indexes 0 $i]
set file_indexes_fb [lrange $file_indexes_fb 0 $i]
- } {
+ } else {
set file_indexes {}
set file_indexes_fb {}
}
@@ -2195,7 +2267,7 @@ class FileList {
# Invoke dialog "File(s) not found"
if {$unopened_files != {}} {
# Create toplevel window
- set win [toplevel .file_not_found$obj_idx -class {Error dialog} -bg {#EEEEEE}]
+ set win [toplevel .file_not_found$obj_idx -class {Error dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
pack [frame $win.frame1] -side top -fill x -anchor nw
@@ -2248,21 +2320,18 @@ class FileList {
# Set window attributes
wm iconphoto $win ::ICONS::16::status_unknown
+ wm transient $win .
wm title $win [mc "File(s) not found"]
wm geometry $win 500x200
- wm protocol $win WM_DELETE_WINDOW "
- grab release $win
- destroy $win
- "
+ wm protocol $win WM_DELETE_WINDOW [list destroy $win]
update
- catch {grab $win}
raise $win
}
# Invoke dialog "File(s) changed"
if {$changed_files != {}} {
# Create dialog toplevel window
- set win [toplevel .changed_files$obj_idx -class {File changed} -bg {#EEEEEE}]
+ set win [toplevel .changed_files$obj_idx -class {File changed} -bg ${::COMMON_BG_COLOR}]
# Create dialog header
pack [frame $win.frame1] -side top -fill x -anchor nw
@@ -2273,8 +2342,8 @@ class FileList {
] -side left -fill x
# Create text widget and scrollbar
- pack [frame $win.frame2] -side top -expand 1 -fill both -pady 10 -padx 5
- pack [text $win.frame2.text -height 5 -width 50 \
+ pack [frame $win.frame2] -side top -expand 1 -fill both -pady 3 -padx 5
+ pack [text $win.frame2.text -height 0 -width 0 \
-yscrollcommand "$win.frame2.scrollbar set"] -side left -fill both -expand 1
pack [ttk::scrollbar $win.frame2.scrollbar \
-orient vertical \
@@ -2285,7 +2354,7 @@ class FileList {
foreach file $changed_files {
if {[file exists $file_path$file_name]} {
set time [clock format [file mtime $file_path$file_name] -format {%T %D}]
- } {
+ } else {
set time " -----\t"
}
$win.frame2.text insert end "$time\t$file\n"
@@ -2320,15 +2389,13 @@ class FileList {
"
# Set window attributes
+ wm minsize $win 200 100
+ wm transient $win .
wm iconphoto $win ::ICONS::16::info
wm title $win [mc "File(s) changed"]
wm geometry $win 500x200
- wm protocol $win WM_DELETE_WINDOW "
- grab release $win
- destroy $win
- "
+ wm protocol $win WM_DELETE_WINDOW [list destroy $win]
update
- catch {grab $win}
raise $win
}
}
@@ -2359,17 +2426,18 @@ class FileList {
if {$file_path != {}} {
# Report error if the file does not exist
if {
- !${::Editor::editor_to_use} && (
- ![file exists $file_path] ||
- ![file isfile $file_path] ||
- (!$::MICROSOFT_WINDOWS && ![file readable $file_path])
- )
- } {
- tk_messageBox \
- -type ok \
- -title [mc "File not found - MCU 8051 IDE"] \
- -message [mc "File %s not found !" $file_path] \
- -icon error
+ !${::Editor::editor_to_use} && (
+ ![file exists $file_path] ||
+ ![file isfile $file_path] ||
+ (!$::MICROSOFT_WINDOWS && ![file readable $file_path])
+ )
+ } then {
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -title [mc "File not found - MCU 8051 IDE"] \
+ -message [mc "File %s not found !" $file_path] \
+ -icon error
set newfile 1
}
@@ -2383,7 +2451,7 @@ class FileList {
}
if {$untitled_num == -1} {
set file_name "untitled"
- } {
+ } else {
set file_name "untitled$untitled_num"
}
incr untitled_num
@@ -2395,15 +2463,31 @@ class FileList {
}
if {$untitled_num == -1} {
set file_name "untitled"
- } {
+ } else {
set file_name "untitled$untitled_num"
}
incr untitled_num
set newfile 1
}
- # Check if the file isn't already opened
+
if {!$newfile} {
+ # Check if the file isn't dangerously large
+ set file_size [file size $file_path]
+ if {$file_size > 10485760} {
+ if {[tk_messageBox \
+ -parent . \
+ -type yesno \
+ -default no \
+ -icon warning \
+ -title [mc "Dangerously large file!"] \
+ -message [mc "WARNING: The file you are about to open is larger than 10MB!\n\nOpening extremely big source code files might lead your system to run out of operating memory, then the MCU 8051 IDE might got killed by the operating system!\n\nARE YOU SURE you want to proceed?"] \
+ ] != {yes}} then {
+ return {}
+ }
+ }
+
+ # Check if the file isn't already opened
set idx 0
foreach editor $editors {
if {[$editor cget -fullFileName] == $file_path} {
@@ -2411,7 +2495,7 @@ class FileList {
$listbox_opened_files selection set $item
switchfile
set lastItem $item
- Sbar [mc "File: %s is alredy opened." $file_path]
+ Sbar [mc "File: %s is already opened." $file_path]
return {}
}
incr idx
@@ -2432,10 +2516,10 @@ class FileList {
set file_descriptor [regsub -all -- {-} $file_descriptor {--}]
set file_descriptor [regsub -all -- {\s} $file_descriptor {-}]
# Handle similar file descriptors of different files
- while 1 {
+ while {1} {
if {[lsearch $file_descriptors $file_descriptor] != -1} {
append file_descriptor {_}
- } {
+ } else {
break
}
}
@@ -2470,38 +2554,47 @@ class FileList {
set ::FileList::dialog_response 0
set win [toplevel .append_to_the_project_dialog]
- pack [label $win.label -text [mc "Do you want to append this file to the project ?\n%s" $file_name]] -fill x -pady 5 -padx 5
-
- pack [frame $win.frm] -pady 5
- pack [ttk::button $win.frm.yes_button -text [mc "Yes"] -command "
- set ::FileList::dialog_response 1
- grab release $win
- destroy $win" \
- ] -side left
- bind $win.frm.yes_button <Return> "
+ set top_frame [frame $win.top]
+ pack [label $top_frame.img -image ::ICONS::32::help] -side left -padx 5
+ pack [label $top_frame.txt \
+ -justify left \
+ -text [mc "Do you want to add this file to the project ?\n%s" $file_name] \
+ ] -side left -padx 5
+ set chb [checkbutton $win.chb \
+ -text [mc "Do not ask again"] \
+ -onvalue 0 \
+ -offvalue 1 \
+ -variable ::FileList::ask__append_file_to_project \
+ ]
+ set bottom_frame [frame $win.bottom]
+ pack [ttk::button $bottom_frame.button_yes \
+ -text [mc "Yes"] -compound left \
+ -image ::ICONS::16::ok \
+ -command "
+ set ::FileList::dialog_response 1
+ grab release $win
+ destroy $win" \
+ ] -side left -padx 2 -pady 5
+ bind $bottom_frame.button_yes <Return> "
set ::FileList::dialog_response 1
grab release $win
destroy $win"
- bind $win.frm.yes_button <KP_Enter> "
+ bind $bottom_frame.button_yes <KP_Enter> "
set ::FileList::dialog_response 1
grab release $win
destroy $win"
- pack [ttk::button $win.frm.no_button -text [mc "No"] -command "
- grab release $win
- destroy $win" \
- ] -side left
- bind $win.frm.no_button <Return> "
- grab release $win
- destroy $win"
- bind $win.frm.no_button <KP_Enter> "
- grab release $win
- destroy $win"
-
- pack [ttk::separator $win.sep -orient horizontal] -fill x -pady 10
- pack [checkbutton $win.chb -text [mc "Do not ask again"] -onvalue 0 -offvalue 1 -variable ::FileList::ask__append_file_to_project] -anchor w
- pack [text $win.tip -fg {#888888} -bg {#EEEEEE} -height 2 -width 0 -bd 0] -fill x
- $win.tip insert end [mc "Tip: You can enable/disable this dialog in MCU 8051 IDE configuration dialog."]
- $win.tip configure -state disabled
+ pack [ttk::button $bottom_frame.button_no \
+ -text [mc "No"] -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command "grab release $win; destroy $win" \
+ ] -side left -padx 2 -pady 5
+ bind $bottom_frame.button_no <KP_Enter> "grab release $win; destroy $win"
+ bind $bottom_frame.button_no <KP_Enter> "grab release $win; destroy $win"
+
+ # Pack window frames
+ pack $top_frame -fill x -padx 5 -pady 10
+ pack $chb -anchor e -padx 5
+ pack $bottom_frame -pady 10
# Set window attributes
wm iconphoto $win ::ICONS::16::help
@@ -2509,13 +2602,13 @@ class FileList {
wm resizable $win 0 0
wm transient $win .
catch {grab $win}
- focus -force $win.frm.yes_button
wm protocol $win WM_DELETE_WINDOW "
grab release $win
destroy $win
"
raise $win
update
+ focus -force $bottom_frame.button_yes
tkwait window $win
if {$::FileList::dialog_response } {
@@ -2536,8 +2629,10 @@ class FileList {
set file [open $file_path]
fconfigure $file -encoding $enc
if {[regsub -all {[\u0000-\u0008\u000B-\u000C\u000E-\u001F\u007F-\u009F]} [read $file] {} data]} {
- tk_messageBox -parent . \
- -type ok -icon warning \
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon warning \
-title [mc "Binary File Opened - MCU 8015 IDE"] \
-message [mc "The file %s is binary, saving it will result corrupted file." $file_path]
}
@@ -2549,7 +2644,7 @@ class FileList {
$file_name $file_path "$this editor_procedure {} " \
[regsub -all {\r\n?} $data "\n"] $sh \
]
- } {
+ } else {
set editor [Editor "::editor${file_count}_$obj_idx" \
[expr {!$fast}] $eol $enc $read_only $file_switching_enabled $this \
$file_name $file_path "$this editor_procedure {} " {} $sh \
@@ -2571,7 +2666,7 @@ class FileList {
}
$filetabs_nb insert end $file_descriptor \
-text $file_name -image ::ICONS::16::$icon \
- -raisecmd "$this switch_file_from_filetabs $file_descriptor"
+ -raisecmd [list $this switch_file_from_filetabs $file_descriptor]
$filetabs_nb see $file_descriptor
# Conditionaly show Line Numbers and Icon Border
@@ -2615,7 +2710,7 @@ class FileList {
switchfile
}
- ## Show file details windows from files tab (or something ...)
+ ## Show file details window from files tab (or something ...)
# $filetabs_nb bindtabs <Enter> "$this file_details_win_create_from_ftnb"
# @parm String page - Page ID
# @return void
@@ -2638,8 +2733,9 @@ class FileList {
## Save currently opened file under a given filename
# note: should be used only for saving untitled files !
# @parm String filename - Full file name including path
- # @return bool - 1: (maybe) successful; 0: argument is empty
- public method save_as {filename} {
+ # @parm Bool keep_extension - Do not alter file extension by assuming that file with no extension should end with ".asm"
+ # @return Bool - 1: (maybe) successful; 0: argument is empty
+ public method save_as {filename {keep_extension 0}} {
# Handle empty argument
if {$filename == {}} {return 0}
@@ -2647,16 +2743,18 @@ class FileList {
# Adjust filename
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
- set filename "[$this cget -ProjectDir]/$filename"
+ set filename "[$this cget -ProjectDir]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
set filename [file join [$this cget -ProjectDir] $filename]
}
}
set filename [file normalize $filename]
- if {[file extension $filename] == {}} {
- append filename {.asm}
+ if {!$keep_extension} {
+ if {[file extension $filename] == {}} {
+ append filename {.asm}
+ }
}
# Determinate file rootname
set rootname [file tail $filename]
@@ -2670,7 +2768,7 @@ class FileList {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" $rootname]
] != {yes}
- } {
+ } then {
return 1
}
}
@@ -2683,7 +2781,7 @@ class FileList {
# Determinate some additional informations
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
set editor [lindex $editors $idx]
@@ -2691,6 +2789,7 @@ class FileList {
set original_rootname [$editor cget -filename] ;# Original file rootname
# Mark the file as opened (in listbox of project files)
+ set already_in_project 0
foreach item [$listbox_project_files items] {
if {[$listbox_project_files itemcget $item -text] != $original_rootname} {
continue
@@ -2700,6 +2799,7 @@ class FileList {
if {[lindex $data 0] != $fullFileName} {continue}
lset data 0 $filename
$listbox_project_files itemconfigure $item -data $data -text $rootname
+ set already_in_project 1
}
# Set new file name
@@ -2708,14 +2808,17 @@ class FileList {
$this todo_change_filename $idx $rootname
# Ask for appending the file to the project
- set response [tk_messageBox \
- -title [mc "Add file ?"] \
- -icon question -type yesno \
- -parent $parent \
- -message [mc "Do you want to append this file to the project ?\n%s" $rootname]
- ]
- if {$response == {yes}} {
- filelist_append_to_prj
+ if {!$already_in_project} {
+ set response [tk_messageBox \
+ -title [mc "Add file ?"] \
+ -icon question \
+ -type yesno \
+ -parent $parent \
+ -message [mc "Do you want to add this file to the project ?\n%s" $rootname]
+ ]
+ if {$response == {yes}} {
+ filelist_append_to_prj
+ }
}
::X::recent_files_add 1 $filename
@@ -2726,7 +2829,7 @@ class FileList {
# ---------------------------------------------------------------------
- # EDITOR PROCEDURES
+ # EDITOR FUNCTIONS
# ---------------------------------------------------------------------
## Show/Hide line numbers
@@ -2735,7 +2838,7 @@ class FileList {
if {$lineNumbers} {
set lineNumbers 0
foreach editor $editors {$editor hideLineNumbers}
- } {
+ } else {
set lineNumbers 1
foreach editor $editors {$editor showLineNumbers}
}
@@ -2747,7 +2850,7 @@ class FileList {
if {$iconBorder} {
set iconBorder 0
foreach editor $editors {$editor hideIconBorder}
- } {
+ } else {
set iconBorder 1
foreach editor $editors {$editor showIconBorder}
}
@@ -2758,10 +2861,10 @@ class FileList {
public method editor_linescount {} {
if {$splitted && $selectedView} {
set tmp $actualEditor2
- } {
+ } else {
set tmp $actualEditor
}
- set tmp [[lindex $editors $tmp] cget -lastEnd]
+ set tmp [expr {int([[[lindex $editors $tmp] cget -editor] index end])}]
return [expr {$tmp-1}]
}
@@ -2770,7 +2873,7 @@ class FileList {
public method editor_actLineNumber {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
return [expr {int([[lindex $editor_wdgs $idx] index insert])}]
@@ -2786,7 +2889,7 @@ class FileList {
if {$objectNumber == {}} {
if {$splitted && $selectedView} {
set objectNumber $actualEditor2
- } {
+ } else {
set objectNumber $actualEditor
}
}
@@ -2846,13 +2949,13 @@ class FileList {
# List header
if {$splitted} {
set _actualEditor2 $actualEditor2
- } {
+ } else {
set _actualEditor2 -1
}
if {$splitted} {
if {$pwin_orient == {vertical}} {
set idx 1
- } {
+ } else {
set idx 0
}
set multiview_sash_pos [lindex [$multiview_paned_win sash coord 0] $idx]
@@ -2897,6 +3000,9 @@ class FileList {
lset data 1 {no}
# Set file path
set path [lindex $data 5]
+ if {$::MICROSOFT_WINDOWS} { ;# "\" --> "/"
+ regsub -all "\\\\" $path {/} path
+ }
if {[string first $project_path $path] == 0} {
lset data 5 [string range $path $project_path_length end]
}
@@ -2908,7 +3014,7 @@ class FileList {
lappend file_list $data
# Opened file
- } {
+ } else {
# Find the file in list of opened files
foreach editor $editors {
# Local variables
@@ -2921,6 +3027,9 @@ class FileList {
# Set file path
set path [lindex $data 5]
+ if {$::MICROSOFT_WINDOWS} { ;# "\" --> "/"
+ regsub -all "\\\\" $path {/} path
+ }
if {[string first $project_path $path] == 0} {
lset data 5 [string range $path $project_path_length end]
}
@@ -2969,7 +3078,7 @@ class FileList {
regexp {^.*[\\\/]} $file_name path
if {[catch {
set md5_hash [md5::md5 -hex -hex -file $file_name]
- }]} {
+ }]} then {
set md5_hash {}
}
@@ -2997,7 +3106,7 @@ class FileList {
public method editor_save {} {
if {$splitted && $selectedView} {
[lindex $editors $actualEditor2] save
- } {
+ } else {
[lindex $editors $actualEditor] save
}
}
@@ -3041,13 +3150,13 @@ class FileList {
$editor insertData $data {}
[$editor cget -editor] edit modified 0
[$editor cget -editor] edit reset
- } {
+ } else {
set dir [${::X::actualProject} cget -ProjectDir]
catch {
file delete -force -- [file join $dir .#special:tmp]
}
- set file [open [file join $dir .#special:tmp] w 420]
+ set file [open [file join $dir .#special:tmp] w 0640]
puts -nonewline $file $data
close $file
@@ -3069,10 +3178,10 @@ class FileList {
if {$editorIdx == {}} {
if {$splitted && $selectedView} {
set editorIdx $actualEditor2
- } {
+ } else {
set editorIdx $actualEditor
}
- } {
+ } else {
if {$editorIdx == $actualEditor} {
set selectedView 0
} elseif {$editorIdx == $actualEditor2} {
@@ -3083,12 +3192,13 @@ class FileList {
# Ask user for saving the file (if was modified)
if {$ask && [$editor cget -modified]} {
- set response [tk_messageBox \
- -type yesnocancel \
+ set response [tk_messageBox \
+ -parent . \
+ -type yesnocancel \
-title [mc "Close document - MCU 8051 IDE"] \
- -icon question \
- -default yes \
- -message [mc "The document %s have been modified.\nDo you want to save it ?" [[lindex $editors $editorIdx] cget -fullFileName]]]
+ -icon question \
+ -default yes \
+ -message [mc "The document %s has been modified.\nDo you want to save it ?" [file tail [[lindex $editors $editorIdx] cget -fullFileName]]]]
if {$response == {yes}} {
$editor save
@@ -3137,27 +3247,31 @@ class FileList {
# Adjust object variables
foreach var {editors file_descriptors editor_wdgs file_eol file_encoding file_ro_mode file_sh} {
- set $var [lreplace [subst "\$$var"] $editorIdx $editorIdx]
+ set $var [lreplace [subst -nocommands "\$$var"] $editorIdx $editorIdx]
}
- if {$actualEditor > $editorIdx} {
+ if {$actualEditor == $editorIdx} {
+ set actualEditor {x}
+ } elseif {$actualEditor > $editorIdx} {
incr actualEditor -1
}
- if {$actualEditor2 > $editorIdx} {
+ if {$actualEditor2 == $editorIdx} {
+ set actualEditor2 {x}
+ } elseif {$actualEditor2 > $editorIdx} {
incr actualEditor2 -1
}
- if {$actualEditor == $editorIdx || $actualEditor2 == $editorIdx} {
+ if {$actualEditor == {x} || $actualEditor2 == {x}} {
set do_not_forget_editor 1
- if {$actualEditor == $editorIdx} {
+ if {$actualEditor == {x}} {
set actualEditor -1
}
- if {$actualEditor2 == $editorIdx} {
+ if {$actualEditor2 == {x}} {
set actualEditor2 -1
}
# Conditionaly open a new editor
if {$splitted} {
set min 2
- } {
+ } else {
set min 1
}
if {[llength $file_descriptors] < $min} {
@@ -3197,7 +3311,7 @@ class FileList {
if {$unsaved != {}} {
save_multiple_files $allowCancelButton
return 0
- } {
+ } else {
if {!$projectClose} {
editor_force_close_all
}
@@ -3239,7 +3353,7 @@ class FileList {
] -side right -fill x -expand 1
# Create the middle part of the dialog (list of unsaved files)
- pack [tkk::labelframe $dialog.lf \
+ pack [ttk::labelframe $dialog.lf \
-text [mc "Unsaved files"] \
] -fill both -expand 1 -pady 10 -padx 10
set i 0
@@ -3257,25 +3371,25 @@ class FileList {
pack [ttk::separator $dialog.separator -orient horizontal] -fill x -expand 1
pack [frame $dialog.f]
# SAVESELECTED
- pack [ttk::button $dialog.f.b_save_selected \
- -text [mc "Save selected"] \
- -compound left \
- -image ::ICONS::16::filesave \
- -command {${X::actualProject} save_multiple_files_SAVESELECTED} \
+ pack [ttk::button $dialog.f.b_save_selected \
+ -text [mc "Save selected"] \
+ -compound left \
+ -image ::ICONS::16::filesave \
+ -command {${::X::actualProject} save_multiple_files_SAVESELECTED} \
] -side left
# SAVEALL
pack [ttk::button $dialog.f.b_save_all \
-text [mc "Save all"] \
-compound left \
-image ::ICONS::16::save_all \
- -command {${X::actualProject} save_multiple_files_SAVEALL} \
+ -command {${::X::actualProject} save_multiple_files_SAVEALL} \
] -side left
# DESTROY
pack [ttk::button $dialog.f.b_discard \
-text [mc "Discard"] \
-compound left \
-image ::ICONS::16::editdelete \
- -command {${X::actualProject} save_multiple_files_DESTROY} \
+ -command {${::X::actualProject} save_multiple_files_DESTROY} \
] -side left
# CANCEL
if {$allowCancelButton} {
@@ -3283,7 +3397,7 @@ class FileList {
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {${X::actualProject} save_multiple_files_CANCEL} \
+ -command {${::X::actualProject} save_multiple_files_CANCEL} \
] -side left
}
@@ -3313,7 +3427,7 @@ class FileList {
public method save_multiple_files_SAVESELECTED {} {
set i 0
foreach editor $unsaved {
- set cnd [subst "\${::unsavedfile$i}"]
+ set cnd [subst -nocommands "\${::unsavedfile$i}"]
if {$cnd} {$editor save}
incr i
}
@@ -3365,21 +3479,21 @@ class FileList {
${project_files_buttonBox}open configure -state disabled
# Simulator disengaged
- } {
+ } else {
# Opened file
if {[llength [$listbox_project_files itemcget $item -data]] < 5} {
${project_files_buttonBox}close configure -state normal
${project_files_buttonBox}open configure -state disabled
# Unopened file
- } {
+ } else {
${project_files_buttonBox}close configure -state disabled
${project_files_buttonBox}open configure -state normal
}
}
# Nothing selected
- } {
+ } else {
${project_files_buttonBox}remove configure -state disabled
${project_files_buttonBox}open configure -state disabled
${project_files_buttonBox}close configure -state disabled
@@ -3438,7 +3552,7 @@ class FileList {
}
$project_files_menu entryconfigure [::mc "Open file"] -state disabled
# Unopened file
- } {
+ } else {
if {!$frozen} {
$project_files_menu entryconfigure [::mc "Close file"] -state disabled
}
@@ -3448,7 +3562,7 @@ class FileList {
# Movement commands
if {[$listbox_project_files index $item] == 0} {
set state disabled
- } {
+ } else {
set state normal
}
$project_files_menu entryconfigure [::mc "Move up"] -state $state
@@ -3456,7 +3570,7 @@ class FileList {
if {[$listbox_project_files index $item] == ([llength [$listbox_project_files items]] - 1)} {
set state disabled
- } {
+ } else {
set state normal
}
$project_files_menu entryconfigure [::mc "Move down"] -state $state
@@ -3611,7 +3725,7 @@ class FileList {
set item [$listbox_project_files selection get] ;# Item ID
set record [$listbox_project_files itemcget $item -data] ;# Item data
- # If the file is already opended -- abort
+ # If the file is already opened -- abort
if {[llength $record] == 4} {return}
# Parse item data
@@ -3623,10 +3737,11 @@ class FileList {
# Check for file existence
if {![file exists $file_path$file_name]} {
- tk_messageBox \
+ tk_messageBox \
-title [mc "File not found"] \
- -icon error \
- -type ok \
+ -parent . \
+ -icon error \
+ -type ok \
-message [mc "File %s could not be located at the specified location." $file_name]
return
}
@@ -3634,15 +3749,17 @@ class FileList {
# Verify file MD5 hash
if {[catch {
if {[md5::md5 -hex -file $file_path$file_name] != $file_md5} {
- tk_messageBox \
- -icon warning \
- -type ok \
+ tk_messageBox \
+ -icon warning \
+ -parent . \
+ -type ok \
-title [mc "File changed"] \
-message [mc "File \"%s\" was modified since last project save\nTime: %s" $file_name [clock format [file mtime $file_path$file_name] -format {%T %D}]]
}
}]} then {
tk_messageBox \
-icon warning \
+ -parent . \
-type ok \
-title [mc "Unknown error"] \
-message [mc "Raised error during md5 checking file %s. Maybe md5 extension is not correctly loaded." $file_name]
@@ -3769,7 +3886,7 @@ class FileList {
}
# Unopened file
- } {
+ } else {
if { "[lindex $data 5][lindex $data 0]" == $fullFileName} {
return $item
}
@@ -3785,7 +3902,7 @@ class FileList {
public method change_encoding {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
if {[lindex $file_encoding $idx] == ${::editor_encoding}} {
@@ -3800,7 +3917,7 @@ class FileList {
set ::editor_encoding $original_encoding
lset file_encoding $idx $original_encoding
[lindex $editors $idx] configure -encoding $original_encoding
- } {
+ } else {
# Configure list of project files
set filename [[lindex $editors $idx] cget -fullFileName]
foreach item [$listbox_project_files items] {
@@ -3819,7 +3936,7 @@ class FileList {
public method change_EOL {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
if {[lindex $file_eol $idx] == ${::editor_EOL}} {
@@ -3843,11 +3960,11 @@ class FileList {
}
## Change RO mode in the current editor
- # @return void
+ # @return Bool - true == ok; false == cannot comply!
public method switch_editor_RO_MODE {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
if {[lindex $file_ro_mode $idx] == ${::editor_RO_MODE}} {
@@ -3855,26 +3972,23 @@ class FileList {
}
# Configure editor
+ if {![[lindex $editors $idx] change_RO_MODE ${::editor_RO_MODE}]} {
+ return 0
+ }
lset file_ro_mode $idx ${::editor_RO_MODE}
- [lindex $editors $idx] change_RO_MODE ${::editor_RO_MODE}
# Configure list of project files
set filename [[lindex $editors $idx] cget -fullFileName]
foreach item [$listbox_project_files items] {
set data [$listbox_project_files itemcget $item -data]
- # Unknown bug workaround :-(
- if {[llength $data] < 4} {
- puts "data == {$data}" ;# Dump
- lappend data {}
- }
-
if {[lindex $data 0] == $filename} {
lset data 3 ${::editor_RO_MODE}
$listbox_project_files itemconfigure $item -data $data
break
}
}
+ return 1
}
## Adjust scrollbar for listbox of opened files
@@ -3889,7 +4003,7 @@ class FileList {
set o_scrollbar_visible 0
}
# Show scrollbar
- } {
+ } else {
if {!$o_scrollbar_visible} {
pack $opened_files_scrollbar \
-side left \
@@ -3924,7 +4038,7 @@ class FileList {
set p_scrollbar_visible 0
}
# Show scrollbar
- } {
+ } else {
if {!$p_scrollbar_visible} {
pack $project_files_scrollbar \
-side left \
@@ -4116,7 +4230,7 @@ class FileList {
$filetabs_nb itemconfigure $page -image ::ICONS::16::$icon
# Add bookmark
- } {
+ } else {
lset opened_files_bookmarks $line 1
incr line
$listbox_opened_files_bm image create $line.0 \
@@ -4172,7 +4286,7 @@ class FileList {
incr line
$listbox_project_files_bm delete $line.0 [list $line.0 lineend]
# Add bookmark
- } {
+ } else {
lset project_files_bookmarks $line 1
incr line
$listbox_project_files_bm image create $line.0 \
@@ -4217,7 +4331,7 @@ class FileList {
if {$splitted && $selectedView} {
[lindex $editors $actualEditor2] cmd_line_focus 1
- } {
+ } else {
[lindex $editors $actualEditor] cmd_line_focus 1
}
}
@@ -4243,7 +4357,7 @@ class FileList {
# Save current sash position
if {$pwin_orient == {vertical}} {
set idx 1
- } {
+ } else {
set idx 0
}
set multiview_sash_pos [lindex [$multiview_paned_win sash coord 0] $idx]
@@ -4261,18 +4375,14 @@ class FileList {
# Determinate which editor will be visible now
if {$editor_object != {}} {
- set editor_object [lsearch $editors $editor_object]
- if {$editor_object == $actualEditor2} {
- set selectedView 1
- } {
- set selectedView 0
+ set editor_object [lsearch -ascii -exact $editors $editor_object]
+ if {$editor_object == $actualEditor} {
+ $listbox_opened_files selection set [lindex $file_descriptors $actualEditor2]
+ } elseif {$editor_object == $actualEditor2} {
+ $listbox_opened_files selection set [lindex $file_descriptors $actualEditor]
}
}
- # Insure than the choosen editor (see above) is (in)visible
- if {!$selectedView} {
- $listbox_opened_files selection set [lindex $file_descriptors $actualEditor2]
- }
set selectedView 0
set splitted 0
set actualEditor2 -1
@@ -4329,17 +4439,31 @@ class FileList {
private method split_editor {vert_or_horz} {
if {$splitted} {return}
+ set pwin_orient_orig $pwin_orient
+
# Determinate orientation
if {$vert_or_horz} {
set pwin_orient {horizontal}
- } {
+ } else {
set pwin_orient {vertical}
}
$multiview_paned_win configure -orient $pwin_orient
+ if {$pwin_orient_orig != $pwin_orient} {
+ set multiview_sash_pos 0
+ }
+
# Validate sash position
- if {!$multiview_sash_pos} {
- set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
+ if {$pwin_orient == {vertical}} {
+ if {!$multiview_sash_pos} {
+ set multiview_sash_pos [expr {[winfo height $pagesManager] / 2}]
+ }
+ set minsize 80
+ } else {
+ if {!$multiview_sash_pos} {
+ set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
+ }
+ set minsize 300
}
# Unmap current pages manager and remap it with the second one into paned window
@@ -4349,19 +4473,14 @@ class FileList {
$multiview_paned_win add $pagesManager2 -after $pagesManager
# Configure minimum size for panes
- if {$vert_or_horz} {
- set minsize 300
- } {
- set minsize 80
- }
$multiview_paned_win paneconfigure $pagesManager -minsize $minsize
$multiview_paned_win paneconfigure $pagesManager2 -minsize $minsize
# Move paned window sash
- update idle
+ update idletasks
if {$pwin_orient == {vertical}} {
$multiview_paned_win sash place 0 0 $multiview_sash_pos
- } {
+ } else {
$multiview_paned_win sash place 0 $multiview_sash_pos 0
}
@@ -4377,10 +4496,10 @@ class FileList {
if {$len > 1} {
if {$actualEditor < ($len - 1)} {
set actualEditor2 [expr {$actualEditor + 1}]
- } {
+ } else {
set actualEditor2 0
}
- } {
+ } else {
set selectedView 1
editor_new
set selectedView 0
@@ -4398,7 +4517,7 @@ class FileList {
set listbox $listbox_opened_files
set bookmarks_text $listbox_opened_files_bm
set bookmarks_var {opened_files_bookmarks}
- } {
+ } else {
set listbox $listbox_project_files
set bookmarks_text $listbox_project_files_bm
set bookmarks_var {project_files_bookmarks}
@@ -4420,7 +4539,7 @@ class FileList {
set data [lindex $data 5]
# Opened file
- } {
+ } else {
set data [lindex $data 0]
}
}
@@ -4434,7 +4553,7 @@ class FileList {
set path [lindex $path 5]
# Opened file
- } {
+ } else {
set path [lindex $path 0]
}
}
@@ -4471,7 +4590,7 @@ class FileList {
}
}
# By size (integer comparison)
- } {
+ } else {
for {set i 1} {$i < $num_of_items} {incr i} {
for {set j 1; set k 0} {$j < $num_of_items} {incr j; incr k} {
if {[lindex $items $k] > [lindex $items $j]} {
@@ -4492,7 +4611,7 @@ class FileList {
#+ No GUI will be affected
set new_items_order {}
set bookmarks_new {}
- set bookmarks_org [subst "\$$bookmarks_var"]
+ set bookmarks_org [subst -nocommands "\$$bookmarks_var"]
for {set i 0} {$i < $num_of_items} {incr i} {
set idx [lindex $new_order $i]
lappend new_items_order [$listbox items $idx]
@@ -4525,7 +4644,7 @@ class FileList {
return
}
set filename [$listbox_opened_files itemcget $item -data]
- } {
+ } else {
set item [$listbox_project_files selection get]
if {![$listbox_project_files exists $item]} {
return
@@ -4533,7 +4652,7 @@ class FileList {
set data [$listbox_project_files itemcget $item -data]
if {[llength $data] < 5} {
set filename [lindex $data 0]
- } {
+ } else {
set filename "[lindex $data 5][lindex $data 0]"
}
}
@@ -4549,7 +4668,7 @@ class FileList {
# Start external editor
if {[catch {
exec $command "$filename" &
- }]} {
+ }]} then {
tk_messageBox \
-parent . \
-icon error \
@@ -4565,7 +4684,7 @@ class FileList {
set ::FileList::open_with_cnfr 0
# Create toplevel window
- set win [toplevel .open_with_other_dlg -class {Open with ...} -bg {#EEEEEE}]
+ set win [toplevel .open_with_other_dlg -class {Open with ...} -bg ${::COMMON_BG_COLOR}]
# Create label, entryBox and horizontal separator
pack [label $win.lbl -text [mc "Enter command to execute:"]] -fill x -anchor w -padx 5
@@ -4573,7 +4692,6 @@ class FileList {
-textvariable ::FileList::open_with \
-width 0 \
] -fill x -padx 10 -anchor w
-# pack [ttk::separator $win.sep -orient horizontal] -fill x -padx 5 -pady 10
bind $win.ent <Return> "grab release $win; destroy $win"
bind $win.ent <KP_Enter> "grab release $win; destroy $win"
@@ -4589,7 +4707,7 @@ class FileList {
grab release $win
destroy $win
" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
@@ -4598,7 +4716,7 @@ class FileList {
grab release $win
destroy $win
" \
- ] -side left
+ ] -side left -padx 2
pack $buttonFrame -side bottom -padx 5 -pady 5 -anchor e
# Set window attributes
@@ -4620,7 +4738,7 @@ class FileList {
# Return result
if {${::FileList::open_with_cnfr}} {
return ${::FileList::open_with}
- } {
+ } else {
return {}
}
}
@@ -4688,21 +4806,30 @@ class FileList {
if {$file_number != {} && $simulator_editor != $file_number} {
# Gain target file name
set file_name [$this simulator_get_filename $file_number]
+ if {$::MICROSOFT_WINDOWS} { ;# "/" --> "\"
+ regsub -all {/} $file_name "\\" file_name
+ }
# Search for the given file and try to switch to it
if {$file_switching_enabled || $simulator_editor == -1} {
foreach item [$listbox_opened_files items] {
- if {$file_name != [$listbox_opened_files itemcget $item -data]} {
+ set item_data [$listbox_opened_files itemcget $item -data]
+ if {$::MICROSOFT_WINDOWS} { ;# "/" --> "\"
+ regsub -all {/} $item_data "\\" item_data
+ }
+
+ if {$file_name != $item_data} {
continue
}
$listbox_opened_files selection set $item
+
if {$simulator_editor_obj != {}} {
$simulator_editor_obj disable
- $listbox_opened_files itemconfigure [lindex \
- $file_descriptors [lsearch -ascii -exact \
- $editors $simulator_editor_obj \
- ] \
+ $listbox_opened_files itemconfigure [lindex \
+ $file_descriptors [lsearch -ascii -exact\
+ $editors $simulator_editor_obj \
+ ] \
] -fg {#000000}
}
$listbox_opened_files itemconfigure $item -fg {#FF0000}
@@ -4711,11 +4838,14 @@ class FileList {
]
$simulator_editor_obj freeze
$simulator_editor_obj move_simulator_line $line_number
+
switchfile
set simulator_editor $file_number
+
return
}
}
+
Sbar [mc "Simulator: unable to switch to file: '%s'" $file_name]
# Move simulator pointer directly
@@ -4754,7 +4884,7 @@ class FileList {
## Redraw panel pane
# @return void
public method leftpanel_redraw_pane {} {
- update idle
+ update idletasks
if {$PanelVisible != 0} {
$parent sash place 0 $PanelSize 0
}
@@ -4765,7 +4895,7 @@ class FileList {
public method get_current_editor_object {} {
if {$splitted && $selectedView} {
set editor_num $actualEditor2
- } {
+ } else {
set editor_num $actualEditor
}
return [lindex $editors $editor_num]
@@ -4779,7 +4909,7 @@ class FileList {
if {![winfo ismapped $filetabs_frm]} {
if {$splitted} {
set before $multiview_paned_win
- } {
+ } else {
set before $pagesManager
}
pack $filetabs_frm -fill x -before $before
@@ -4787,7 +4917,7 @@ class FileList {
filelist_adjust_size_of_tabbar
}
# Hide
- } {
+ } else {
if {[winfo ismapped $filetabs_frm]} {
pack forget $filetabs_frm
}
@@ -4801,7 +4931,7 @@ class FileList {
$filetabs_nb see [lindex [$filetabs_nb pages] 0]
update
catch {
- $filetabs_nb.c configure -height 20
+ $filetabs_nb.c configure -height [expr {int(20 * $::font_size_factor)}]
}
$filetabs_nb see [$filetabs_nb raise]
@@ -4822,3 +4952,7 @@ class FileList {
}
}
set ::FileList::ask__append_file_to_project ${::CONFIG(ASK_ON_FILE_OPEN)}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard