Browse Source

Add files via upload

Capitan Cloud 2 năm trước cách đây
mục cha
commit
74bb9d3901
18 tập tin đã thay đổi với 5906 bổ sung0 xóa
  1. 94 0
      edit.tcl
  2. 211 0
      eglib.tcl
  3. 356 0
      file.tcl
  4. 160 0
      filelib.tcl
  5. BIN
      icons/archive.png
  6. BIN
      icons/file-generic.png
  7. BIN
      icons/file-php.png
  8. BIN
      icons/file-txt.png
  9. BIN
      icons/folder.png
  10. BIN
      icons/private-folder.png
  11. BIN
      icons/public-folder.png
  12. BIN
      icons/radxide.png
  13. 77 0
      main.tcl
  14. 98 0
      menu.tcl
  15. 235 0
      radxide.tcl
  16. 28 0
      templates/license/MIT.txt
  17. 721 0
      tree.tcl
  18. 3926 0
      win.tcl

+ 94 - 0
edit.tcl

@@ -0,0 +1,94 @@
+###########################################################
+# Name:    edit.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    27/11/2023
+# Desc:    Edit Menu namespace of RadXIDE.
+#
+#          Edit Menu namespace scaffolding and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################
+
+namespace eval edit {
+
+# ________________________ find _________________________ #
+
+	proc find {win} {
+    # Open the Find window to start a text search
+
+    namespace upvar ::radxide dan dan project project
+
+    set t $dan(TEXT)
+    set args {}
+
+		if {$project(CUR_FILE_PATH) ne {}} {
+
+      #tk_textCopy $t
+      #catch {clipboard get} clipcontent
+
+		  #set sel $clipcontent
+		  
+      set sel [::radxide::win::InitFindInText 0 $t]
+		  
+		  #tk_messageBox -title $dan(TITLE) -icon info -message $sel
+		  
+		  set args "-buttons {butSearch SEARCH ::radxide::win::findTextOK butCANCEL CANCEL ::radxide::win::findTextCancel}"
+		     
+		  catch {lassign [::radxide::win::input "Find" {} "Find text" [list \
+		    ent "{} {} {-w 64}" "{$sel}"] \
+		    -head "Serach for:" {*}$args] res}
+    }
+	}
+
+# ________________________ makeCopy _________________________ #
+
+	proc makeCopy {win} {
+    # Copy from the textPane to the clipboard
+    #clipboard clear
+    #clipboard append $txt
+    tk_textCopy $win
+	}
+
+#_________________________ makeCut ________________________ #
+
+	proc makeCut {win} {
+    # Cut from the textPane to the clipboard
+    #set canvas %W
+    #eval [clipboard get -type TkCanvasItem]
+    tk_textCut $win    
+	}
+	
+#_________________________ makePaste ________________________ #
+
+	proc makePaste {win} {
+    # Paste from the clipboard to the textPane
+    #set canvas %W
+    #eval [clipboard get -type TkCanvasItem]
+    tk_textPaste $win    
+	}
+
+#_________________________ setup ________________________ #
+
+	proc setup {} {
+    # Open the Options window
+    
+    namespace upvar ::radxide dan dan
+    
+    tk_messageBox -title $dan(TITLE) -icon info -message "Setup!"   
+	}
+	
+#_______________________
+
+}
+
+
+# _________________________________ EOF _________________________________ #

+ 211 - 0
eglib.tcl

@@ -0,0 +1,211 @@
+###########################################################
+# Name:    eglib.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    05/12/2023
+# Desc:    Code library code. 
+#
+#          Code Library scaffolding and most of code 
+#          here presented and distributed contain excerpts 
+#          from "Practical Programming in Tcl and Tk, 4th Ed."
+#          by Brent B. Welch, Ken Jones, Jeffrey Hebbs.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to RadXIDE have no 
+#          knowledge about.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyrights © 2003 Pearson Education Inc. (original excerpts.)  
+#
+###########################################################
+
+namespace eval eglib {
+
+  namespace upvar ::radxide dan dan
+
+  set browse(list) [list]
+  set browse(dir) $dan(WORKDIR)/.examples
+	set browse(curix) -1
+	set browse(current) ""
+	set browse(label) {}
+	  
+# ____________________ Scrolled_Text ____________________ #
+
+	proc Scrolled_Text { f args } {
+	# Create the text to display the example
+		frame $f
+		eval {text $f.text -wrap none \
+		-xscrollcommand [list $f.xscroll set] \
+		-yscrollcommand [list $f.yscroll set]} $args
+		scrollbar $f.xscroll -orient horizontal \
+		-command [list $f.text xview]
+		scrollbar $f.yscroll -orient vertical \
+		-command [list $f.text yview]
+		grid $f.text $f.yscroll -sticky news
+		grid $f.xscroll -sticky news
+		grid rowconfigure $f 0 -weight 1
+		grid columnconfigure $f 0 -weight 1
+		return $f.text
+	}
+	
+# ____________________ create ____________________________ #	
+	  
+	proc create {wframe} {
+	  # Create the Code Library window
+	  
+	  namespace upvar ::radxide dan dan
+	
+	  variable browse
+
+		#wm minsize $wframe 30 5
+		#wm title $wframe "Tcl Example Browser"
+
+		# Create a row of buttons along the top
+		#set f $wframe
+		set f [frame $wframe.menubar]
+		pack $f -fill x; #-side left -fill both -expand 1 ;#-fill x
+		
+		# Create the menubutton and menu
+		menubutton $f.ex -text Examples -menu $f.ex.m
+		pack $f.ex -side left
+		set m [menu $f.ex.m]		
+
+		button $f.next -text Next -command ::radxide::eglib::Next
+		button $f.prev -text Previous -command ::radxide::eglib::Previous
+
+		# The Run and Reset buttons use EvalEcho that
+		# is defined by the Tcl shell in Example 24–4 on page 389
+		button $f.load -text Run -command Run -state disabled
+		button $f.reset -text Reset -command ::radxide::eglib::Reset
+
+		# A label identifies the current example
+		set browse(label) [set l [label $f.label]]
+
+		pack $f.reset $f.load $f.next $f.prev $l -side left
+
+		set browse(text) [Scrolled_Text $wframe.body \
+			-width 40 -height 10\
+			-setgrid false]
+		pack $wframe.body -side left -expand 1 -fill both -anchor nw ;#-fill both -expand true	
+	
+		# Look through the example files for their ID number.
+		catch {
+				foreach fpath [lsort -dictionary [glob [file join $browse(dir) *]]] {
+				if [catch {open $fpath} in] {
+					puts stderr "Cannot open $f: $in"
+					continue
+				}
+					set ex [expr 0]
+					while {[gets $in line] >= 0} {
+						#if [regexp {^# Example ([0-9]+)-([0-9]+)} $line x chap ex] {
+							#regexp {^\/\/\w+} $line x
+							set fname [file tail $fpath]
+							set chap [string range $fname [expr [string first \[ $fname]+1] [expr [string last \] $fname]-1]]
+							if {[string length $chap] <=1} {
+								set chap "Various"
+							}
+							set ex [incr $ex]
+							lappend examples($chap) $ex
+							lappend browse(list) $fpath
+							# Read example title
+							#gets $in line
+							set title($chap-$ex) [string trim $line "# "]
+							#tk_messageBox -title radxide -icon error -message $title($chap-$ex)
+							set file($chap-$ex) $fpath
+							close $in
+							break
+						#}
+					}
+				}
+		}		
+		
+
+		# Create two levels of cascaded menus.
+		# The first level divides up the chapters into chunks.
+		# The second level has an entry for each example.
+		option add *Menu.tearOff 0
+		set limit 8
+		set c 0; set i 0
+		foreach chap [lsort [array names examples]] {
+			$m add cascade -label "$chap..." \
+			-menu $m.$c
+			set sub1(chap) [menu $m.$c]
+			incr c
+			
+			set i [expr ($i +1) % $limit]
+			foreach ex [lsort $examples($chap)] {
+				$sub1(chap) add command -label $title($chap-$ex) \
+					-command [list ::radxide::eglib::Browse $file($chap-$ex)]	
+			}
+		}
+  }
+  
+# ___________________ Browse ____________________ #  
+  	
+	proc Browse { file } {
+	# Display a specified file. The label is updated to
+	# reflect what is displayed, and the text is left
+	# in a read-only mode after the example is inserted.
+		variable browse
+		# update the descriptive label with the filename
+		#$browse(label) configure -text [set browse(current) [file tail $file]]
+		set t $browse(text)
+		$t config -state normal
+		$t delete 1.0 end
+		if [catch {open $file} in] {
+			$t insert end $in
+		} else {
+			$t insert end [read $in]
+			close $in
+		}
+		$t config -state disabled
+	}
+
+# ___________________ Next ____________________ #  
+
+	proc Next {} {
+	# Browse the next files in the list
+		variable browse 
+		if {$browse(curix) < ([llength $browse(list)] - 1)} {
+			incr browse(curix)
+		}
+		::radxide::eglib::Browse [lindex $browse(list) $browse(curix)]
+	}
+
+# ___________________ Previous ____________________ #
+
+	proc Previous {} {
+	 # Browse the previous files in the list
+		variable browse
+		if {$browse(curix) > 0} {
+			incr browse(curix) -1
+		}
+		::radxide::eglib::Browse [lindex $browse(list) $browse(curix)]
+	}
+
+# ___________________ Run ____________________ #
+
+
+	proc Run {} {
+  # Run the example in the shell
+		variable browse
+		EvalEcho [list source \
+			[file join $browse(dir) $browse(current)]]
+	}
+
+# ___________________ Reset ____________________ #
+
+
+	proc Reset {} {
+  # Reset the slave in the eval server
+		variable browse
+	 	set t $browse(text)
+		$t config -state normal
+		$t delete 1.0 end
+		$t insert end ""
+		$t config -state disabled
+	}	
+#_______________________	
+	
+}  
+
+# _________________________________ EOF _________________________________ #	  

+ 356 - 0
file.tcl

@@ -0,0 +1,356 @@
+###########################################################
+# Name:    file.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    27/11/2023
+# Desc:    File Menu namespace of RadXIDE.
+#
+#          Edit Menu namespace scaffolding and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################
+
+namespace eval file {
+
+#_________________________ addFile ______________________ #
+
+
+	proc addFile {} {
+    # Add a file to the current project
+
+    namespace upvar ::radxide dan dan
+  
+    set tree $dan(TREEVIEW)
+    
+	  if {[set ID [$tree selection]] eq {}} return
+		
+		::radxide::tree::addFile $ID
+	}
+
+
+#_________________________ closeFile ______________________ #
+
+	proc closeFile {} {
+    # Close the current file
+    
+    namespace upvar ::radxide dan dan menu menu project project
+    
+    # var reset
+		set project(CUR_FILE_PATH) ""
+    
+    # ide text reset
+   	set t $dan(TEXT)
+  	$t config -state normal
+	  $t delete 1.0 end
+	  $t insert end ""
+	  $t config -state disabled
+	  ::radxide::win::fillGutter .danwin.fra.pan.fra2.text .danwin.fra.pan.fra2.gutText 5 1 "#FFFFFF" "#222223"
+	  
+		# Update file Menu
+	  $menu(FILE) entryconfigure $menu(SAVE_AS_ENTRY_IDX) -state disabled
+	  $menu(FILE) entryconfigure $menu(SAVE_ENTRY_IDX) -state disabled
+	  $menu(FILE) entryconfigure $menu(CLOSE_ENTRY_IDX) -state disabled
+    $menu(EDIT) entryconfigure $menu(COPY_ENTRY_IDX) -state disabled
+	  $menu(EDIT) entryconfigure $menu(PASTE_ENTRY_IDX) -state disabled
+	  $menu(EDIT) entryconfigure $menu(CUT_ENTRY_IDX) -state disabled
+	  $menu(EDIT) entryconfigure $menu(FIND_ENTRY_IDX) -state disabled
+	  
+	  ::radxide::main::updateAppTitle		      
+	}
+
+#_________________________ closeProject ______________________ #
+
+	proc closeProject {} {
+    # Close all the files
+    
+    namespace upvar ::radxide dan dan menu menu project project
+    
+    # var reset
+		set project(NAME) ""
+		set project(ROOT) ""
+		set project(PATH) ""
+		set project(CUR_FILE_PATH) ""
+    
+    # ide text reset
+   	set t $dan(TEXT)
+  	$t config -state normal
+	  $t delete 1.0 end
+	  $t insert end ""
+	  $t config -state disabled
+	  ::radxide::win::fillGutter .danwin.fra.pan.fra2.text .danwin.fra.pan.fra2.gutText 5 1 "#FFFFFF" "#222223"
+	  
+	  # ide treeviee reset
+	  set tree $dan(TREEVIEW)
+	  ::radxide::tree::delete $tree {}
+
+		# Update file Menu
+		$menu(FILE) entryconfigure $menu(ADD_FILE_ENTRY_IDX) -state disabled
+	  $menu(FILE) entryconfigure $menu(SAVE_AS_ENTRY_IDX) -state disabled
+	  $menu(FILE) entryconfigure $menu(SAVE_ENTRY_IDX) -state disabled		  
+	  $menu(FILE) entryconfigure $menu(CLOSE_ENTRY_IDX) -state disabled
+    $menu(FILE) entryconfigure $menu(CLOSE_PROJECT_ENTRY_IDX) -state disabled
+
+	  ::radxide::main::updateAppTitle		      
+	  
+	}
+
+
+# ________________________ createProjectStru _______________________ #
+
+  proc createProjectStru {pjroot pjname} {
+  
+    namespace upvar ::radxide dan dan
+  
+    set init_txt ""
+    set init_txt ${init_txt}project_name=$pjname\n
+    set init_txt ${init_txt}project_root=$pjroot\n
+    
+    set fh [open $dan(WORKDIR)/$pjname.radx {WRONLY CREAT EXCL}]
+    puts $fh $init_txt
+    close $fh
+    
+		file mkdir $pjroot
+		file mkdir $pjroot/Private
+		file mkdir $pjroot/Public
+			
+  }
+
+# ________________________ newProject _______________________ #
+
+	proc newProject {} {
+    # Create a new project
+    
+    namespace upvar ::radxide dan dan project project icons icons menu menu
+    
+		set types {
+				{{Project Files}    {.radx}       }
+				{{All Files}        *             }
+		}
+		set oriprojectpath [tk_getSaveFile -initialdir $dan(WORKDIR) -filetypes $types]
+
+		if {$oriprojectpath ne ""} {
+		
+		  # Check: Parent path must equal to Working Dir..
+		  if {[string range $oriprojectpath 0 [expr [string last "/" $oriprojectpath]-1]] ne $dan(WORKDIR)} {
+			
+        tk_messageBox -title $dan(TITLE) -icon error -message "Project must be inside the Working Dir!"			
+			  return
+			  
+			}
+		
+			# Parsing project name and path ..
+			set projectpath $oriprojectpath
+			
+			set projectname [string range $projectpath [expr [string last "/" $projectpath]+1] end]
+			set projectname [string tolower $projectname] 
+			set projectname [string totitle $projectname]
+			set projectname [string map {.radx ""} $projectname]
+			set project(NAME) $projectname
+			
+			set project(ROOT) $dan(WORKDIR)/$project(NAME)
+			
+			set projectpath $project(ROOT).radx
+			set project(PATH) $projectpath
+			
+		  # Check: Project existance..
+		  if {[file exists $oriprojectpath] || [file exists $project(PATH)]} {
+			
+        tk_messageBox -title $dan(TITLE) -icon error -message "Project already exists!"			
+			  return
+			  
+			}
+			
+			# tk_messageBox -title $dan(TITLE) -icon error -message $project(NAME)
+			# tk_messageBox -title $dan(TITLE) -icon error -message $project(ROOT)
+			# tk_messageBox -title $dan(TITLE) -icon error -message $project(PATH)
+			
+			# Creating Project file structure
+			createProjectStru $project(ROOT) $project(NAME)
+							
+			# Update Treeview
+			#catch {::winfun::clearTree $dan(TREEVIEW) $project(TREE_PROJECT_ROOT)}
+			#set project(TREE_PROJECT_ROOT) [$dan(TREEVIEW) insert {} 0 -text $project(NAME) -image $icons(PROJECT-ICONI) -open true]
+			#set project(TREE_PRIVATE_ROOT) [$dan(TREEVIEW) insert $project(TREE_PROJECT_ROOT) 1 -text "Private" -image $icons(PRIVATEF-ICONI)]
+			#set project(TREE_PUBLIC_ROOT) [$dan(TREEVIEW) insert $project(TREE_PROJECT_ROOT) 2 -text "Public" -image $icons(PUBLICF-ICONI)]
+			::radxide::tree::create
+			
+			# Update file Menu
+			$menu(FILE) entryconfigure $menu(ADD_FILE_ENTRY_IDX) -state normal
+      $menu(FILE) entryconfigure $menu(CLOSE_PROJECT_ENTRY_IDX) -state normal		  		        		  		  
+
+			# Update text editor
+			#$dan(TEXT) configure -state normal
+		}
+	}
+
+
+#_________________________ openProject ______________________ #
+
+
+	proc openProject {} {
+    # Open an existing project
+
+    namespace upvar ::radxide dan dan project project icons icons menu menu
+    
+		set types {
+				{{Project Files}    {.radx}       }
+				{{All Files}        *             }
+		}
+		set oriprojectpath [tk_getOpenFile -initialdir $dan(WORKDIR) -filetypes $types]
+
+		if {$oriprojectpath ne ""} {
+		
+		  # Check: Parent path must equal to Working Dir..
+		  if {[string range $oriprojectpath 0 [expr [string last "/" $oriprojectpath]-1]] ne $dan(WORKDIR)} {
+			
+        tk_messageBox -title $dan(TITLE) -icon error -message "Project must be inside the Working Dir!"			
+			  return
+			  
+			}
+		
+			# Parsing project name and path ..
+			set projectpath $oriprojectpath
+			
+			set projectname [string range $projectpath [expr [string last "/" $projectpath]+1] end]
+			set projectname [string tolower $projectname] 
+			set projectname [string totitle $projectname]
+			set projectname [string map {.radx ""} $projectname]
+			set project(NAME) $projectname
+			
+			#tk_messageBox -title $dan(TITLE) -icon error -message $projectname
+			
+			#project_root=/home/pocahontas/.radxwork/Pippo
+			
+			if [catch {open $oriprojectpath} in] {
+	      tk_messageBox -title $dan(TITLE) -icon error -message "Cannot open $projectname."
+      	return
+      }   
+      set project(ROOT) ""
+			while {[gets $in line] >= 0} {
+				regexp {^project_root\=(.+)} $line x project(ROOT)
+				if {$project(ROOT) ne ""} {
+				  break
+				}
+			}
+			#tk_messageBox -title $dan(TITLE) -icon error -message $projectname
+ 			#tk_messageBox -title $dan(TITLE) -icon error -message $project(ROOT)
+			#set project(ROOT) [gets $in line]
+			
+			set projectpath $project(ROOT).radx
+			set project(PATH) $projectpath
+			
+			# Update Treeview
+			::radxide::tree::create
+			
+			# Update file Menu
+			$menu(FILE) entryconfigure $menu(ADD_FILE_ENTRY_IDX) -state normal
+      $menu(FILE) entryconfigure $menu(CLOSE_PROJECT_ENTRY_IDX) -state normal	
+
+			# Update text editor
+			#$dan(TEXT) configure -state normal
+						
+    }
+	}
+
+#____________________________ quit ______________________ #
+
+
+	proc quit {} {
+    # Quit the application
+    radxide::quit
+	}
+
+
+# ________________________ saveFileByName _______________________ #
+
+
+  proc saveFileByName {{withGUI no}} {
+  
+    namespace upvar ::radxide dan dan project project
+    
+    #tk_messageBox -title $dan(TITLE) -icon error -message "file=$project(CUR_FILE_PATH)"
+    
+    if {$withGUI eq yes} {
+    
+      set initialdir [string range $project(CUR_FILE_PATH) 0 [expr [string last "/" $project(CUR_FILE_PATH)]-1]]
+      set initialfile [string range $project(CUR_FILE_PATH) [expr [string last "/" $project(CUR_FILE_PATH)]+1] end]
+      
+			set types {
+					{{HTML Files}       {.html}       }					
+					{{PHP Files}        {.php}        }
+					{{INC Files}        {.inc}        }
+					{{All Files}        *             }
+			}
+			set orifilepath [tk_getSaveFile -initialdir $initialdir -initialfile $initialfile -filetypes $types -defaultextension .php]
+			
+			if {$orifilepath eq ""} {return}
+			
+			# Check: Parent path must equal to Working Dir..
+			if {([string first $project(ROOT)/Private $orifilepath] eq -1) && ([string first $project(ROOT)/Public $orifilepath] eq -1)} {
+			
+	      tk_messageBox -title $dan(TITLE) -icon error -message "File must be saved inside a valid destination in the Working Dir ($project(ROOT)) !"			
+				return
+				
+			}			
+			
+		  set fname $orifilepath
+		  
+		} else {   
+
+		  set fname $project(CUR_FILE_PATH)
+
+    }
+		  
+	  set t $dan(TEXT)
+	  set stxt [string trim [$t get 1.0 end]]
+	   
+	  ::radxide::filelib::saveFile $fname $stxt
+ 
+  }
+
+#_________________________ saveFileAs ______________________ #
+
+
+	proc saveFileAs {} {
+    # Save the current file as..
+    
+    namespace upvar ::radxide dan dan
+    
+    #tk_messageBox -title $dan(TITLE) -icon info -message "Saved as!"    
+    
+    namespace upvar ::radxide project project
+
+		if {$project(CUR_FILE_PATH) ne ""} {
+      saveFileByName yes
+    }
+	}
+
+#_________________________ saveFile ______________________ #
+
+
+	proc saveFile {} {
+    # Save the current file
+    
+    namespace upvar ::radxide dan dan project project
+
+    #tk_messageBox -title $dan(TITLE) -icon info -message "Saved!"
+
+		if {$project(CUR_FILE_PATH) ne ""} {
+      saveFileByName no
+    }
+	}
+
+#_________________________#
+
+}
+
+
+# _________________________________ EOF _________________________________ #

+ 160 - 0
filelib.tcl

@@ -0,0 +1,160 @@
+###########################################################
+# Name:    filelib.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    01/12/2023
+# Desc:    Files namespace of RadXIDE.
+#
+#          Files namespace and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################
+
+
+namespace eval filelib {
+
+# __________________________ createFile _________________________ #
+
+
+	proc createFile {{destfolder ""}} {
+		# Create a file.
+		#   fname - file name
+		#   stxt - text to save
+
+		namespace upvar ::radxide dan dan project project
+		
+		set n "newfile"
+		
+		#tk_messageBox -title $dan(TITLE) -icon error -message $destfolder
+		
+		if {$destfolder ne ""} {
+		
+		  #tk_messageBox -title $dan(TITLE) -icon error -message "Yess!"
+		
+		  set num 1
+		  while {[file exists $destfolder/$n$num]} {  
+		    incr num
+		  }
+
+		  #tk_messageBox -title $dan(TITLE) -icon error -message $destfolder/$n$num	
+		  
+		  set fname $destfolder/$n$num
+		
+		  set fh [open $fname {WRONLY CREAT}]
+		  set stxt ""
+		  puts $fh $stxt
+		  close $fh		
+		}
+	}
+
+# __________________________ delFile _________________________ #
+
+
+	proc delFile {{fname ""}} {
+		# Delete a file.
+		#   fname - file name
+
+		if {($fname ne "")} {
+		
+		  catch {[file delete $fname]}
+
+		}
+	}
+
+# __________________________ openFile _________________________ #
+
+
+	proc openFile {{fname ""} {reload no} {islist no} {Message {}}} {
+		# Handles "Open file" menu item.
+		#   fnames - file name (if not set, asks for it)
+		#   reload - if yes, loads the file even if it has a "strange" extension
+		#   islist - if yes, *fnames* is a file list
+		#   Message - name of procedure for "open file" message
+		# Returns the file's tab ID if it's loaded, or {} if not loaded.
+
+    namespace upvar ::radxide dan dan
+
+    set ret ""
+
+    if {$fname ne ""} {
+
+      #tk_messageBox -title $dan(TITLE) -icon error -message "Yess!"
+
+		  if {[file size $fname] > $dan(MAXFILESIZE)} {
+		    tk_messageBox -title $dan(TITLE) -icon error -message "File exceed MAXFILESIZE=$dan(MAXFILESIZE)"
+		    return $ret
+		  }
+
+			set fh [open $fname {RDONLY}]
+			set ret [set data [read $fh]]
+			close $fh
+
+    }
+		
+		return $ret
+	}
+
+# __________________________ saveFile _________________________ #
+
+
+	proc saveFile {{fname ""} {stxt ""}} {
+		# Saves a file.
+		#   fname - file name
+		#   stxt - text to save
+
+		namespace upvar ::radxide dan dan project project
+		#if {[info exists al(THIS-ENCODING)]} {
+		#  set enc "-encoding $al(THIS-ENCODING)" ;# at saving "no name"
+		#} else {
+		#  set enc [Encoding $fname]
+		#}
+		#if {[info exists al(THIS-EOL)]} {
+		#  set eol "-translation $al(THIS-EOL)" ;# at saving "no name"
+		#} else {
+		#  set eol [EOL $fname]
+		#}
+		#append enc " $eol"
+		#set al(_NO_OUTWARD_) {}
+		#set wtxt [alited::main::GetWTXT $TID]
+		#if {$al(prjtrailwhite)} {alited::edit::RemoveTrailWhites $TID yes $doit}
+		#set fcont [$wtxt get 1.0 "end - 1 chars"]  ;# last \n excluded
+		#if {![::apave::writeTextFile $fname fcont 0 1 {*}$enc]} {
+		#  alited::msg ok err [::apave::error $fname] -w 50 -text 1
+		#  unset al(_NO_OUTWARD_)
+		#  return 0
+		#}
+		#unset al(_NO_OUTWARD_)
+		#OutwardChange $TID no
+		#alited::edit::BackupFile $TID
+		#if {!$doit} {
+		#  $wtxt edit modified no
+		#  alited::edit::Modified $TID $wtxt
+		#  alited::main::HighlightText $TID $fname $wtxt
+		#  RecreateFileTree
+		#}
+		#return 1
+		
+		if {($fname ne "") && ($stxt ne "")} {
+		
+		  #tk_messageBox -title $dan(TITLE) -icon error -message "Yess!"
+		
+		  #tk_messageBox -title $dan(TITLE) -icon error -message $fname
+		
+		  set fh [open $fname {WRONLY CREAT}]
+		  puts $fh $stxt
+		  close $fh		
+		}
+	}
+#_______________________
+
+}
+
+# _________________________________ EOF _________________________________ #	  

BIN
icons/archive.png


BIN
icons/file-generic.png


BIN
icons/file-php.png


BIN
icons/file-txt.png


BIN
icons/folder.png


BIN
icons/private-folder.png


BIN
icons/public-folder.png


BIN
icons/radxide.png


+ 77 - 0
main.tcl

@@ -0,0 +1,77 @@
+###########################################################
+# Name:    main.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    25/11/2023
+# Desc:    Main form of RadXIDE.
+# License: MIT.
+###########################################################
+
+
+namespace eval main {
+
+# ________________________ Main _create _________________________ #
+
+	proc _create {} {
+		# Creates the main form of radxide.
+
+		namespace upvar ::radxide dan dan
+		
+		::radxide::win::makeMainWindow $dan(WIN).fra $dan(TITLE) $dan(BG) $dan(FG)
+
+	}
+
+# ________________________ ShowHeader _________________________ #
+
+	proc updateAppTitle {} {
+		# Displays a file's name and modification flag (*) in alited's title.
+
+		namespace upvar ::radxide dan dan project project
+
+    #tk_messageBox -title $dan(TITLE) -icon error -message $project(CUR_FILE_PATH)
+
+  	set f "<no file>"
+    if {$project(CUR_FILE_PATH) ne ""} {
+      set f [string range $project(CUR_FILE_PATH) [expr [string length $dan(WORKDIR)]+1] end]
+  	}  
+  	#tk_messageBox -title $dan(TITLE) -icon error -message $f
+	  set t $dan(TITLE)
+	  set templ $dan(TITLE_TEMPL)
+	  set ttl [string map [list %f $f %t $t] $templ]
+	  wm title $dan(WIN) [string trim $ttl]
+
+	}
+
+# ________________________ Main _run _________________________ #
+
+	proc _run {} {
+		# Runs the alited, displaying its main form with attributes
+		# 'modal', 'not closed by Esc', 'decorated with Contract/Expand buttons',
+		# 'minimal sizes' and 'saved geometry'.
+		#
+		# After closing the alited, saves its settings (geometry etc.).
+
+		namespace upvar ::radxide dan dan
+
+		wm attributes $dan(WIN) -topmost
+		updateAppTitle
+		wm iconphoto $dan(WIN) $dan(ICONI)
+		wm resizable $dan(WIN) 0 0
+		::radxide::win::centerWin $dan(WIN) $dan(WIDTH) $dan(HEIGHT)
+		wm minsize $dan(WIN) $dan(WIDTH) $dan(HEIGHT)
+		wm attributes $dan(WIN) -fullscreen 0
+		wm protocol . WM_DELETE_WINDOW { radxide::quit }
+    
+    catch {focus -force $dan(TEXT)}
+    
+    # Modal
+		set var 1
+		::radxide::win::waitWinVar $dan(WIN) $var 1
+		# --
+		
+		destroy $dan(WIN)
+		update
+		return 1
+	}
+
+}
+# _________________________________ EOF _________________________________ #

+ 98 - 0
menu.tcl

@@ -0,0 +1,98 @@
+###########################################################
+# Name:    menu.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    27/11/2023
+# Desc:    Menu namespace of RadXIDE.
+#
+#          Menu namespace and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################
+
+namespace eval menu {
+
+# ________________________ MenuScaf _________________________ #
+
+	proc menuScaf {} {
+	
+	  namespace upvar ::radxide dan dan menu menu
+
+	  set aboutTEXT ""	
+	  #set aboutTEXT "MIT Licence.\n\n\n" 
+	  #set aboutTEXT "${aboutTEXT}Copyrights 5 Mode\n\n"
+	  #set aboutTEXT "${aboutTEXT}http://5mode.com\n\n\n"
+	  #set aboutTEXT "${aboutTEXT}Most of code here presented and distributed contain excerpts"
+    #set aboutTEXT "${aboutTEXT}from Alited (https://github.com/aplsimple/alited"
+    #set aboutTEXT "${aboutTEXT}by Alex Plotnikov and contributors to the project."
+    #set aboutTEXT "${aboutTEXT}The original code of these excerpts could be" 
+    #set aboutTEXT "${aboutTEXT}borrowed from other sources which the author"
+    #set aboutTEXT "${aboutTEXT}and the contributors to this RadXIDE have no"
+    #set aboutTEXT "${aboutTEXT}knowledge about.\n\n\n"
+    #set aboutTEXT "${aboutTEXT}For other rights and copyright see each file header."
+	
+		# menu
+		set menu(ROOT) [set m [menu .mb]]
+		$m add cascade -label File -menu $m.file
+		set m1 [menu $m.file -tearoff 0]
+		set menu(FILE) $m1
+		$m1 add command -label "New project" -command { ::radxide::menu::file::newProject } -accelerator Ctrl+N
+		$m1 add command -label "Open project" -command { ::radxide::menu::file::openProject } -accelerator Ctrl+O
+		$m1 add command -label "Add file" -command { ::radxide::menu::file::addFile } -accelerator Ctrl+Shift+N -state disabled
+		$m1 add separator
+		$m1 add command -label "Save as.." -command { ::radxide::menu::file::saveFileAs } -accelerator Ctrl+Shift+S	-state disabled
+		$m1 add command -label "Save" -command { ::radxide::menu::file::saveFile } -accelerator Ctrl-S -state disabled
+		$m1 add separator
+		$m1 add command -label "Close" -command { ::radxide::menu::file::closeFile } -accelerator Ctrl+Shift+X -state disabled
+		$m1 add command -label "Close project" -command { ::radxide::menu::file::closeProject } -accelerator Ctrl+Alt+X	-state disabled	
+		$m1 add separator  	
+		$m1 add command -label Exit -command { ::radxide::menu::file::quit } -accelerator Ctrl+Q
+		$m add cascade -label Edit -menu $m.edit
+		set m2 [menu $m.edit -tearoff 0]
+		set menu(EDIT) $m2
+		$m add cascade -label Help -menu $m.help
+		$m2 add command -label Copy -command { ::radxide::menu::edit::makeCopy .danwin.fra.text }  -accelerator Ctrl+C -state disabled
+		$m2 add command -label Paste -command { ::radxide::menu::edit::makePaste .danwin.fra.text } -accelerator Ctrl+P -state disabled
+		$m2 add command -label Cut -command { ::radxide::menu::edit::makeCut .danwin.fra.text } -accelerator Ctrl+X -state disabled
+		$m2 add separator
+		$m2 add command -label Find -command { ::radxide::menu::edit::find .danwin.fra.text } -accelerator Ctrl+F -state disabled
+		$m2 add separator
+		$m2 add command -label Options -command { ::radxide::menu::edit::setup } 
+		set m3 [menu $m.help -tearoff 0]
+		$m3 add command -label About -command { tk_messageBox -title $dan(TITLE) -icon info -message "\n\nRADXIDE ver 1.0.5\n\n\nMIT Licence.\n\n\nCopyrights (c) 2023-2024 5 Mode http://5mode.com\n\nThe software is provided AS-IS.\n\nA great 'Thank you' to Alex Plotnikov and his Alited (copyrights notice are included in the single files of RADXIDE!)\n\n\n"}
+    return $m
+	}
+
+# ________________________ defMUShortcuts _________________________ #
+
+	proc defWinShortcuts {ctrl canvas} {
+	
+	  namespace upvar ::radxide dan dan
+	
+ 	  bind $ctrl "<Control-n>" { ::radxide::menu::file::newProject }
+ 	  bind $ctrl "<Control-o>" { ::radxide::menu::file::openProject }
+ 	  bind $ctrl "<Control-Alt-x>" { ::radxide::menu::file::closeProject }
+ 	  bind $ctrl "<Control-q>" { ::radxide::menu::file::quit }
+ 	  bind $ctrl "<Control-c>" "::radxide::menu::edit::makeCopy $ctrl"
+ 	  bind $ctrl "<Control-p>" "::radxide::menu::edit::makePaste $ctrl"
+ 	  bind $ctrl "<Control-x>" "::radxide::menu::edit::makeCut $ctrl"
+ 	  bind $ctrl "<Control-f>" "::radxide::menu::edit::find $ctrl"
+		
+	}	
+	
+#_______________________
+
+  source [file join . file.tcl]
+  source [file join . edit.tcl]
+
+}
+
+# _________________________________ EOF _________________________________ #

+ 235 - 0
radxide.tcl

@@ -0,0 +1,235 @@
+#! /usr/bin/env tclsh
+###########################################################
+# Name:    radxide.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    05/12/2023
+# Desc:    Starting file of RadXIDE.
+#
+#          Starting file and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+#          Code Library scaffolding and most of its code 
+#          from "Practical Programming in Tcl and Tk, 4th Ed."
+#          by Brent B. Welch, Ken Jones, Jeffrey Hebbs.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to RadXIDE have no 
+#          knowledge about. For the related copyright notice
+#          refer <eglib.tcl> part of this software.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################
+
+package provide radxide 1.0.5
+
+set _ [package require Tk]
+wm withdraw .
+
+if {![package vsatisfies $_ 8.6.10-]} {
+  tk_messageBox -message "\nradxide needs Tcl/Tk v8.6.10+ \
+    \n\nwhile the current is v$_\n"
+  exit
+}
+
+unset -nocomplain _
+
+
+# __________________________ radxide:: Main _________________________ #
+
+namespace eval radxide {
+
+  variable dan; array set dan [list]
+  
+  variable tcltk_version "Tcl/Tk [package versions Tk]"
+
+  ## ________________________ Main variables _________________________ ##
+
+  set DEBUG no  ;# debug mode
+  
+  set dan(WIN) .danwin              ;# main form
+  set dan(WORKDIR) "/home/pocahontas/.radxwork"  ;# root working dir
+  set dan(TITLE) RADXIDE
+  
+  # Check workdir existance..
+  if {![file exists $dan(WORKDIR)]} {
+    file mkdir $dan(WORKDIR)
+  }
+
+  # Check Code Library dir existance.. (WORKDIR)/.examples)
+  if {![file exists $dan(WORKDIR)/.examples]} {
+    file mkdir $dan(WORKDIR)/.examples
+  }
+    
+  set dan(TREEVIEW) ""              ;# ide project tree
+  set dan(TEXT) ""                  ;# ide text control
+  set dan(prjdirignore) {.git .bak} ;# ignored subdirectories of project
+  
+  set project(NAME) ""              ;# project default name
+  set project(ROOT) ""              ;# project default root
+  set project(PATH) ""              ;# project default path
+  set project(CUR_FILE_PATH) ""     ;# project current file path
+  set project(TREE_PROJECT_ROOT) "" ;# Treeview: Project root node
+  set project(TREE_PRIVATE_ROOT) "" ;# Treeview: Private node
+  set project(TREE_PUBLIC_ROOT) ""  ;# Treeview: Public node
+  
+  set files(FILE1) ""             ;# Array files
+  set files(FILE2) ""
+  set files(FILE3) ""  
+  set files(FILE4) ""  
+  set files(FILE5) ""  
+  
+  # main data of radxide (others are in ini.tcl)
+
+  variable SCRIPT [info script]
+  variable SCRIPTNORMAL [file normalize $SCRIPT]
+  variable FILEDIR [file dirname $SCRIPTNORMAL]
+  variable DIR [file dirname $FILEDIR]
+
+  # directories of sources
+  variable SRCDIR [file join $DIR src]
+  variable LIBDIR [file join $DIR lib]
+
+  # misc. vars
+  variable pID 0
+
+  # directory tree's content
+  variable _dirtree [list]
+  
+  set dan(TITLE_TEMPL) {%f :: %t}   ;# radxide title's template
+  set dan(WIDTH) 1600
+  set dan(HEIGHT) 800
+  #set al(MOVEFG) "black"
+  #set al(MOVEBG) "#7eeeee"  
+  set dan(FG) "#000000"
+  set dan(BG) "#cecece"  
+  set dan(fgred) "red"
+  set dan(fgbold) "magenta"
+  set dan(fgtodo) "orange"
+  set dan(fgbranch) "blue"    
+  set dan(CHARFAMILY) "Sans"
+  set dan(CHARSIZE) 10
+  set dan(MAXFILES) 250
+  set dan(MAXFILESIZE) 65534
+  set dan(MAXFINDLENGTH) 50 
+   
+  # icons
+  set dan(ICON) "icons/radxide.png"
+  set dan(ICONI) [image create photo imgobj1 -file $dan(ICON)]
+      
+  set icons(PROJECT-ICON) "icons/archive.png"
+  set icons(PROJECT-ICONI) [image create photo imgobj2 -file $icons(PROJECT-ICON)]
+  set icons(PUBLICF-ICON) "icons/public-folder.png"
+  set icons(PUBLICF-ICONI) [image create photo imgobj3 -file $icons(PUBLICF-ICON)]
+  set icons(PRIVATEF-ICON) "icons/private-folder.png"
+  set icons(PRIVATEF-ICONI) [image create photo imgobj4 -file $icons(PRIVATEF-ICON)]
+  set icons(PHP-ICON) "icons/file-php.png"
+  set icons(PHP-ICONI) [image create photo imgobj5 -file $icons(PHP-ICON)]
+  set icons(GENERIC-FILE-ICON) "icons/file-generic.png"
+  set icons(GENERIC-FILE-ICONI) [image create photo imgobj6 -file $icons(GENERIC-FILE-ICON)]
+  set icons(FOLDER-ICON) "icons/folder.png"
+  set icons(FOLDER-ICONI) [image create photo imgobj7 -file $icons(FOLDER-ICON)]
+  
+  # Menu variables
+  set menu(ROOT) "";
+  set menu(ADD_FILE_ENTRY_IDX) 2;
+  set menu(SAVE_AS_ENTRY_IDX) 4;
+  set menu(SAVE_ENTRY_IDX) 5;
+  set menu(CLOSE_ENTRY_IDX) 7;
+  set menu(CLOSE_PROJECT_ENTRY_IDX) 8;      
+  set menu(COPY_ENTRY_IDX) 0;
+  set menu(PASTE_ENTRY_IDX) 1;
+  set menu(CUT_ENTRY_IDX) 2;
+  set menu(FIND_ENTRY_IDX) 4;    
+    
+  set dan(PhpExts) {.php .php2 .php3 .php4 .php5 .funny}     ;# extensions of Php files
+     
+# __________________ iswindows ___________________ #
+
+
+	proc iswindows {} {
+		# Checks for "platform is MS Windows".
+
+		expr {$::tcl_platform(platform) eq {windows}}
+	}
+
+# __________________ quit ___________________ #
+
+
+  proc quit {{w ""} {res 0} {ask yes}} {
+    # Closes alited application.
+    #   w - not used
+    #   res - result of running of main window
+    #   ask - if "yes", requests the confirmation of the exit
+
+    exit 0;
+  }
+
+# __________________ raise_window ___________________ #
+
+
+  proc raise_window {} {
+    # Raises the app's window.
+
+    variable dan
+    catch {
+      wm withdraw $dan(WIN)
+      wm deiconify $dan(WIN)
+    }
+  }
+
+# __________________ Tclexe ___________________ #
+
+
+  proc Tclexe {} {
+    # Gets Tcl's executable file.
+
+    variable dan
+  
+    set tclexe [info nameofexecutable]
+  
+    return $tclexe
+  }
+
+  
+  source [file join $SRCDIR main.tcl]
+  source [file join $SRCDIR filelib.tcl]
+  source [file join $SRCDIR win.tcl] 
+  source [file join $SRCDIR menu.tcl]
+  source [file join $SRCDIR tree.tcl]
+  source [file join $SRCDIR eglib.tcl] 
+   
+  ## _ EONS: radxide _ ##
+}  
+
+# ________________________ ::argv, ::argc _________________________ #
+
+
+set ::radxide::ARGV $::argv
+set ::radxide::dan(IsWindows) [expr {$::tcl_platform(platform) eq {windows}}]
+
+# _________________________ Run the app _________________________ #
+
+
+namespace upvar ::radxide dan dan
+
+radxide::main::_create  ;# create the main form
+unset -nocomplain _
+
+if {[catch {set res [radxide::main::_run]} err]} {
+  set res 0
+  set msg "\nERROR in radxide:"
+  puts \n$msg\n\n$::errorInfo\n
+  set msg "$msg\n\n$err\n\nPlease, inform authors.\nDetails are in stdout."
+  tk_messageBox -title $dan(TITLE) -icon error -message $msg
+  exit 2
+}
+
+# _________________________________ EOF _________________________________ #

+ 28 - 0
templates/license/MIT.txt

@@ -0,0 +1,28 @@
+###########################################################
+# Name:    radxide
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    05/12/2023
+# Desc:    RadXIDE.
+#
+#          Starting file and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+#          Code Library scaffolding and most of its code 
+#          from "Practical Programming in Tcl and Tk, 4th Ed."
+#          by Brent B. Welch, Ken Jones, Jeffrey Hebbs.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to RadXIDE have no 
+#          knowledge about. For the related copyright notice
+#          refer <eglib.tcl> part of this software.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################

+ 721 - 0
tree.tcl

@@ -0,0 +1,721 @@
+###########################################################
+# Name:    tree.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    05/12/2023
+# Desc:    Tree namespace of RadXIDE.
+#
+#          Tree namespace and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################
+
+namespace eval tree {
+
+# ________________________ AddItem _________________________ #
+
+
+	proc addFile {{ID ""}} {
+		# Adds a new item to the tree.
+		#   ID - an item's ID where the new item will be added (for the file tree).
+
+		namespace upvar ::radxide dan dan
+
+    set tree $dan(TREEVIEW)
+    lassign [$tree item $ID -values] -> fname isfile
+    set destfolder $fname
+    
+    if {!$isfile} {
+    
+      #tk_messageBox -title $dan(TITLE) -icon error -message $destfolder
+        
+      ::radxide::filelib::createFile $destfolder
+      
+      # Refreshing TreeView
+      ::radxide::tree::create
+      
+    }  
+
+	}
+
+# ________________________ addTags _________________________ #
+
+
+	proc addTags {tree} {
+		# Creates tags for the tree.
+		#   tree - the tree's path
+
+		namespace upvar ::radxide dan dan
+		#lassign [::hl_tcl::addingColors {} -AddTags] - - fgbr - - fgred - - - fgtodo
+
+		$tree tag configure tagNorm -foreground $dan(FG)
+		$tree tag configure tagSel  -foreground $dan(fgred)
+		$tree tag configure tagBold -foreground $dan(fgbold)
+		$tree tag configure tagTODO -foreground $dan(fgtodo)
+		$tree tag configure tagBranch -foreground $dan(fgbranch)
+	}
+
+# ________________________ AddToDirContents _________________________ #
+
+	proc addToDirContent {lev isfile fname iroot} {
+		# Adds an item to a list of directory's contents.
+		#   lev - level in the directory hierarchy
+		#   isfile - a flag "file" (if yes) or "directory" (if no)
+		#   fname - a file name to be added
+		#   iroot - index of the directory's parent or -1
+
+		namespace upvar ::radxide dan dan _dirtree _dirtree
+		set dllen [llength $_dirtree]
+		if {$dllen < $dan(MAXFILES)} {
+		  lappend _dirtree [list $lev $isfile $fname 0 $iroot]
+		  if {$iroot>-1} {
+		    lassign [lindex $_dirtree $iroot] lev isfile fname fcount sroot
+		    set _dirtree [lreplace $_dirtree $iroot $iroot \
+		      [list $lev $isfile $fname [incr fcount] $sroot]]
+		  }
+		}
+		return $dllen
+	}
+
+# ________________________ buttonPress _________________________ #
+
+
+	proc buttonPress {but x y X Y} {
+		# Handles a mouse clicking the tree.
+		#   but - mouse button
+		#   x - x-coordinate to identify an item
+		#   y - y-coordinate to identify an item
+		#   X - x-coordinate of the click
+		#   Y - x-coordinate of the click
+
+		namespace upvar ::radxide dan dan menu menu
+		set tree $dan(TREEVIEW)
+		set ID [$tree identify item $x $y]
+		set region [$tree identify region $x $y]
+		#set al(movID) [set al(movWin) {}]
+		if {![$tree exists $ID] || $region ni {tree cell}} {
+		  return  ;# only tree items are processed
+		}
+		#tk_messageBox -title $dan(TITLE) -icon error -message $but
+		switch $but {
+		  {3} {
+		    if {[llength [$tree selection]]<2} {
+		      $tree selection set $ID
+		    }
+		    showPopupMenu $ID $X $Y
+		  }
+		  {1} {
+		    #::radxide::tree::openFile $ID
+		    
+		    lassign [$tree item $ID -values] -> fname isfile
+     		if {$isfile} {
+     		  $menu(FILE) entryconfigure $menu(ADD_FILE_ENTRY_IDX) -state disabled
+		    } else {
+		      $menu(FILE) entryconfigure $menu(ADD_FILE_ENTRY_IDX) -state normal
+		    }   
+		  }
+		}
+	}
+
+# ________________________ buttonRelease _________________________ #
+
+
+	proc buttonRelease {but s x y X Y} {
+		# Handles a mouse button releasing on the tree, at moving an item.
+		#   but - mouse button
+		#   s - state (ctrl/alt/shift)
+		#   x - x-coordinate to identify an item
+		#   y - y-coordinate to identify an item
+		#   X - x-coordinate of the click
+		#   Y - x-coordinate of the click
+
+		namespace upvar ::radxide dan dan
+		
+		set tree $dan(TREEVIEW)
+		set ID [$tree identify item $x $y]
+		#DestroyMoveWindow no
+		#set msec [clock milliseconds]
+		#set ctrl [expr {$s & 0b100}]
+		#if {([info exists al(_MSEC)] && [expr {($msec-$al(_MSEC))<400}]) || $ctrl} {
+		#  SelectUnits $wtree $ctrl
+		#  set al(movWin) {}
+		#  return
+		#}
+		#if {[$tree exists $ID] && [info exists al(movID)] && \
+		#$al(movID) ne {} && $ID ne {} && $al(movID) ne $ID && \
+		#[$wtree identify region $x $y] eq {tree}} {
+		#  if {$al(TREE,isunits)} {
+		#    alited::unit::MoveUnits $wtree move $al(movID) $ID
+		#  } else {
+		#    alited::file::MoveFiles $wtree move $al(movID) $ID
+		#  }
+		#}
+		#DestroyMoveWindow yes
+	}
+
+# ________________________ clearTree _________________________ #
+
+	proc clearTree {TreeView item} {
+		# Removes recursively an item and its children from the tree.
+		#   TreeView - the tree widget's path
+		#   item - ID of the item to be deleted.
+
+		foreach child [$TreeView children $item] {
+		  clearTree $TreeView $child
+		}
+		if {$item ne {}} {$TreeView delete $item}
+	}
+
+# ________________________ create _________________________ #
+
+	proc create {} {
+		# Creates a tree of files, at need.
+		
+		namespace upvar ::radxide dan dan menu menu
+
+		set tree $dan(TREEVIEW)
+
+	  # for file tree: get its current "open branch" flags
+	  # in order to check them in createFilesTree
+	  set dan(SAVED_FILE_TREE) [list]
+	  foreach item [getTree] {
+	    lassign $item - - ID - values
+	    lassign $values -> fname isfile
+	    if {[string is false -strict $isfile]} {
+	      lappend dan(SAVED_FILE_TREE) [list $fname [$tree item $ID -open]]
+	    }
+	  }
+
+		#set TID [alited::bar::CurrentTabID]
+		delete $tree {}
+		addTags $tree
+		bind $tree "<ButtonPress>" {after idle {::radxide::tree::buttonPress %b %x %y %X %Y}}
+		#bind $tree "<ButtonRelease>" {after idle {::radxide::tree::buttonRelease %b %s %x %y %X %Y}}
+		bind $tree "<Double-Button-1>" {after idle {::radxide::tree::dblClick %b %x %y %X %Y}}
+		#bind $tree "<Motion>" {after idle {::radxide::tree::ButtonMotion %b %s %x %y %X %Y}}
+		#bind $tree "<ButtonRelease>" {alited::tree::DestroyMoveWindow no}
+		#bind $tree "<Leave>" {alited::tree::DestroyMoveWindow yes}
+		#bind $tree "<F2>" {alited::file::RenameFileInTree 0 -}
+		#bind $tree "<Insert>" {alited::tree::AddItem}
+		#bind $tree "<Delete>" {alited::tree::DelItem {} {}}
+
+		createFileTree $tree
+		unset dan(SAVED_FILE_TREE)
+
+    $menu(FILE) entryconfigure $menu(ADD_FILE_ENTRY_IDX) -state disabled
+
+	}
+
+# ________________________ createFileTree _________________________ #
+
+	proc createFileTree {tree} {
+
+		# Creates a file tree.
+		#   wtree - the tree's path
+
+		namespace upvar ::radxide dan dan project project icons icons 
+		#set al(TREE,files) yes
+		#[$obPav BtTswitch] configure -image alimg_gulls
+		#baltip::tip [$obPav BtTswitch] $al(MC,swfiles)
+		#baltip::tip [$obPav BtTAddT] $al(MC,filesadd)\nInsert
+		#baltip::tip [$obPav BtTDelT] $al(MC,filesdel)\nDelete
+		#baltip::tip [$obPav BtTUp] $al(MC,moveupF)
+		#baltip::tip [$obPav BtTDown] $al(MC,movedownF)
+		#$tree heading #0 -text ":: [file tail $al(prjroot)] ::"
+		#$tree heading #1 -text $al(MC,files)
+		bind $tree <Return> {::radxide::tree::openFile}
+		set selID ""
+		#if {[catch {set selfile [alited::bar::FileName]}]} {
+		#  set selfile {} ;# at closing by Ctrl+W with file tree open: no current file
+		#}
+		
+		set parent {}
+		set fc 0
+		set fname $project(ROOT)
+		set title [file tail $fname]
+		set isfile no
+		set itemID 0
+		set isopen yes
+		set imgopt $icons(PROJECT-ICONI)
+		
+		$tree insert $parent end -id $itemID -text "$title" \
+		    -values [list $fc $fname $isfile $itemID] -open $isopen -image $imgopt
+		
+		foreach item [getDirectoryContent $project(ROOT)] {
+		  set itemID [newItemID [incr iit]]
+		  lassign $item lev isfile fname fcount iroot
+		  #if {$selfile eq $fname} {set selID $itemID}
+		  set title [file tail $fname]
+		  if {$iroot<0} {
+		    set parent 0 ;#{}
+		  } else {
+		    set parent [newItemID [incr iroot]]
+		  }
+		  set isopen no
+		  if {$isfile} {
+		  
+		    if {$parent eq 0} {
+		      continue
+		    } 
+		  
+		    if {[isPhp $fname]} {
+		      set imgopt $icons(PHP-ICONI)
+		    } else {
+		      set imgopt $icons(GENERIC-FILE-ICONI)
+		    }
+		  } else {
+        
+        if {$title eq "Private"} {
+	        set imgopt $icons(PRIVATEF-ICONI)
+	      } elseif {$title eq "Public"} {
+	        set imgopt $icons(PUBLICF-ICONI)
+	      } else {
+	      
+	        if {$parent eq 0} {
+		        continue
+		      } 
+	      
+	        set imgopt $icons(FOLDER-ICONI)	
+	      }  
+		    
+		    # get the directory's flag of expanded branch (in the file tree)
+		    set idx [lsearch -index 0 -exact $dan(SAVED_FILE_TREE) $fname]
+		    if {$idx>-1} {
+		      set isopen [lindex $dan(SAVED_FILE_TREE) $idx 1]
+		    }
+		  }
+		  if {$fcount} {set fc $fcount} {set fc {}}
+		  $tree insert $parent end -id $itemID -text "$title" \
+		    -values [list $fc $fname $isfile $itemID] -open $isopen -image $imgopt
+		  $tree tag add tagNorm $itemID
+		  if {!$isfile} {
+		    $tree tag add tagBranch $itemID
+		  }
+		}
+		if {$selID ne {}} {
+		  $tree see $selID
+		  $tree selection set $selID
+		}
+	}
+
+# ________________________ delete _________________________ #
+
+	proc deleteFile {ID} {
+		# Removes a file.
+		#   ID - ID of the item to be deleted.
+
+    namespace upvar ::radxide dan dan
+
+    set tree $dan(TREEVIEW)
+
+		if {$ID eq {}} {
+		  if {[set ID [$tree selection]] eq {}} return
+		}
+		lassign [$tree item $ID -values] -> fname isfile
+
+    if {$isfile} {
+    
+      set answer [tk_messageBox -title $dan(TITLE) -message "Really delete the selected file?" \
+        -icon question -type yesno -detail "Selected: \"$fname\""]
+    
+      if {$answer eq yes} {
+        ::radxide::filelib::delFile $fname
+        
+        ::radxide::tree::create
+      }    
+    }
+	}
+
+# ________________________ delete _________________________ #
+
+	proc delete {tree item} {
+		# Removes recursively an item and its children from the tree.
+		#   tree - the tree widget's path
+		#   item - ID of the item to be deleted.
+
+		foreach child [$tree children $item] {
+		  delete $tree $child
+		}
+		if {$item ne {}} {$tree delete $item}
+	}
+
+# ________________________ dblClick _________________________ #
+
+
+	proc dblClick {but x y X Y} {
+		# Handles a mouse clicking the tree.
+		#   but - mouse button
+		#   x - x-coordinate to identify an item
+		#   y - y-coordinate to identify an item
+		#   X - x-coordinate of the click
+		#   Y - x-coordinate of the click
+
+		namespace upvar ::radxide dan dan
+		set tree $dan(TREEVIEW)
+		set ID [$tree identify item $x $y]
+		set region [$tree identify region $x $y]
+		#set al(movID) [set al(movWin) {}]
+		if {![$tree exists $ID] || $region ni {tree cell}} {
+		  return  ;# only tree items are processed
+		}
+		#tk_messageBox -title $dan(TITLE) -icon error -message DoubleClick: ($but)
+		switch $but {
+		  {3} {
+
+  	  }
+		  {1} {
+		    #set al(movID) $ID
+		    #set al(movWin) .tritem_move
+		    #set msec [clock milliseconds]
+		    #if {[info exists al(_MSEC)] && [expr {($msec-$al(_MSEC))<400}]} {
+		    ::radxide::tree::openFile $ID
+		    #}
+		    #set al(_MSEC) $msec
+		  }
+		}
+	}
+
+# ________________________ dirContent _________________________ #
+
+	proc dirContent {dirname {lev 0} {iroot -1} {globs "*"}} {
+		# Reads a directory's contents.
+		#   dirname - a dirtectory's name
+		#   lev - level in the directory hierarchy
+		#   iroot - index of the directory's parent or -1
+		#   globs - list of globs to filter files.
+
+		namespace upvar ::radxide dan dan _dirtree _dirtree
+		incr lev
+		if {[catch {set dcont [lsort -dictionary [glob [file join $dirname *]]]}]} {
+		  set dcont [list]
+		}
+		# firstly directories:
+		# 1. skip the ignored ones
+		for {set i [llength $dcont]} {$i} {} {
+		  incr i -1
+		  if {[ignoredDir [lindex $dcont $i]]} {
+		    set dcont [lreplace $dcont $i $i]
+		  }
+		}
+		# 2. put the directories to the beginning of the file list
+		set i 0
+		foreach fname $dcont {
+		  if {[file isdirectory $fname]} {
+		    set dcont [lreplace $dcont $i $i [list $fname "y"]]
+		    set nroot [addToDirContent $lev 0 $fname $iroot]
+		    if {[llength $_dirtree] < $dan(MAXFILES)} {
+		      dirContent $fname $lev $nroot $globs
+		    } else {
+		      break
+		    }
+		  } else {
+		    set dcont [lreplace $dcont $i $i [list $fname]]
+		  }
+		  incr i
+		}
+		# then files
+		if {[llength $_dirtree] < $dan(MAXFILES)} {
+		  foreach fname $dcont {
+		    lassign $fname fname d
+		    if {$d ne "y"} {
+		      foreach gl [split $globs ","] {
+		        if {[string match $gl $fname]} {
+		          addToDirContent $lev 1 $fname $iroot
+		          break
+		        }
+		      }
+		    }
+		  }
+		}
+	}
+
+# ________________________ getDirectoryContent _________________________ #
+
+
+	proc getDirectoryContent {dirname} {
+		# Gets a directory's content.
+		#   dirname - the directory's name
+		# Returns a list containing the directory's content.
+
+		namespace upvar ::radxide dan dan _dirtree _dirtree
+		set _dirtree [set dan(_dirignore) [list]]
+		set _dirtree [list]
+		catch {    ;# there might be an incorrect list -> catch it
+		  foreach d $dan(prjdirignore) {
+		    lappend dan(_dirignore) [string toupper [string trim $d \"]]
+		  }
+		}
+		lappend dan(_dirignore) [string toupper [file tail [::radxide::Tclexe]]]
+		dirContent $dirname
+		return $_dirtree
+	}
+
+# ________________________ ignoredDir _________________________ #
+
+	proc getTree {{parent {}}} {
+		# Gets a tree or its branch.
+		#   parent - ID of the branch
+		#   Tree - name of the tree widget
+
+		namespace upvar ::radxide dan dan
+		set tree $dan(TREEVIEW)
+		set mytree [list]
+		set levp -1
+		procTreeItems $tree {
+		  set item "%item"
+		  set lev %level
+		  if {$levp>-1 || $item eq $parent} {
+		    if {$lev<=$levp} {return -code break}  ;# all of branch fetched
+		    if {$item eq $parent} {set levp $lev}
+		  }
+		  catch {
+		    if {$parent eq {} || $levp>-1} {
+		      lappend mytree [list $lev %children $item {%text} {%values}]
+		    }
+		  }
+		}
+		return $mytree
+	}
+
+# ________________________ ignoredDir _________________________ #
+
+	proc ignoredDir {dir} {
+		# Checks if a directory is in the list of the ignored ones.
+		#   dir - the directory's name
+
+		namespace upvar ::radxide dan dan
+		set dir [string toupper [file tail $dir]]
+		return [expr {[lsearch -exact $dan(_dirignore) $dir]>-1}]
+	}
+
+# ________________________ isPhp _________________________ #
+
+	proc isPhp {fname} {
+		# Checks if a file is of PHP.
+		#   fname - file name
+
+		if {[string tolower [file extension $fname]] in $radxide::dan(PhpExts)} {
+		  return yes
+		}
+		return no
+	}
+
+# ________________________ newItemID _________________________ #
+
+	proc newItemID {iit} {
+		# Gets a new ID for the tree item.
+		#   iit - index of the new item.
+
+		return "al$iit"
+	}
+
+# ________________________ openFile _________________________ #
+
+
+	proc openFile {{ID ""}} {
+		# Opens file at clicking a file tree's item.
+		#   ID - ID of file tree
+
+		namespace upvar ::radxide dan dan menu menu project project
+
+		set tree $dan(TREEVIEW)
+		#tk_messageBox -title $dan(TITLE) -icon error -message $ID
+		if {$ID eq {}} {
+		  if {[set ID [$tree selection]] eq {}} return
+		}
+		lassign [$tree item $ID -values] -> fname isfile
+		if {$isfile} {
+		  $dan(TEXT) config -state normal
+		  $dan(TEXT) delete 1.0 end 
+		  $dan(TEXT) insert 1.0 [::radxide::filelib::openFile $fname]
+		  ::radxide::win::fillGutter .danwin.fra.pan.fra2.text .danwin.fra.pan.fra2.gutText 5 1 "#FFFFFF" "#222223"
+			
+		  # Update menu
+	    $menu(FILE) entryconfigure $menu(SAVE_ENTRY_IDX) -state normal
+	    $menu(FILE) entryconfigure $menu(SAVE_AS_ENTRY_IDX) -state normal
+	    $menu(FILE) entryconfigure $menu(CLOSE_ENTRY_IDX) -state normal
+	    $menu(EDIT) entryconfigure $menu(COPY_ENTRY_IDX) -state normal
+	    $menu(EDIT) entryconfigure $menu(PASTE_ENTRY_IDX) -state normal
+	    $menu(EDIT) entryconfigure $menu(CUT_ENTRY_IDX) -state normal	    
+	    $menu(EDIT) entryconfigure $menu(FIND_ENTRY_IDX) -state normal
+	    
+	    set project(CUR_FILE_PATH) $fname
+	    
+	    ::radxide::main::updateAppTitle
+	    		  
+		  # after idle {alited::bar::BAR draw; alited::tree::UpdateFileTree}
+		}
+
+	}
+
+
+# ________________________ procTreeItems _________________________ #
+
+
+	proc procTreeItems {tree aproc {lev 0} {branch {}}} {
+		# Scans all items of the tree.
+		#   tree - the tree's path
+		#   aproc - a procedure to run at scanning
+		#   lev - level of the tree
+		#   branch - ID of the branch to be scanned
+		# The 'aproc' argument can include wildcards to be replaced
+		# appropriate data:
+		#    %level - current tree level
+		#    %children - children of a current item
+		#    %item - ID of a current item
+		#    %text - text of a current item
+		#    %values - values of a current item
+
+		set children [$tree children $branch]
+		if {$lev} {
+		  set proc [string map [list \
+		    %level $lev \
+		    %children [llength $children] \
+		    %item $branch \
+		    %text [$tree item $branch -text] \
+		    %values [$tree item $branch -values]] \
+		    $aproc]
+		  uplevel [expr {$lev+1}] "$proc"
+		}
+		incr lev
+		foreach child $children {
+		  procTreeItems $tree $aproc $lev $child
+		}
+	}
+
+# ________________________ refreshTree _________________________ #
+
+
+  proc refreshTree {{tree ""} {headers ""} {clearsel no}} {
+  
+     namespace upvar ::radxide dan dan
+  
+     if {$tree eq ""} {
+       set tree $dan(TREEVIEW)
+     }
+  
+     if {[set selID [$tree selection]] eq {}} return
+     #tk_messageBox -title $dan(TITLE) -icon error -message $selID
+     
+     ::radxide::tree::create
+     
+     $tree selection set [list $selID]
+     
+  }
+
+# ________________________ renameFile _________________________ #
+
+
+  proc renameFile {{ID ""}} {
+  
+    namespace upvar ::radxide dan dan
+  
+    set tree $dan(TREEVIEW)
+    set args {}
+    set name2 ""
+    
+		if {$ID eq {}} {
+		  if {[set ID [$tree selection]] eq {}} return
+		}
+		lassign [$tree item $ID -values] -> fname isfile 
+  
+    # lassign [::radxide::win::input {} "Rename file" [list \
+    #   ent "{} {} {-w 32}" "{$fname}"] \
+    #   -head "File name:" res name2]
+    
+    set args "-buttons {butOK OK ::radxide::win::renameFileOK butCANCEL CANCEL ::radxide::win::renameFileCancel}"
+       
+    catch {lassign [::radxide::win::input "RenameFile" {} "Rename file" [list \
+      ent "{} {} {-w 64}" "{$fname}"] \
+      -head "File name:" {*}$args] res}
+  
+    #tk_messageBox -title $dan(TITLE) -icon error -message $res
+    #tk_messageBox -title $dan(TITLE) -icon error -message $name2
+  
+  }
+
+# ________________________ showPopupMenu _________________________ #
+
+
+	proc showPopupMenu {ID X Y} {
+		# Creates and opens a popup menu at right clicking the tree.
+		#   ID - ID of clicked item
+		#   X - x-coordinate of the click
+		#   Y - y-coordinate of the click
+
+		namespace upvar ::radxide dan dan project project
+		
+		
+		#::baltip sleep 1000
+		set tree $dan(TREEVIEW)
+		set popm $tree.popup
+		catch {destroy $popm}
+		menu $popm -tearoff 0 -cursor ""
+		set header [lindex [split "" \n] 0]
+
+		lassign [$tree item $ID -values] -> fname isfile
+		
+		set m1 "Refresh project"
+		set m2 "Add file"
+		set m3 "Rename file"
+		set m4 "Delete file"
+		set m3b "Rename folder"
+		set m4b "Delete folder"
+		set m5 "Open file" 
+		set m6 "Open dir"  
+		
+		$popm add command -label $m1 -command { ::radxide::tree::refreshTree }
+		$popm add separator
+		if {$isfile} {
+		  $popm add command -label $m2 -command "::radxide::tree::addFile $ID" -state disabled
+		} else {
+		  $popm add command -label $m2 -command "::radxide::tree::addFile $ID" -state normal
+		}
+		if {$isfile} {  
+  		$popm add command -label $m3 -command "::radxide::tree::renameFile $ID"
+	  	$popm add command -label $m4 -command "::radxide::tree::deleteFile $ID" 
+	  } else {
+  		if {($fname eq "$project(ROOT)/Public") || ($fname eq "$project(ROOT)/Private")} {
+	  		$popm add command -label $m3b -command "::radxide::tree::renameFolder $ID" -state disabled
+  	  	$popm add command -label $m4b -command "::radxide::tree::delFolder $ID" -state disabled
+  	  } else {
+	  		$popm add command -label $m3b -command "::radxide::tree::renameFolder $ID" -state normal
+  	  	$popm add command -label $m4b -command "::radxide::tree::delFolder $ID" -state normal
+      }  	  	
+	  }	
+		$popm add separator
+		if {$isfile} {
+		  $popm add command -label $m5 -command "::radxide::tree::openFile $ID" -state normal
+		} else {
+		  $popm add command -label $m5 -command { ::radxide::tree::openFile $ID } -state disabled
+		}  
+		
+		set addsel {}
+		if {[llength [$tree selection]]>1} {
+		  if {[$tree tag has tagSel $ID]} {
+		    # the added tagSel tag should be overrided
+		    $tree tag remove tagSel $ID
+		    set addsel "; $tree tag add tagSel $ID"
+		  }
+		}  
+		
+		bind $popm <FocusIn> "$tree tag add tagBold $ID"
+		bind $popm <FocusOut> "catch {$tree tag remove tagBold $ID; $addsel}"
+		#$obPav themePopup $popm
+		tk_popup $popm $X $Y
+	}
+
+#_______________________
+
+	
+}	
+
+# _________________________________ EOF _________________________________ #

+ 3926 - 0
win.tcl

@@ -0,0 +1,3926 @@
+###########################################################
+# Name:    win.tcl
+# Author:  Daniele Bonini  (posta@elettronica.lol)
+# Date:    26/11/2023
+# Desc:    Win(ndow) library of RadXIDE.
+#
+#          Win library scaffolding and most of code 
+#          here presented and distributed contain excerpts 
+#          from [alited](https://github.com/aplsimple/alited
+#          by Alex Plotnikov and contributors to the project.
+#          The original code of these excerpts could be 
+#          borrowed from other sources which the author
+#          and the contributors to this RadXIDE have no 
+#          knowledge about.
+#
+# License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
+#               Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
+#
+###########################################################
+
+
+namespace eval win {
+
+  array set _PU_opts [list -NONE =NONE=]
+  set _PU_opts(_MODALWIN_) [list]
+  variable _AP_Properties; array set _AP_Properties [list]
+  variable _AP_ICO { none folder OpenFile SaveFile saveall print font color \
+    date help home misc terminal run tools file find replace other view \
+    categories actions config pin cut copy paste plus minus add delete \
+    change diagram box trash double more undo redo up down previous next \
+    previous2 next2 upload download tag tagoff tree lock light restricted \
+    attach share mail www map umbrella gulls sound heart clock people info \
+    err warn ques retry yes no ok cancel exit }
+  variable _AP_IMG;  array set _AP_IMG [list]
+  variable _AP_VARS; array set _AP_VARS [list]  
+  variable UFF "\uFFFF"
+  variable querydlg {}
+  variable CheckNomore
+  array set msgarray [list]
+  set Dlgpath ""
+  set Dlgname ""  
+  set dlg(PATH) ""
+  set dlg(NAME) ""
+  set dlg(FIELDS) {}
+  set Indexdlg 0	
+  set _savedvv [list]
+  set MODALWINDOW {}
+  set Foundstr {}
+#  array set data [list]
+#  set data(en1) {}
+#  set data(docheck) yes 
+  set Foundstr {}   ;# current found string
+  set HLstring {}   ;# current selected string
+        
+  set _Defaults [dict create \
+    bts {{} {}} \
+    but {{} {}} \
+    buT {{} {-width -20 -pady 1}} \
+    btT {{} {-width -20 -pady 1 -relief flat -overrelief raised -highlightthickness 0 -takefocus 0}} \
+    can {{} {}} \
+    chb {{} {}} \
+    swi {{} {}} \
+    chB {{} {-relief sunken -padx 6 -pady 2}} \
+    cbx {{} {}} \
+    fco {{} {}} \
+    ent {{} {}} \
+    enT {{} {-insertwidth $::apave::cursorwidth -insertofftime 250 -insertontime 750}} \
+    fil {{} {}} \
+    fis {{} {}} \
+    dir {{} {}} \
+    fon {{} {}} \
+    clr {{} {}} \
+    dat {{} {}} \
+    fiL {{} {}} \
+    fiS {{} {}} \
+    diR {{} {}} \
+    foN {{} {}} \
+    clR {{} {}} \
+    daT {{} {}} \
+    sta {{} {}} \
+    too {{} {}} \
+    fra {{} {}} \
+    ftx {{} {}} \
+    frA {{} {}} \
+    gut {{} {-width 0 -highlightthickness 1}} \
+    lab {{-sticky w} {}} \
+    laB {{-sticky w} {}} \
+    lfr {{} {}} \
+    lfR {{} {-relief groove}} \
+    lbx {{} {-activestyle none -exportselection 0 -selectmode browse}} \
+    flb {{} {}} \
+    meb {{} {}} \
+    meB {{} {}} \
+    nbk {{} {}} \
+    opc {{} {}} \
+    pan {{} {}} \
+    pro {{} {}} \
+    rad {{} {}} \
+    raD {{} {-padx 6 -pady 2}} \
+    sca {{} {-orient horizontal -takefocus 0}} \
+    scA {{} {-orient horizontal -takefocus 0}} \
+    sbh {{-sticky ew} {-orient horizontal -takefocus 0}} \
+    sbH {{-sticky ew} {-orient horizontal -takefocus 0}} \
+    sbv {{-sticky ns} {-orient vertical -takefocus 0}} \
+    sbV {{-sticky ns} {-orient vertical -takefocus 0}} \
+    scf {{} {}} \
+    seh {{-sticky ew} {-orient horizontal -takefocus 0}} \
+    sev {{-sticky ns} {-orient vertical -takefocus 0}} \
+    siz {{} {}} \
+    spx {{} {}} \
+    spX {{} {}} \
+    tbl {{} {-selectborderwidth 1 -highlightthickness 2 \
+          -labelcommand tablelist::sortByColumn -stretch all \
+          -showseparators 1}} \
+    tex {{} {-undo 1 -maxundo 0 -highlightthickness 2 -insertofftime 250 -insertontime 750 -insertwidth $::apave::cursorwidth -wrap word -selborderwidth 1 -exportselection 0}} \
+    tre {{} {-selectmode browse}} \
+    h_ {{-sticky ew -csz 3 -padx 3} {}} \
+    v_ {{-sticky ns -rsz 3 -pady 3} {}}]
+  
+    
+  set TexM {}
+
+# __________________________ AddButtonIcon _________________________ #
+
+
+  proc AddButtonIcon {w attrsName} {
+    # Gets the button's icon based on its text and name (e.g. butOK) and
+    # appends it to the attributes of button.
+    #   w - button's name
+    #   attrsName - name of variable containing attributes of the button
+
+    upvar 1 $attrsName attrs
+    set com [getOption -com {*}$attrs]
+    if {[string is integer -strict $com]} {
+      extractOptions attrs -com {}
+      append attrs " -com {[self] res {} $com}" ;# returned integer result
+    }
+    if {[getOption -image {*}$attrs] ne {}} return
+    set txt [getOption -t {*}$attrs]
+    if {$txt eq {}} { set txt [getOption -text {*}$attrs] }
+    set im {}
+    set icolist [list {exit abort} {exit close} \
+      {SaveFile save} {OpenFile open}]
+    # ok, yes, cancel, apply buttons should be at the end of list
+    # as their texts can be renamed (e.g. "Help" in e_menu's "About")
+    lappend icolist {*}[iconImage] {yes apply}
+    foreach icon $icolist {
+      lassign $icon ic1 ic2
+      # text of button is of highest priority at defining its icon
+      if {[string match -nocase $ic1 $txt] || \
+      [string match -nocase b*t$ic1 $w] || ($ic2 ne {} && ( \
+      [string match -nocase b*t$ic2 $w] || [string match -nocase $ic2 $txt]))} {
+        if {[string match -nocase btT* $w]} {
+          set cmpd none
+        } else {
+          set cmpd left
+        }
+        append attrs " [iconA $ic1 small $cmpd]"
+        break
+      }
+    }
+    return
+  }
+
+# __________________ AddPopupAttr ________________#
+
+
+  proc AddPopupAttr {w attrsName atRO isRO args} {
+    # Adds the attribute to call a popup menu for an editable widget.
+    #   w - widget's name
+    #   attrsName - variable name for attributes of widget
+    #   atRO - "readonly" attribute (internally used)
+    #   isRO - flag of readonly widget
+    #   args - widget states to be checked
+
+    upvar 1 $attrsName attrs
+    lassign $args state state2
+    if {$state2 ne {}} {
+      if {[getOption -state {*}$attrs] eq $state2} return
+      set isRO [expr {$isRO || [getOption -state {*}$attrs] eq $state}]
+    }
+    if {$isRO} {append atRO RO}
+    append attrs " $atRO $w"
+    return
+  }
+
+# __________________________ AppendButtons _________________________ #
+
+
+  proc AppendButtons {widlistName buttons neighbor pos defb timeout win modal} {
+    # Adds buttons to the widget list from a position of neighbor widget.
+    #   widlistName - variable name for widget list
+    #   buttons - buttons to add
+    #   neighbor - neighbor widget
+    #   pos - position of neighbor widget
+    #   defb - default button
+    #   timeout  - timeout (to count down seconds and invoke a button)
+    #   win - dialogue's path
+    #   modal - yes if the window is modal
+    # Returns list of "Help" button's name and command.
+
+    upvar $widlistName widlist
+    namespace upvar ::radxide dan dan
+    variable Dlgpath
+ 
+    set Defb1 [set Defb2 [set bhlist {}]]
+    foreach {but txt res} $buttons {
+      #set com "res $Dlgpath"
+      #set com "::radxide::win::res $Dlgpath"
+      #if {[info commands $res] eq {}} {
+      #  set com "$com $res"
+      #} else {
+      #  if {$res eq {destroy}} {
+      #    # for compatibility with old modal windows
+      #    if {$modal} {set res "$com 0"} {set res "destroy $win"}
+      #  }
+      #  set com $res  ;# "res" is set as a command
+      #}
+      set com $res
+      if {$but eq {butHELP}} {
+        # Help button contains the command in "res"
+        set com [string map "%w $win" $res]
+        set bhlist [list $but $com]
+      } elseif {$Defb1 eq {}} {
+        set Defb1 $but
+      } elseif {$Defb2 eq {}} {
+        set Defb2 $but
+      }
+      if {[set _ [string first "::" $txt]]>-1} {
+        set tt " -tip {[string range $txt $_+2 end]}"
+        set txt [string range $txt 0 $_-1]
+      } else {
+        set tt {}
+      }
+      if {$timeout ne {} && ($defb eq $but || $defb eq {})} {
+        set tmo "-timeout {$timeout}"
+      } else {
+        set tmo {}
+      }
+      if {$but eq {butHELP}} {
+        set neighbor [lindex $widlist end 1]
+        set widlist [lreplace $widlist end end]
+        lappend widlist [list $but $neighbor T 1 1 {-st w} \
+          "-t \"$txt\" -com \"$com\"$tt $tmo -tip F1"]
+        set h h_Help
+        lappend widlist [list $h $but L 1 94 {-st we}]
+        set neighbor $h
+      } else {
+        lappend widlist [list $but $neighbor $pos 1 1 {-st we} \
+          "-t \"$txt\" -com \"$com\"$tt $tmo"]
+        set neighbor $but
+      }
+      set pos L
+    }
+    lassign [LowercaseWidgetName $Dlgpath.fra.$Defb1] Defb1
+    lassign [LowercaseWidgetName $Dlgpath.fra.$Defb2] Defb2
+    return $bhlist
+  }
+
+# __________________________ appendDialogField _________________________ #  
+  
+  
+  proc addDialogField {fldname oldval newval} {
+    
+    variable dlg
+    
+    set newlist [list $fldname $oldval $newval]
+    
+    set dlg(FIELDS) [linsert $dlg(FIELDS) end $newlist]
+
+  }
+
+# __________________________ basicFontSize _________________________ #
+
+
+  proc basicFontSize {{fs 0} {ds 0}} {
+    # Gets/Sets a basic size of font used in apave
+    #    fs - font size
+    #    ds - incr/decr of size
+    # If 'fs' is omitted or ==0, this method gets it.
+    # If 'fs' >0, this method sets it.
+
+    namespace upvar ::radxide dan dan 
+
+    #if {$fs} {
+    #  set ::radxide::_CS_(fs) [expr {$fs + $ds}]
+    #  my create_Fonts
+    #  return $::radxide::_CS_(fs)
+    #} else {
+    #  return [expr {$::radxide::_CS_(fs) + $ds}]
+    #}
+    
+    return $dan(CHARSIZE)
+    
+  }
+
+# __________________________ basicDefFont _________________________ #
+
+
+  proc basicDefFont {{deffont ""}} {
+    # Gets/Sets a basic default font.
+    #    deffont - font
+    # If 'deffont' is omitted or =="", this method gets it.
+    # If 'deffont' is set, this method sets it.
+
+    namespace upvar ::radxide dan dan
+
+    #if {$deffont ne ""} {
+    #  return [set ::apave::_CS_(defFont) $deffont]
+    #} else {
+    #  return $::apave::_CS_(defFont)
+    #}
+    
+    return $dan(CHARFAMILY)
+  }
+
+# __________________________ basicTextFont _________________________ #
+
+
+  proc basicTextFont {{textfont ""}} {
+    # Gets/Sets a basic font used in editing/viewing text widget.
+    #    textfont - font
+    # If 'textfont' is omitted or =="", this method gets it.
+    # If 'textfont' is set, this method sets it.
+
+    namespace upvar ::radxide dan dan
+
+    #if {$textfont ne ""} {
+    #  return [set ::apave::_CS_(textFont) $textfont]
+    #} else {
+    #  return $::apave::_CS_(textFont)
+    #}
+    
+    return $dan(CHARFAMILY)
+  }
+  
+# __________________________ checkXY _________________________ #
+
+	proc checkXY {win w h x y} {
+		# Checks the coordinates of window (against the screen).
+		#   w - width of window
+		#   h - height of window
+		#   x - window's X coordinate
+		#   y - window's Y coordinate
+		# Returns new coordinates in +X+Y form.
+
+		# check for left/right edge of screen (accounting decors)
+		set scrw [expr {[winfo vrootwidth $win] - 12}]
+		set scrh [expr {[winfo vrootheight $win] - 36}]
+		if {($x + $w) > $scrw } {
+		  set x [expr {$scrw - $w}]
+		}
+		if {($y + $h) > $scrh } {
+		  set y [expr {$scrh - $h}]
+		}
+		if {![string match -* $x]} {set x +[string trimleft $x +]}
+		if {![string match -* $y]} {set y +[string trimleft $y +]}
+		return ${x}x${y}
+	}
+
+# _________________________ centeredXY ________________________ #
+
+	proc centeredXY {win rw rh rx ry w h} {
+		# Gets the coordinates of centered window (against its parent).
+		#   rw - parent's width
+		#   rh - parent's height
+		#   rx - parent's X coordinate
+		#   ry - parent's Y coordinate
+		#   w - width of window to be centered
+		#   h - height of window to be centered
+		# Returns centered coordinates in +X+Y form.
+
+		set x [expr {max(0, $rx + ($rw - $w) / 2)}]
+		set y [expr {max(0,$ry + ($rh - $h) / 2)}]
+		return [checkXY $win $w $h $x $y]
+	}
+
+
+# ________________________ centerWin _________________________ #
+
+
+  proc centerWin {win wwidth wheight} {
+  
+    namespace upvar ::radxide dan dan
+  
+		set screen_width [winfo screenwidth $win]
+		set screen_height [winfo screenheight $win]
+		#tk_messageBox -title $dan(TITLE) -icon error -message $screen_width
+		set half_screen_w [expr {0}]
+		if {[expr {$screen_width/$screen_height} > 2]} {
+		  set half_screen_w [expr {$screen_width/2}]
+		  set wrong_geo [centeredXY $win $half_screen_w $screen_height 0 0 $wwidth $wheight]
+		} else {  
+		  set wrong_geo [centeredXY $win $screen_width $screen_height 0 0 $wwidth $wheight]
+		}  
+		#set geo [string map {x ""} $geo]
+		#wm geometry $dan(WIN) "=$dan(WIDTH)x$dan(HEIGHT)$geo"
+		wm geometry $win =${wwidth}x${wheight}
+		# Lets do it modal:
+		set offsetx [winfo x $win]
+		set offsety [winfo y $win]		
+		set disinfox [winfo pointerx [winfo parent $win]]
+		#tk_messageBox -title $dan(TITLE) -icon error -message $disinfox
+		#tk_messageBox -title $dan(TITLE) -icon error -message $half_screen_w
+		set display [expr {1}]
+		if { $disinfox>$half_screen_w } { 
+		  set display [expr {2}]
+		} 
+		#tk_messageBox -title $dan(TITLE) -icon error -message $display
+		set newx [expr {($half_screen_w-$wwidth)/2}]
+		if {$display>1} {
+  		set newx [expr {$half_screen_w+(($half_screen_w-$wwidth)/2)}]
+  	}	
+  	#tk_messageBox -title $dan(TITLE) -icon error -message newx=$newx
+		set newy [expr {70}]
+		wm geometry $win +$newx+$newy
+  }
+
+
+#_______________________ CheckData _______________________ #
+
+#	proc CheckData {op} {
+#		# Checks if the find/replace data are valid.
+#		#   op - if "repl", checks for "Replace" operation
+#		# Return "yes", if the input data are valid.
+#
+#    namespace upvar :radxide dan dan
+#
+#		variable data
+#		
+#		# this means "no checks when used outside of the dialogue":
+#		if {!$data(docheck)} {return yes}
+#
+#		set ret yes
+#    if {[set data(en1)] eq {}} { set ret no }
+#    if {[set data(en1)] > $dan(MAXFINDLENGTH)} { set ret no }
+#    
+#		if {$ret eq no} {
+#		  # if find/replace field is empty, let the bell tolls for him
+#		  bell
+#		  return no
+#		}
+#		return yes
+#	}
+
+# ________________________ CleanUps _________________________ #
+
+
+  proc CleanUps {{wr ""}} {
+
+  }
+
+
+  proc danInitDialogs {} {
+
+    namespace upvar ::radxide dan dan
+
+    variable Dlgpath
+    variable Dlgname  
+    variable dlg
+    variable Indexdlg
+ 
+    set Dlgpath ""
+    set Dlgname ""  
+    set dlg(PATH) ""
+    set dlg(NAME) ""
+    set dlg(FIELDS) {}
+    set Indexdlg 0
+  
+  }
+
+# ________________________ defaultATTRS _________________________ #
+
+  proc defaultATTRS {{type ""} {opts ""} {atrs ""} {widget ""}} {
+    # Sets, gets or registers default options and attributes for widget type.
+    #   type - widget type
+    #   opts - new default grid/pack options
+    #   atrs - new default attributes
+    #   widget - Tcl/Tk command for the new registered widget type
+    # The *type* should be a three letter unique string.
+    # If the *type* is absent in the registered types and *opts* and/or *atrs*
+    # is not set to "", defaultATTRS registers the new *type* with its grid/pack
+    # options and attributes. At that *widget* is a command for the new widget
+    # type. For example, to register "toolbutton" widget:
+    #   my defaultATTRS tbt {} {-style Toolbutton -compound top} ttk::button
+    # Options and attributes may contain data (variables and commands)
+    # to be processed by [subst].
+    # Returns:
+    #   - if not set *type*: a full list of options and attributes of all types
+    #   - if set *type* only: a list of options, attributes and *widget*
+    #   - else: a list of updated options, attributes and *widget*
+
+    variable _Defaults
+
+    if {$type eq {}} {return $_Defaults}
+    set optatr "$opts$atrs"
+    if {[catch {set def1 [dict get $_Defaults $type]}]} {
+      if {$optatr eq {}} {
+        set err "[self method]: \"$type\" widget type not registered."
+        puts -nonewline stderr $err
+        return -code error $err
+      }
+      set def1 [list $opts $atrs $widget]
+    }
+    if {$optatr eq {}} {return [subst $def1]}
+    lassign $def1 defopts defatrs widget
+    if {[catch {set defopts [dict replace $defopts {*}$opts]}]} {
+      set defopts [string trim "$defopts $opts"]
+    }
+    if {[catch {set defatrs [dict replace $defatrs {*}$atrs]}]} {
+      set defatrs [string trim "$defatrs $atrs"]
+    }
+    set newval [list $defopts $defatrs $widget]
+    dict set _Defaults $type $newval
+    return $newval
+  }
+
+# ________________________ defaultAttrs _________________________ #
+
+
+  proc defaultAttrs {{type ""} {opts ""} {atrs ""} {widget ""}} {
+    # Sets, gets or registers default options and attributes for widget type.
+    #   type - widget type
+    #   opts - new default grid/pack options
+    #   atrs - new default attributes
+    #   widget - Tcl/Tk command for the new registered widget type
+    # See also: APaveBase::defaultATTRS
+
+    return [defaultATTRS $type $opts $atrs $widget]
+  }
+
+# ________________________ dlgPath _________________________ #
+
+
+  proc dlgPath {}  {
+    # Gets a current dialogue's path.
+    # In fact, it does the same as [my dlgPath], but it can be
+    # called outside of apave dialogue object (useful sometimes).
+    
+    namespace upvar ::radxide dan dan
+    
+    #variable Dlgpath
+    # xxx
+    variable Dlgname
+    
+    variable Indexdlg
+    
+    set Winpath $dan(WIN)
+    
+    # xxx
+    #set wdia $Winpath.dia    
+    set wdia $Winpath.dia$Dlgname$Indexdlg
+    return [set dlg(PATH) [set Dlgpath $wdia]]
+  }
+
+# ________________________ DiaWidgetNameter _________________________ #
+
+
+  proc DiaWidgetName {w} {
+    # Gets a widget name of apave dialogue.
+    #   w - name of widget
+    # The name of widget may be partial. In this case it's prepended
+    # the current dialogue's frame path.
+    # Useful in "input" dialogue when -method option is present
+    # or widget names are uppercased.
+    # See also: MakeWidgetName, input
+
+    if {[string index $w 0] eq {.}} {return $w}
+    return $Dlgpath.fra.$w
+  }
+
+# ________________________ displayTaggedText _________________________ #
+
+  proc displayTaggedText {w contsName {tags ""}} {
+    # Sets the text widget's contents using tags (ornamental details).
+    #   w - text widget's name
+    #   contsName - variable name for contents to be set in the widget
+    #   tags - list of tags to be applied to the text
+    # The lines in *text contents* are divided by \n and can include
+    # *tags* like in a html layout, e.g. <red>RED ARMY</red>.
+    # The *tags* is a list of "name/value" pairs. 1st is a tag's name, 2nd
+    # is a tag's value.
+    # The tag's name is "pure" one (without <>) so e.g.for <b>..</b> the tag
+    # list contains "b".
+    # The tag's value is a string of text attributes (-font etc.).
+    # If the tag's name is FG, FG2, BG or BG2, then it is really a link color.
+
+  }
+
+# ________________________ displayText _________________________ #
+
+
+  proc displayText {w conts {pos 1.0}} {
+    # Sets the text widget's contents.
+    #   w - text widget's name
+    #   conts - contents to be set in the widget
+
+    if {[set state [$w cget -state]] ne {normal}} {
+      $w configure -state normal
+    }
+    $w replace 1.0 end $conts
+    $w edit reset; $w edit modified no
+    if {$state eq {normal}} {
+      ::tk::TextSetCursor $w $pos
+    } else {
+      $w configure -state $state
+    }
+    return
+  }
+
+# __________________________ editDialogField _________________________ #  
+  
+  
+  proc editDialogField {index fldname oldval newval} {
+    
+    namespace upvar ::radxide dan dan
+    
+    variable dlg
+    
+    set newlist {$fldname $oldval $newval}
+    
+    lset dlg(FIELDS) $index $newlist
+    
+  }
+
+# ________________________ ExpandOptions _________________________ #
+
+
+  proc ExpandOptions {options} {
+    # Expands shortened options.
+
+    set options [string map {
+      { -st } { -sticky }
+      { -com } { -command }
+      { -t } { -text }
+      { -w } { -width }
+      { -h } { -height }
+      { -var } { -variable }
+      { -tvar } { -textvariable }
+      { -lvar } { -listvariable }
+      { -ro } { -readonly }
+    } " $options"]
+    return $options
+  }
+
+# ________________________ error _________________________ #
+
+
+	proc error {{fileName ""}} {
+		# Gets the error's message at reading/writing.
+		#   fileName - if set, return a full error messageat opening file
+
+		variable _PU_opts
+		if {$fileName eq ""} {
+		  return $_PU_opts(_ERROR_)
+		}
+		return "Error of access to\n\"$fileName\"\n\n$_PU_opts(_ERROR_)"
+	}
+
+# ________________________ extractOption _________________________ #
+
+
+	proc extractOptions {optsVar args} {
+		# Gets options' values and removes the options from the input list.
+		#  optsVar - variable name for the list of options and values
+		#  args  - list of "option / default value" pairs
+		# Returns a list of options' values, according to args.
+		# See also: parseOptions
+
+		upvar 1 $optsVar opts
+		set retlist [parseOptions $opts {*}$args]
+		foreach {o v} $args {
+		  set opts [removeOptions $opts $o]
+		}
+		return $retlist
+	}
+
+# ________________________ FCfieldAttrs _________________________ #
+
+
+  proc FCfieldAttrs {wnamefull attrs varopt} {
+    # Fills the non-standard attributes of file content widget.
+    #   wnamefull - a widget name
+    #   attrs - a list of all attributes
+    #   varopt - a variable option
+    # The *varopt* refers to a variable part such as tvar, lvar:
+    #  * -inpval option means an initial value of the field
+    #  * -retpos option has p1:p2 format (e.g. 0:10) to cut a substring \
+    from a returned value
+    # Returns *attrs* without -inpval and -retpos options.
+
+    lassign [parseOptions $attrs $varopt {} -retpos {} -inpval {}] \
+      vn rp iv
+    if {[string first {-state disabled} $attrs]<0 && $vn ne {}} {
+      set all {}
+      if {$varopt eq {-lvar}} {
+        lassign [extractOptions attrs -values {} -ALL 0] iv a
+        if {[string is boolean -strict $a] && $a} {set all ALL}
+        lappend Widgetopts "-lbxname$all $wnamefull $vn"
+      }
+      if {$rp ne {}} {
+        if {$all ne {}} {set rp 0:end}
+        lappend Widgetopts "-retpos $wnamefull $vn $rp"
+      }
+    }
+    if {$iv ne {}} { set $vn $iv }
+    return [removeOptions $attrs -retpos -inpval]
+  }
+
+# ________________________ FCfieldValues _________________________ #
+
+
+  proc FCfieldValues {wnamefull attrs} {
+    # Fills the file content widget's values.
+    #   wnamefull - name (path) of fco widget
+    #   attrs - attributes of the widget
+
+  ; proc readFCO {fname} {
+      # Reads a file's content.
+      # Returns a list of (non-empty) lines of the file.
+      if {$fname eq {}} {
+        set retval {{}}
+      } else {
+        set retval {}
+        foreach ln [split [readTextFile $fname {} 1] \n] {
+          # probably, it's bad idea to have braces in the file of contents
+          set ln [string map [list \\ \\\\ \{ \\\{ \} \\\}] $ln]
+          if {$ln ne {}} {lappend retval $ln}
+        }
+      }
+      return $retval
+    }
+
+  ; proc contFCO {fline opts edge args} {
+      # Given a file's line and options,
+      # cuts a substring from the line.
+      lassign [parseOptionsFile 1 $opts {*}$args] opts
+      lassign $opts - - - div1 - div2 - pos - len - RE - ret
+      set ldv1 [string length $div1]
+      set ldv2 [string length $div2]
+      set i1 [expr {[string first $div1 $fline]+$ldv1}]
+      set i2 [expr {[string first $div2 $fline]-1}]
+      set filterfile yes
+      if {$ldv1 && $ldv2} {
+        if {$i1<0 || $i2<0} {return $edge}
+        set retval [string range $fline $i1 $i2]
+      } elseif {$ldv1} {
+        if {$i1<0} {return $edge}
+        set retval [string range $fline $i1 end]
+      } elseif {$ldv2} {
+        if {$i2<0} {return $edge}
+        set retval [string range $fline 0 $i2]
+      } elseif {$pos ne {} && $len ne {}} {
+        set retval [string range $fline $pos $pos+[incr len -1]]
+      } elseif {$pos ne {}} {
+        set retval [string range $fline $pos end]
+      } elseif {$len ne {}} {
+        set retval [string range $fline 0 $len-1]
+      } elseif {$RE ne {}} {
+        set retval [regexp -inline $RE $fline]
+        if {[llength $retval]>1} {
+          foreach r [lrange $retval 1 end] {append retval_tmp $r}
+          set retval $retval_tmp
+        } else {
+          set retval [lindex $retval 0]
+        }
+      } else {
+        set retval $fline
+        set filterfile no
+      }
+      if {$retval eq {} && $filterfile} {return $edge}
+      set retval [string map [list "\}" "\\\}"  "\{" "\\\{"] $retval]
+      return [list $retval $ret]
+    }
+
+    set edge $Edge
+    set ldv1 [string length $edge]
+    set filecontents {}
+    set optionlists {}
+    set tplvalues {}
+    set retpos {}
+    set values [getOption -values {*}$attrs]
+    if {[string first $edge $values]<0} { ;# if 1 file, edge
+      set values "$edge$values$edge"      ;# may be omitted
+    }
+    # get: files' contents, files' options, template line
+    set lopts {-list {} -div1 {} -div2 {} -pos {} -len {} -RE {} -ret 0}
+    while {1} {
+      set i1 [string first $edge $values]
+      set i2 [string first $edge $values $i1+1]
+      if {$i1>=0 && $i2>=0} {
+        incr i1 $ldv1
+        append tplvalues [string range $values 0 $i1-1]
+        set fdata [string range $values $i1 $i2-1]
+        lassign [parseOptionsFile 1 $fdata {*}$lopts] fopts fname
+        lappend filecontents [readFCO $fname]
+        lappend optionlists $fopts
+        set values [string range $values $i2+$ldv1 end]
+      } else {
+        append tplvalues $values
+        break
+      }
+    }
+    # fill the combobox lines, using files' contents and options
+    if {[set leno [llength $optionlists]]} {
+      set newvalues {}
+      set ilin 0
+      lassign $filecontents firstFCO
+      foreach fline $firstFCO { ;# lines of first file for a base
+        set line {}
+        set tplline $tplvalues
+        for {set io 0} {$io<$leno} {incr io} {
+          set opts [lindex $optionlists $io]
+          if {$ilin==0} {  ;# 1st cycle: add items from -list option
+            lassign $opts - list1  ;# -list option goes first
+            if {[llength $list1]} {
+              foreach l1 $list1 {append newvalues "\{$l1\} "}
+              lappend Widgetopts "-list $wnamefull [list $list1]"
+            }
+          }
+          set i1 [string first $edge $tplline]
+          if {$i1>=0} {
+            lassign [contFCO $fline $opts $edge {*}$lopts] retline ret
+            if {$ret ne "0" && $retline ne $edge && \
+            [string first $edge $line]<0} {
+              set p1 [expr {[string length $line]+$i1}]
+              if {$io<($leno-1)} {
+                set p2 [expr {$p1+[string length $retline]-1}]
+              } else {
+                set p2 end
+              }
+              set retpos "-retpos $p1:$p2"
+            }
+            append line [string range $tplline 0 $i1-1] $retline
+            set tplline [string range $tplline $i1+$ldv1 end]
+          } else {
+            break
+          }
+          set fline [lindex [lindex $filecontents $io+1] $ilin]
+        }
+        if {[string first $edge $line]<0} {
+          # put only valid lines into the list of values
+          append newvalues "\{$line$tplline\} "
+        }
+        incr ilin
+      }
+      # replace old 'values' attribute with the new 'values'
+      lassign [parseOptionsFile 2 $attrs -values \
+        [string trimright $newvalues]] attrs
+    }
+    return "$attrs $retpos"
+  }
+
+# ________________________ fillGutter _________________________ #
+
+
+  proc fillGutter {txt {canvas ""} {width ""} {shift ""} fg bg} {
+    # Fills a gutter of text with the text's line numbers.
+    #  txt - path to the text widget
+    #  canvas - canvas of the gutter
+    #  width - width of the gutter, in chars
+    #  shift - addition to the width (to shift from the left side)
+    #  args - additional arguments for tracing
+    # The code is borrowed from open source tedit project.
+    
+    #set shift [expr $shift-1]
+    #set linenum [expr {0}]
+    #set savedcont $txt
+    #set savedcont [namespace current]::gc$txt
+    #if {![winfo exists $txt] || ![winfo ismapped $txt]} {
+    #  unset -nocomplain $savedcont
+    #  return
+    #}
+    
+    namespace upvar ::radxide dan dan
+    
+    $canvas configure -state normal
+    
+    if {$canvas eq {}} {
+      event generate $txt <Configure> ;# repaints the gutter
+      return
+    }
+    #set oper [lindex $args 0 1]
+    #if {![llength $args] || [lindex $args 0 4] eq {-elide} || \
+    #$oper in {configure delete insert see yview}} {
+      set i [$txt index @0,0]
+      set gcont [list]
+      while true {
+        set dline [$txt dlineinfo $i]
+        if {[llength $dline] == 0} break
+        set height [lindex $dline 3]
+        set y [expr {[lindex $dline 1]}]
+        set linenum [format "%${width}d" [lindex [split $i .] 0]]
+        set i [$txt index "$i +1 lines linestart"]
+        #lappend gcont [list $y $linenum\n]
+        lappend gcont [list $y [expr {$linenum}]\n]
+      }
+      # update the gutter at changing its contents/config
+      #if {[::apave::cs_Active]} {
+      #  lassign [csGet] - - - bg - - - - fg
+      #  setProperty _GUTTER_FGBG [list $fg $bg]
+      #} else {
+      #  lassign [getProperty _GUTTER_FGBG] fg bg
+      #}
+      set cwidth [expr {$shift + \
+        [font measure monospace -displayof $txt [string repeat 0 $width]]}]
+      #set newbg [expr {$bg ne [$canvas cget -background]}]
+      set newwidth [expr {$cwidth ne [$canvas cget -width]}]
+      #if {![llength $args] || $newbg || $newwidth || ![info exists $savedcont] || \
+      #$gcont ne [set $savedcont]} {
+        #if {$newbg} {$canvas config -background $newbg}
+        #if {$newwidth} {$canvas config -width $cwidth}
+        $canvas delete 1.0 end
+        set y [expr {0}]
+	      foreach g $gcont {
+	        lassign $g y linenum
+	        #$canvas insert [expr {$y-1}].0 $linenum
+	        $canvas insert [expr {$y}].0 $linenum
+	    #    #$canvas create text 2 $y -anchor nw -text $linenum -font apaveFontMono -fill $fg
+	      }
+        #if {[expr {$y}] ne 1} {
+        # $canvas insert [expr {$y}].0 [expr {$linenum+1}]
+        # lassign $g y linenum
+        # $canvas insert $y $linenum
+        #}  
+      #}
+   # }
+    #tk_messageBox -title $dan(TITLE) -icon error -message linenum=$linenum
+    $canvas configure -state disabled
+  }
+
+
+# ________________________ FieldName _________________________ #
+
+
+  proc FieldName {name} {
+    # Gets a field name.
+
+    return fraM.fra$name.$name
+  }
+
+# ________________________ findInText ___________________________ #
+
+
+  proc findInText {{donext 0} {txt ""} {varFind ""} {dobell yes}} {
+    # Finds a string in text widget.
+    #   donext - "1" means 'from a current position'
+    #   txt - path to the text widget
+    #   varFind - variable
+    #   dobell - if yes, bells
+    # Returns yes, if found (or nothing to find), otherwise returns "no";
+    # also, if there was a real search, the search string is added.
+
+    namespace upvar ::radxide dan dan
+
+    variable Foundstr
+
+    if {$txt eq {}} {
+      set txt $dan(TEXT)
+      set sel $Foundstr
+    } elseif {$donext && [set sel [get_HighlightedString]] ne {}} {
+      # find a string got with alt+left/right
+    } elseif {$varFind eq {}} {
+      set sel $Foundstr
+    } else {
+      set sel [set $varFind]
+    }
+    if {$donext} {
+      set pos [$txt index insert]
+      if {{sel} in [$txt tag names $pos]} {
+        set pos [$txt index "$pos + 1 chars"]
+      }
+      set pos [$txt search -- $sel $pos end]
+    } else {
+      set pos {}
+      set_HighlightedString {}
+    }
+    if {![string length "$pos"]} {
+      set pos [$txt search -- $sel 1.0 end]
+    }
+    if {[string length "$pos"]} {
+      ::tk::TextSetCursor $txt $pos
+      $txt tag add sel $pos [$txt index "$pos + [string length $sel] chars"]
+      #focus $txt
+      set res yes
+    } else {
+      if {$dobell} bell
+      set res no
+    }
+    return [list $res $sel]
+  }
+
+# ________________________ findTextOK _________________________ #
+
+
+  proc findTextOK {} {
+  
+    namespace upvar ::radxide dan dan project project
+
+    variable dlg
+    variable data
+    variable Foundstr
+    
+    set wt $dan(TEXT) 
+    
+    #if {$inv>-1} {set data(lastinvoke) $inv}    
+    
+    #set t $Dlgpath.fra.fraM.fraent.ent
+    set t [dlgPath].fra.[FieldName [lindex [getDialogField 0] 0]]
+    #tk_messageBox -title $dan(TITLE) -icon info -message textbox=$t
+    set varname [lindex [getDialogField end] 0]
+    #tk_messageBox -title $dan(TITLE) -icon info -message varname=$varname
+    set oldsearchtext [lindex [getDialogField end] 1]
+    #tk_messageBox -title $dan(TITLE) -icon info -message oldsearchtext=$oldsearchtext
+    set newsearchtext [string trim [$t get]]
+    #tk_messageBox -title $dan(TITLE) -icon info -message newsearchtext=$newsearchtext
+  
+    set Foundstr $newsearchtext
+   
+    findInText 1 $wt
+  
+    #ShowResults1 [FindAll $wt]
+  
+    return 1
+  }
+
+
+# ________________________ findTextCancel _________________________ #
+
+
+  proc findTextCancel {} {
+  
+    #catch {[destroy .danwin.diaRenameFile1]}    
+    catch {[destroy [dlgPath]]}
+        
+    return 0
+  }
+
+# ________________________ GetAttrs _________________________ #
+
+
+  proc GetAttrs {options {nam3 ""} {disabled 0} } {
+    # Expands attributes' values.
+    #   options - list of attributes and values
+    #   nam3 - first three letters (type) of widget's name
+    #   disabled - flag of "disabled" state
+    # Returns expanded attributes.
+
+    set opts [list]
+    foreach {opt val} [list {*}$options] {
+      switch -exact -- $opt {
+        -t - -text {
+          ;# these options need translating \\n to \n
+          # catch {set val [subst -nocommands -novariables $val]}
+          set val [string map [list \\n \n \\t \t] $val]
+          set opt -text
+        }
+        -st {set opt -sticky}
+        -com {set opt -command}
+        -w {set opt -width}
+        -h {set opt -height}
+        -var {set opt -variable}
+        -tvar {set opt -textvariable}
+        -lvar {set opt -listvariable}
+        -ro {set opt -readonly}
+      }
+      lappend opts $opt \{$val\}
+    }
+    if {$disabled} {
+      append opts [NonTtkStyle $nam3 1]
+    }
+    return $opts
+  }
+
+# ________________________ get_HighlightedString _________________________ #
+
+
+  proc get_HighlightedString {} {
+    # Returns a string got from highlighting by Alt+left/right/q/w.
+
+    variable HLstring
+
+    if {[info exists HLstring]} {
+      return $HLstring
+    }
+    return {}
+  }
+
+# ________________________ GetIntOptions _________________________ #
+
+
+  proc GetIntOptions {w options row rowspan col colspan} {
+    # Gets specific integer options. Then expands other options.
+    #   w - widget's name
+    #   options - grid options
+    #   row, rowspan - row and its span of thw widget
+    #   col, colspan - column and its span of thw widget
+    # The options are set in grid options as "-rw <int>", "-cw <int>" etc.
+    # Returns the resulting grid options.
+
+    set opts {}
+    foreach {opt val} [list {*}$options] {
+      switch -exact -- $opt {
+        -rw  {SpanConfig $w row $row $rowspan -weight $val}
+        -cw  {SpanConfig $w column $col $colspan -weight $val}
+        -rsz {SpanConfig $w row $row $rowspan -minsize $val}
+        -csz {SpanConfig $w column $col $colspan -minsize $val}
+        -ro  {SpanConfig $w column $col $colspan -readonly $val}
+        default {append opts " $opt $val"}
+      }
+    }
+    # Get other grid options
+    return [ExpandOptions $opts]
+  }
+
+# ________________________ GetLinkLab _________________________ #
+
+
+  proc GetLinkLab {m} {
+    # Gets a link for label.
+    #   m - label with possible link (between <link> and </link>)
+    # Returns: list of "pure" message and link for label.
+
+    if {[set i1 [string first "<link>" $m]]<0} {
+      return [list $m]
+    }
+    set i2 [string first "</link>" $m]
+    set link [string range $m $i1+6 $i2-1]
+    set m [string range $m 0 $i1-1][string range $m $i2+7 end]
+    return [list $m [list -link $link]]
+  }
+
+# ________________________ getOption _________________________ #
+
+
+	proc getOption {optname args} {
+		# Extracts one option from an option list.
+		#   optname - option name
+		#   args - option list
+		# Returns an option value or "".
+		# Example:
+		#     set options [list -name some -value "any value" -tip "some tip"]
+		#     set optvalue [::apave::getOption -tip {*}$options]
+
+		set optvalue [lindex [parseOptions $args $optname ""] 0]
+		return $optvalue
+	}
+
+# ________________________ GetOutputValues _________________________ #
+
+
+  proc GetOutputValues {} {
+    # Makes output values for some widgets (lbx, fco).
+    # Some i/o widgets need a special method to get their returned values.
+
+    foreach aop $Widgetopts {
+      lassign $aop optnam vn v1 v2
+      switch -glob -- $optnam {
+        -lbxname* {
+          # To get a listbox's value, its methods are used.
+          # The widget may not exist when an apave object is used for
+          # several dialogs which is a bad style (very very bad).
+          if {[winfo exists $vn]} {
+            lassign [$vn curselection] s1
+            if {$s1 eq {}} {set s1 0}
+            set w [string range $vn [string last . $vn]+1 end]
+            if {[catch {set v0 [$vn get $s1]}]} {set v0 {}}
+            if {$optnam eq {-lbxnameALL}} {
+              # when -ALL option is set to 1, listbox returns
+              # a list of 3 items - sel index, sel contents and all contents
+              set $v1 [list $s1 $v0 [set $v1]]
+            } else {
+              set $v1 $v0
+            }
+          }
+        }
+        -retpos { ;# a range to cut from -tvar/-lvar variable
+          lassign [split $v2 :] p1 p2
+          set val1 [set $v1]
+          # there may be -list option for this widget
+          # then if the value is from the list, it's fully returned
+          foreach aop2 $Widgetopts {
+            lassign $aop2 optnam2 vn2 lst2
+            if {$optnam2 eq {-list} && $vn eq $vn2} {
+              foreach val2 $lst2 {
+                if {$val1 eq $val2} {
+                  set p1 0
+                  set p2 end
+                  break
+                }
+              }
+              break
+            }
+          }
+          set $v1 [string range $val1 $p1 $p2]
+        }
+      }
+    }
+    return
+  }
+
+# __________________________ getDialogField _________________________ #  
+  
+  
+  proc getDialogField {index} {
+
+    variable dlg
+
+    set ret [lindex $dlg(FIELDS) $index] 
+
+    return $ret
+    
+  }
+
+#_______________________ getProperty _______________________#
+
+
+	proc getProperty {name {defvalue ""}} {
+		# Gets a property's value as "application-wide".
+		#   name - name of property
+		#   defvalue - default value
+		# If the property had been set, the method returns its value.
+		# Otherwise, the method returns the default value (`$defvalue`).
+
+		variable _AP_Properties
+		if {[info exists _AP_Properties($name)]} {
+		  return $_AP_Properties($name)
+		}
+		return $defvalue
+	}
+
+# ________________________ getShowOption _________________________ #
+
+
+  proc getShowOption {name {defval ""}} {
+    # Gets a default show option, used in showModal.
+    #   name - name of option
+    #   defval - default value
+    # See also: showModal
+
+    getProperty [ShowOption $name] $defval
+  }
+
+# ________________________ GetVarsValues _________________________ #
+
+
+  proc GetVarsValues {lwidgets} {
+    # Gets values of entries passed (or set) in -tvar.
+    #   lwidgets - list of widget items
+
+    set res [set vars [list]]
+    foreach wl $lwidgets {
+      set ownname [ownWName [lindex $wl 0]]
+      set vv [varName $ownname]
+      set attrs [lindex $wl 6]
+      if {[string match "ra*" $ownname]} {
+        # only for widgets with a common variable (e.g. radiobuttons):
+        foreach t {-var -tvar} {
+          if {[set v [getOption $t {*}$attrs]] ne {}} {
+            array set a $attrs
+            set vv $v
+          }
+        }
+      }
+      if {[info exist $vv] && [lsearch $vars $vv]==-1} {
+        lappend res [set $vv]
+        lappend vars $vv
+      }
+    }
+    return $res
+  }
+
+# ________________________ iconImage _________________________ #
+
+  proc iconA {icon {iconset small} {cmpd left}} {
+    # Gets icon attributes for buttons, menus etc.
+    #   icon - name of icon
+    #   iconset - one of small/middle/large
+    #   cmpd - value of -compound option
+    # The *iconset* is "small" for menus (recommended and default).
+
+    return "-image [iconImage $icon $iconset] -compound $cmpd"
+  }
+
+# ________________________ iconifyOption _________________________ #
+
+
+	proc iconifyOption {args} {
+		# Gets/sets "-iconify" option.
+		#   args - if contains no arguments, gets "-iconify" option; otherwise sets it
+		# Option values mean:
+		#   none - do nothing: no withdraw/deiconify
+		#   Linux - do withdraw/deiconify for Linux
+		#   Windows - do withdraw/deiconify for Windows
+		#   default - do withdraw/deiconify depending on the platform
+		# See also: withdraw, deiconify
+
+		if {[llength $args]} {
+		  set iconify [setShowOption -iconify $args]
+		} else {
+		  set iconify [getShowOption -iconify]
+		}
+		return $iconify
+	}
+
+# ________________________ iconImage _________________________ #
+
+
+  proc iconImage {{icon ""} {iconset "small"} {doit no}} {
+    # Gets a defined icon's image or list of icons.
+    # If *icon* equals to "-init", initializes apave's icon set.
+    #   icon - icon's name
+    #   iconset - one of small/middle/large
+    #   doit - force the initialization
+    # Returns the icon's image or, if *icon* is blank, a list of icons
+    # available in *apave*.
+
+    variable _AP_IMG
+    variable _AP_ICO
+    
+    return folder
+#    if {$icon eq {}} {return $_AP_ICO}
+#  ; proc imagename {icon} {   # Get a defined icon's image name
+#      return _AP_IMG(img$icon)
+#    }
+#    variable apaveDir
+#    if {![array size _AP_IMG] || $doit} {
+#      # Make images of icons
+#      source [file join $apaveDir apaveimg.tcl]
+#      if {$iconset ne "small"} {
+#       foreach ic $_AP_ICO {  ;# small icons best fit for menus
+#          set _AP_IMG($ic-small) [set _AP_IMG($ic)]
+#        }
+#        if {$iconset eq "middle"} {
+#          source [file join $apaveDir apaveimg2.tcl]
+#        } else {
+#          source [file join $apaveDir apaveimg2.tcl] ;# TODO
+#        }
+#      }
+#      foreach ic $_AP_ICO {
+#        if {[catch {image create photo [imagename $ic] -data [set _AP_IMG($ic)]}]} {
+#          # some png issues on old Tk
+#          image create photo [imagename $ic] -data [set _AP_IMG(none)]
+#        } elseif {$iconset ne "small"} {
+#          image create photo [imagename $ic-small] -data [set _AP_IMG($ic-small)]
+#        }
+#      }
+#    }
+#    if {$icon eq "-init"} {return $_AP_ICO} ;# just to get to icons
+#    if {$icon ni $_AP_ICO} {set icon [lindex $_AP_ICO 0]}
+#    if {$iconset eq "small" && "_AP_IMG(img$icon-small)" in [image names]} {
+#      set icon $icon-small
+#    }
+#    return [imagename $icon]
+  }
+
+# ________________________ InfoFind _________________________ #
+
+
+	proc InfoFind {w modal} {
+		# Searches data of a window in a list of registered windows.
+		#   w - root window's path
+		#   modal - yes, if the window is modal
+		# Returns: the window's path or "" if not found.
+		# See also: InfoWindow
+
+		variable _PU_opts
+		foreach winfo [lrange $_PU_opts(_MODALWIN_) 1 end] {  ;# skip 1st window
+		  incr i
+		  lassign $winfo w1 var1 modal1
+		  if {[winfo exists $w1]} {
+		    if {$w eq $w1 && ($modal && $modal1 || !$modal && !$modal1)} {
+		      return $w1
+		    }
+		  } else {
+		    catch {set _PU_opts(_MODALWIN_) [lreplace $_PU_opts(_MODALWIN_) $i $i]}
+		  }
+		}
+		return {}
+	}
+
+# ________________________ InitFindInText _________________________ #
+
+
+  proc InitFindInText { {ctrlf 0} {txt {}} } {
+    # Initializes the search in the text.
+    #   ctrlf - "1" means that the method is called by Ctrl+F
+    #   txt - path to the text widget
+
+    namespace upvar ::radxide dan dan
+
+    variable Foundstr
+
+    if {$txt eq {}} {set txt $dan(TEXT)}
+    #if {$ctrlf} {  ;# Ctrl+F moves cursor 1 char ahead
+    #  ::tk::TextSetCursor $txt [$txt index "insert -1 char"]
+    #}
+    if {[set seltxt [selectedWordText $txt]] ne {}} {
+      set Foundstr $seltxt
+    }
+    return $Foundstr
+  }
+
+# ________________________ initInput _________________________ #
+
+
+  proc initInput {} {
+    # Initializes input and clears variables made in previous session.
+
+    variable _savedvv
+
+    foreach {vn vv} $_savedvv {
+      catch {unset $vn}
+    }
+    set _savedvv [list]
+    set Widgetopts [list]
+
+    return
+  }
+
+	proc InfoWindow {{val ""} {w .} {modal no} {var ""} {regist no}} {
+		# Registers/unregisters windows. Also sets/gets 'count of open modal windows'.
+		#   val - current number of open modal windows
+		#   w - root window's path
+		#   modal - yes, if the window is modal
+		#   var - variable's name for tkwait
+		#   regist - yes or no for registering/unregistering
+
+		variable _PU_opts
+		if {$modal || $regist} {
+		  set info [list $w $var $modal]
+		  set i [lsearch -exact $_PU_opts(_MODALWIN_) $info]
+		  catch {set _PU_opts(_MODALWIN_) [lreplace $_PU_opts(_MODALWIN_) $i $i]}
+		  if {$regist} {
+		    lappend _PU_opts(_MODALWIN_) $info
+		  }
+		  set res [IntStatus . MODALS $val]
+		} else {
+		  set res [IntStatus . MODALS]
+		}
+		return $res
+	}
+
+# ________________________ input _________________________ #
+
+
+  proc input {dlgname icon ttl iopts args} {
+    # Makes and runs an input dialog.
+    #  dlgname - dialog name
+    #  icon - icon (omitted if equals to "")
+    #  ttl - title of window
+    #  iopts - list of widgets and their attributes
+    #  args - list of dialog's attributes
+    # The `iopts` contains lists of three items:
+    #   name - name of widgets
+    #   prompt - prompt for entering data
+    #   valopts - value options
+    # The `valopts` is a list specific for a widget's type, however
+    # a first item of `valopts` is always an initial input value.
+
+    namespace upvar ::radxide dan dan
+
+    variable Indexdlg
+    variable _savedvv 
+    variable Dlgpath
+    variable Dlgname
+    variable dlg
+
+    #tk_messageBox -title $dan(TITLE) -icon error -message "proc Input"
+
+    danInitDialogs
+
+    set Winpath $dan(WIN)
+    set Dlgname [set dlg(NAME) $dlgname]
+    set wdia $Winpath.dia$Dlgname[incr Indexdlg]
+    set dlg(PATH) [set Dlgpath $wdia]
+    if {$iopts ne {}} {
+      initInput  ;# clear away all internal vars
+    }
+    set pady "-pady 2"
+    if {[set focusopt [getOption -focus {*}$args]] ne {}} {
+     set focusopt "-focus $focusopt"
+    }
+    lappend inopts [list fraM + T 1 98 "-st nsew $pady -rw 1"]
+    set _savedvv [list]
+    set frameprev {}
+    foreach {name prompt valopts} $iopts {
+      if {$name eq {}} continue
+      lassign $prompt prompt gopts attrs
+      lassign [extractOptions attrs -method {} -toprev {}] ismeth toprev
+      if {[string toupper $name 0] eq $name} {
+        set ismeth yes  ;# overcomes the above setting
+        set name [string tolower $name 0]
+      }
+      set ismeth [string is true -strict $ismeth]
+      set gopts "$pady $gopts"
+      set typ [string tolower [string range $name 0 1]]
+      if {$typ eq "v_" || $typ eq "se"} {
+        lappend inopts [list fraM.$name - - - - "pack -fill x $gopts"]
+        continue
+      }
+      set tvar "-tvar"
+      switch -exact -- $typ {
+        ch { set tvar "-var" }
+        sp { set gopts "$gopts -expand 0 -side left"}
+      }
+      set framename fraM.fra$name
+      if {$typ in {lb te tb}} {  ;# the widgets sized vertically
+        lappend inopts [list $framename - - - - "pack -expand 1 -fill both"]
+      } else {
+        lappend inopts [list $framename - - - - "pack -fill x"]
+      }
+      set vv [::radxide::win::varName $name]
+      #tk_messageBox -title $dan(TITLE) -icon info -message vv=$vv
+      set ff [FieldName $name]
+      set Name [string toupper $name 0]
+      if {$ismeth && $typ ni {ra}} {
+        # -method option forces making "WidgetName" method from "widgetName"
+        MakeWidgetName $ff $Name -
+      }
+      if {$typ ne {la} && $toprev eq {}} {
+        set takfoc [parseOptions $attrs -takefocus 1]
+        if {$focusopt eq {} && $takfoc} {
+          if {$typ in {fi di cl fo da}} {
+            set _ en*$name  ;# 'entry-like mega-widgets'
+          } elseif {$typ eq "ft"} {
+            set _ te*$name  ;# ftx - 'text-like mega-widget'
+          } else {
+            set _ $name
+          }
+          set focusopt "-focus $_"
+        }
+        if {$typ in {lb tb te}} {set anc nw} {set anc w}
+        lappend inopts [list fraM.fra$name.labB$name - - - - \
+          "pack -side left -anchor $anc -padx 3" \
+          "-t \"$prompt\" -font \
+          \"-family {[basicTextFont]} -size [basicFontSize]\""]
+      }
+      # for most widgets:
+      #   1st item of 'valopts' list is the current value
+      #   2nd and the rest of 'valopts' are a list of values
+      if {$typ ni {fc te la}} {
+        # curr.value can be set with a variable, so 'subst' is applied
+        set vsel [lindex $valopts 0]
+        catch {set vsel [subst -nocommands -nobackslashes $vsel]}
+        set vlist [lrange $valopts 1 end]
+      }
+      if {[set msgLab [getOption -msgLab {*}$attrs]] ne {}} {
+        set attrs [removeOptions $attrs -msgLab]
+      }
+      # define a current widget's info
+      switch -exact -- $typ {
+        lb - tb {
+          set $vv $vlist
+          lappend attrs -lvar $vv
+          if {$vsel ni {{} -}} {
+            lappend attrs -lbxsel "$UFF$vsel$UFF"
+          }
+          lappend inopts [list $ff - - - - \
+            "pack -side left -expand 1 -fill both $gopts" $attrs]
+          lappend inopts [list fraM.fra$name.sbv$name $ff L - - "pack -fill y"]
+        }
+        cb {
+          if {![info exist $vv]} {catch {set $vv $vsel}}
+          lappend attrs -tvar $vv -values $vlist
+          if {$vsel ni {{} -}} {
+            lappend attrs -cbxsel $UFF$vsel$UFF
+          }
+          lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill x $gopts" $attrs]
+        }
+        fc {
+          if {![info exist $vv]} {catch {set $vv {}}}
+          lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill x $gopts" "-tvar $vv -values \{$valopts\} $attrs"]
+        }
+        op {
+          set $vv $vsel
+          lappend inopts [list $ff - - - - "pack -fill x $gopts" "$vv $vlist"]
+        }
+        ra {
+          if {![info exist $vv]} {catch {set $vv $vsel}}
+          set padx 0
+          foreach vo $vlist {
+            set name $name
+            set FF $ff[incr nnn]
+            lappend inopts [list $FF - - - - "pack -side left $gopts -padx $padx" "-var $vv -value \"$vo\" -t \"$vo\" $attrs"]
+            if {$ismeth} {
+              MakeWidgetName $FF $Name$nnn -
+            }
+            set padx [expr {$padx ? 0 : 9}]
+          }
+        }
+        te {
+          if {![info exist $vv]} {
+            set valopts [string map [list \\n \n \\t \t] $valopts]
+            set $vv [string map [list \\\\ \\ \\\} \} \\\{ \{] $valopts]
+          }
+          # xxx
+          #tk_messageBox -title $dan(TITLE) -icon error -message $vv          
+          if {[dict exist $attrs -state] && [dict get $attrs -state] eq "disabled"} \
+          {
+            # disabled text widget cannot be filled with a text, so we should
+            # compensate this through a home-made attribute (-disabledtext)
+            set disattr "-disabledtext \{[set $vv]\}"
+          } elseif {[dict exist $attrs -readonly] && [dict get $attrs -readonly] || [dict exist $attrs -ro] && [dict get $attrs -ro]} {
+            set disattr "-rotext \{[set $vv]\}"
+            set attrs [removeOptions $attrs -readonly -ro]
+          } else {
+            set disattr {}
+          }
+          lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill both $gopts" "$attrs $disattr"]
+          lappend inopts [list fraM.fra$name.sbv$name $ff L - - "pack -fill y"]
+        }
+        la {
+          if {$prompt ne {}} { set prompt "-t \"$prompt\" " } ;# prompt as -text
+          lappend inopts [list $ff - - - - "pack -anchor w $gopts" "$prompt$attrs"]
+          continue
+        }
+        bu - bt - ch {
+          set prompt {}
+          if {$toprev eq {}} {
+            lappend inopts [list $ff - - - - \
+              "pack -side left -expand 1 -fill both $gopts" "$tvar $vv $attrs"]
+          } else {
+            lappend inopts [list $frameprev.$name - - - - \
+              "pack -side left $gopts" "$tvar $vv $attrs"]
+          }
+          if {$vv ne {}} {
+            if {![info exist $vv]} {
+              catch {
+                if {$vsel eq {}} {set vsel 0}
+                set $vv $vsel
+              }
+            }
+          }
+        }
+        default {
+          if {$vlist ne {}} {lappend attrs -values $vlist}
+          lappend inopts [list $ff - - - - \
+            "pack -side left -expand 1 -fill x $gopts" "$tvar $vv $attrs"]
+          if {$vv ne {}} {
+            if {![info exist $vv]} {catch {set $vv $vsel}}
+          }
+        }
+      }
+      if {$msgLab ne {}} {
+        lassign $msgLab lab msg attlab
+        set lab [parentWName [lindex $inopts end 0]].$lab
+        if {$msg ne {}} {set msg "-t {$msg}"}
+        append msg " $attlab"
+        lappend inopts [list $lab - - - - "pack -side left -expand 1 -fill x" $msg]
+      }
+      if {![info exist $vv]} {set $vv {}}
+      # xxx
+      if {$typ eq "en"} {
+        #tk_messageBox -title $dan(TITLE) -icon error -message setvv=[set $vv]
+        addDialogField $name [set $vv] ""
+      }        
+      lappend _savedvv $vv [set $vv]
+      set frameprev $framename
+    }
+    lassign [parseOptions $args -titleHELP {} -buttons {} -comOK 1 \
+      -titleOK OK -titleCANCEL Cancel -centerme {}] \
+      titleHELP buttons comOK titleOK titleCANCEL centerme
+    if {$titleHELP eq {}} {
+      set butHelp {}
+    } else {
+      lassign $titleHELP title command
+      set butHelp [list butHELP $title $command]
+    }
+    if {$titleCANCEL eq {}} {
+      set butCancel {}
+    } else {
+      set butCancel "butCANCEL $titleCANCEL destroy"
+    }
+    if {$centerme eq {}} {
+      set centerme {-centerme 1}
+    } else {
+      set centerme "-centerme $centerme"
+    }
+    set args [removeOptions $args \
+      -titleHELP -buttons -comOK -titleOK -titleCANCEL -centerme -modal]
+    # xxx
+    #set buttons [string map {"butOK OK 1" "" "butCANCEL Cancel destroy" ""} $buttons]
+
+    #tk_messageBox -title $dan(TITLE) -icon info -message new_buttons=$buttons
+    lappend args {*}$focusopt
+    #lassign [PrepArgs {*}$args] args
+    if {[catch { \
+        lassign [PrepArgs {*}$args] args
+        set res [Query $dlgname $icon $ttl {} \
+        "$butHelp $buttons butOK $titleOK $comOK $butCancel" \
+        butOK $inopts $args {} {*}$centerme -input yes]} e]} {
+        
+      catch {destroy $Dlgpath]}  ;# Query's window
+      # ::apave::obj ok err "ERROR" "\n$e\n" \
+      #   -t 1 -head "\nAPave returned an error: \n" -hfg red -weight bold
+      
+      #tk_messageBox -title $dan(TITLE) -icon info -message "::win returned an error:$e"
+      
+			set res 0
+			set msg "\nERROR in win:"
+			puts \n$msg\n\n$e$::errorInfo\n
+			#set msg "$msg\n\n$e\n\nPlease, inform authors.\nDetails are in stdout."
+			#tk_messageBox -title $dan(TITLE) -icon error -message $msg
+			#exit 2
+      
+      return $res
+    }
+    if {![lindex $res 0]} {  ;# restore old values if OK not chosen
+      foreach {vn vv} $_savedvv {
+        # tk_optionCascade (destroyed now) was tracing its variable => catch
+        catch {set $vn $vv}
+      }
+    }
+    
+    return $res
+  }
+
+# ________________________ IntStatus _________________________ #
+
+
+  proc IntStatus {w {name "status"} {val ""}} {
+    # Sets/gets a status of window. The status is an integer assigned to a name.
+    #   w - window's path
+    #   name - name of status
+    #   val - if blank, to get a value of status; otherwise a value to set
+    # Default value of status is 0.
+    # Returns an old value of status.
+    # See also: WindowStatus
+
+    set old [WindowStatus $w $name {} 0]
+    if {$val ne {}} {WindowStatus $w $name $val 1}
+    return $old
+  }
+
+# ________________________ LbxSelect _________________________ #
+
+
+	proc LbxSelect {w idx} {
+		# Selects a listbox item.
+		#   w - listbox's path
+		#   idx - item index
+
+		$w activate $idx
+		$w see $idx
+		if {[$w cget -selectmode] in {single browse}} {
+		  $w selection clear 0 end
+		  $w selection set $idx
+		  event generate $w <<ListboxSelect>>
+		}
+	}
+
+# ________________________ ListboxesAttrs _________________________ #
+
+
+  proc ListboxesAttrs {w attrs} {
+    # Appends selection attributes to listboxes.
+    # Details:
+    #   1. https://wiki.tcl-lang.org/page/listbox+selection
+    #   2. https://stackoverflow.com, the question:
+    #        the-tablelist-curselection-goes-at-calling-the-directory-dialog
+
+    if {{-exportselection} ni $attrs} {
+      append attrs " -ListboxSel $w -selectmode extended -exportselection 0"
+    }
+    return $attrs
+  }
+
+# ________________________ LowercaseWidgetName _________________________ #
+
+
+  proc LowercaseWidgetName {name} {
+    # Makes the widget name lowercased.
+    #   name - widget's name
+    # The widgets of widget list can have uppercased names which
+    # means that the appropriate methods will be created to access
+    # their full pathes with a command `my Name`.
+    # This method gets a "normal" name of widget accepted by Tk.
+    # See also: MakeWidgetName
+
+    set root [ownWName $name]
+    return [list [string range $name 0 [string last . $name]][string tolower $root 0 0] $root]
+  }
+
+# ________________________ NonTtkStyle _________________________ #
+
+
+  proc NonTtkStyle {typ {dsbl 0}} {
+    # Gets a style for non-ttk widgets.
+    #   typ - the type of widget (in apave terms, i.e. but, buT etc.)
+    #   dsbl - a mode to get style of disabled (1) or readonly (2) widgets
+    # See also: widgetType
+    # Method to be redefined in descendants/mixins.
+    return
+  }
+
+# ________________________ NormalizeName _________________________ #
+
+
+  proc NormalizeName {refname refi reflwidgets} {
+    # Gets the real name of widget from *.name*.
+    #   refname - variable name for widget name
+    #   refi - variable name for index in widget list
+    #   reflwidgets - variable name for widget list
+    # The *.name* means "child of some previous" and should be normalized.
+    # Example:
+    #   If parent: fra.fra .....
+    #      child: .but
+    #   => normalized: fra.fra.but
+
+    upvar $refname name $refi i $reflwidgets lwidgets
+    set wname $name
+    if {[string index $name 0] eq {.}} {
+      for {set i2 [expr {$i-1}]} {$i2 >=0} {incr i2 -1} {
+        lassign [lindex $lwidgets $i2] name2
+        if {[string index $name2 0] ne {.}} {
+          set name2 [lindex [LowercaseWidgetName $name2] 0]
+          set wname "$name2$name"
+          set name [lindex [LowercaseWidgetName $name] 0]
+          set name "$name2$name"
+          break
+        }
+      }
+    }
+    return [list $name $wname]
+  }
+
+# ________________________ makeMainWindow _________________________ #
+  
+  
+  proc makeMainWindow {win ttl bg fg} {
+
+    namespace upvar ::radxide dan dan
+
+    set w [set wtop [string trimright $win .]]
+    set withfr [expr {[set pp [string last . $w]]>0 && \
+      [string match *.fra $w]}]
+		if {$withfr} {
+		  set wtop [string range $w 0 $pp-1]
+		}
+		
+    # menu
+		set m [::radxide::menu::menuScaf]
+	  
+		toplevel $wtop -menu $m
+
+		if {$withfr} {
+		
+		  # main frame
+		  pack [frame $w -background $bg ] -expand 1 -fill both
+		  
+		  # panedwindow
+		  pack [set pan [ttk::panedwindow $w.pan -orient horizontal]] -side top -fill both -expand 1
+		  
+		  # tree pane (panL)
+		  pack [set w1 [frame $pan.fra1 -background $bg ]] -side left -fill both ;#-expand 1 -fill both
+		  set panL [$pan add $pan.fra1]
+		  pack [set tree [ttk::treeview $w1.tree -selectmode extended]] -side left -fill both -expand 1
+		  set dan(TREEVIEW) $w1.tree
+		  $tree heading #0 -text "  Project" -anchor "w"
+		  
+		  # main pane (panR)
+		  pack [set w2 [frame $pan.fra2 -background $bg ]] -side left -fill both -expand 1 ;#-fill both
+		  set panR [$pan add $pan.fra2]
+		  pack [text $w2.gutText -background "lightgray" -foreground "#222223" -font "Monospace 10" -width 5] -side left -fill both -expand 1 -anchor nw
+ 		  # text pane
+		  #pack [text $w2.text -background "#FFFFFF" -foreground "#222223" -font "monospace 10" -bd 0 -padx 13 -spacing1 0 -spacing2 0 -spacing3 0 -exportselection yes -expand 1 -fill both;#-gutterwidth 5 -guttershift 3
+		  pack [text $w2.text -background "#FFFFFF" -foreground "#222223" -font "monospace 10" -bd 0 -padx 13 -spacing1 0 -spacing2 0 -spacing3 0 -exportselection yes -width 155] -side left -expand 1 -fill both -anchor nw;#-gutterwidth 5 -guttershift 3
+		  set dan(TEXT) $w2.text
+		  $dan(TEXT) configure -state disabled
+		  
+		  # code library
+		  pack [set w3 [frame $pan.fra3 -background $bg]] -side left -fill y -expand 1;
+		  set panRR [$pan add $pan.fra3]
+		  ::radxide::eglib::create $w3
+		  
+		  # update gutter, key bindings     
+      bind .danwin.fra.pan.fra2.text "<KeyRelease>" {::radxide::win::fillGutter .danwin.fra.pan.fra2.text .danwin.fra.pan.fra2.gutText 5 1 "#FFFFFF" "#222223"}
+      bind $tree "<ButtonPress>" {after idle {::radxide::tree::buttonPress %b %x %y %X %Y}}
+      bind $tree "<ButtonRelease>" {after idle {::radxide::tree::buttonRelease %b %s %x %y %X %Y}}      
+      
+   	}
+		#wm title $wtop ttl  
+ 	  
+ 	  # window shortcut bindings
+    set canvas $w2.gutText 	  
+ 	  ::radxide::menu::defWinShortcuts $dan(TEXT) $canvas  
+ 	  ::radxide::menu::defWinShortcuts $dan(TREEVIEW) $canvas  
+
+  }
+
+# ________________________ MakeWidgetName _________________________ #
+
+
+  proc MakeWidgetName {w name {an {}}} {
+    # Makes an exported method named after root widget, if it's uppercased.
+    #   w - name of root widget
+    #   name - name of widget
+    #   an - additional prefix for name (if "-", $w is full/partial name)
+    # The created method used for easy access to the widget's path.
+    # Example:
+    #   fra1.fra2.fra3.Entry1
+    #   => method Entry1 {} {...}
+    #   ...
+    #   my Entry1  ;# instead of .win.fra1.fra2.fra3.Entry1
+
+    if {$an eq {-}} {
+      set wnamefull "\[DiaWidgetName $w\]"
+    } else {
+      set wnamefull [WidgetNameFull $w $name $an]
+      lassign [LowercaseWidgetName $wnamefull] wnamefull
+    }
+    set method [ownWName $name]
+    set root1 [string index $method 0]
+    #if {[string is upper $root1]} {
+    #  oo::objdefine [self] "method $method {} {return $wnamefull} ; \
+    #    export $method"
+    #}
+    return $wnamefull
+  }
+
+# ________________________ makeWindow _________________________ #
+
+
+  proc makeWindow {w ttl args} {
+    # Creates a toplevel window that has to be paved.
+    #   w - window's name
+    #   ttl - window's title
+    #   args - options for 'toplevel' command
+    # If $w matches "*.fra" then ttk::frame is created with name $w.
+
+    namespace upvar ::radxide dan dan
+
+    #CleanUps
+    set w [set wtop [string trimright $w .]]
+    set withfr [expr {[set pp [string last . $w]]>0 && \
+      [string match *.fra $w]}]
+    if {$withfr} {
+      set wtop [string range $w 0 $pp-1]
+    }
+    catch {destroy $wtop}
+    lassign [extractOptions args -type {}] type
+    toplevel $wtop {*}$args
+    withdraw $wtop ;# nice to hide all gui manipulations
+    if {$type ne {} && [tk windowingsystem] eq {x11}} {
+      wm attributes $wtop -type $type
+    }
+    if {$withfr} {
+      pack [frame $w -background $dan(BG)] -expand 1 -fill both
+    }
+    wm title $wtop $ttl
+    return $wtop
+  }
+
+# ________________________ ownWName _________________________ #
+
+
+  proc ownWName {name} {
+    # Gets a tail (last part) of widget's name
+    #   name - name (path) of the widget
+
+    return [lindex [split $name .] end]
+  }
+
+# ________________________ parentWName _________________________ #
+
+
+  proc parentWName {name} {
+    # Gets parent name of widget.
+    #   name - name (path) of the widget
+
+    return [string range $name 0 [string last . $name]-1]
+  }
+
+# ________________________ parseOptionsFile _________________________ #
+
+
+	proc parseOptionsFile {strict inpargs args} {
+		# Parses argument list containing options and (possibly) a file name.
+		#   strict - if 0, 'args' options will be only counted for,
+		#              other options are skipped
+		#   strict - if 1, only 'args' options are allowed,
+		#              all the rest of inpargs to be a file name
+		#          - if 2, the 'args' options replace the
+		#              appropriate options of 'inpargs'
+		#   inpargs - list of options, values and a file name
+		#   args  - list of default options
+		#
+		# The inpargs list contains:
+		#   - option names beginning with "-"
+		#   - option values following their names (may be missing)
+		#   - "--" denoting the end of options
+		#   - file name following the options (may be missing)
+		#
+		# The *args* parameter contains the pairs:
+		#   - option name (e.g., "-dir")
+		#   - option default value
+		#
+		# If the *args* option value is equal to =NONE=, the *inpargs* option
+		# is considered to be a single option without a value and,
+		# if present in inpargs, its value is returned as "yes".
+		#
+		# If any option of *inpargs* is absent in *args* and strict==1,
+		# the rest of *inpargs* is considered to be a file name.
+		#
+		# The proc returns a list of two items:
+		#   - an option list got from args/inpargs according to 'strict'
+		#   - a file name from inpargs or {} if absent
+		#
+		# Examples see in tests/obbit.test.
+
+		variable _PU_opts
+		set actopts true
+		array set argarray "$args yes yes" ;# maybe, tail option without value
+		if {$strict==2} {
+		  set retlist $inpargs
+		} else {
+		  set retlist $args
+		}
+		set retfile {}
+		for {set i 0} {$i < [llength $inpargs]} {incr i} {
+		  set parg [lindex $inpargs $i]
+		  if {$actopts} {
+		    if {$parg eq "--"} {
+		      set actopts false
+		    } elseif {[catch {set defval $argarray($parg)}]} {
+		      if {$strict==1} {
+		        set actopts false
+		        append retfile $parg " "
+		      } else {
+		        incr i
+		      }
+		    } else {
+		      if {$strict==2} {
+		        if {$defval == $_PU_opts(-NONE)} {
+		          set defval yes
+		        }
+		        incr i
+		      } else {
+		        if {$defval == $_PU_opts(-NONE)} {
+		          set defval yes
+		        } else {
+		          set defval [lindex $inpargs [incr i]]
+		        }
+		      }
+		      set ai [lsearch -exact $retlist $parg]
+		      incr ai
+		      set retlist [lreplace $retlist $ai $ai $defval]
+		    }
+		  } else {
+		    append retfile $parg " "
+		  }
+		}
+		return [list $retlist [string trimright $retfile]]
+	}
+	
+# ________________________ parseOptions _________________________ #
+
+
+	proc parseOptions {opts args} {
+		# Parses argument list containing options.
+		#  opts - list of options and values
+		#  args - list of "option / default value" pairs
+		# It's the same as parseOptionsFile, excluding the file name stuff.
+		# Returns a list of options' values, according to args.
+		# See also: parseOptionsFile
+
+		lassign [parseOptionsFile 0 $opts {*}$args] tmp
+		foreach {nam val} $tmp {
+		  lappend retlist $val
+		}
+		return $retlist
+	}
+
+# ________________________ popupHighlightCommands _________________________ #
+
+
+  proc popupHighlightCommands {{pop ""} {txt ""}} {
+    # Returns highlighting commands for a popup menu on a text.
+    #   pop - path to the menu
+    #   txt - path to the text
+
+    set res ""
+ 
+    return $res
+  }
+
+# ________________________ Pre _________________________ #
+
+
+  proc Pre {refattrs} {
+    # "Pre" actions for the text widget and similar
+    # which all require some actions before and after their creation e.g.:
+    #   the text widget's text cannot be filled if disabled
+    #   so, we must act this way:
+    #     1. call Pre - to get a text of widget
+    #     2. create the widget
+    #     3. call Post - to enable, then fill it with a text, then disable it
+    # It's only possible with Pre and Post methods.
+    # See also: Post
+
+    upvar 1 $refattrs attrs
+    set attrs_ret [set Prepost [list]]
+    foreach {a v} $attrs {
+      switch -exact -- $a {
+        -disabledtext - -rotext - -lbxsel - -cbxsel - -notebazook - \
+        -entrypop - -entrypopRO - -textpop - -textpopRO - -ListboxSel - \
+        -callF2 - -timeout - -bartabs - -onReturn - -linkcom - -selcombobox - \
+        -afteridle - -gutter - -propagate - -columnoptions - -selborderwidth -
+        -selected - -popup - -bindEC - -tags - -debug - -clearcom {
+          # attributes specific to apave, processed below in "Post"
+          set v2 [string trimleft $v \{]
+          set v2 [string range $v2 0 end-[expr {[string length $v]-[string length $v2]}]]
+          lappend Prepost [list $a $v2]
+        }
+        -myown {
+          lappend Prepost [list $a [subst $v]]
+        }
+        -labelwidget { ;# widget path as a method
+          set v [string trim $v \{\}]
+          catch {set v [$::win::$v]}
+          lappend attrs_ret $a $v
+        }
+        default {
+          lappend attrs_ret $a $v
+        }
+      }
+    }
+    set attrs $attrs_ret
+    return
+  }
+
+# ________________________ PrepArgs _________________________ #
+
+
+  proc PrepArgs {args} {
+    # Prepares a list of arguments.
+    # Returns the list (wrapped in list) and a command for OK button.
+
+    lassign [parseOptions $args -modal {} -ch {} -comOK {} -onclose {}] \
+      modal ch comOK onclose
+    if {[string is true -strict $modal]} {
+      set com 1
+    } elseif {$ch ne {}} {
+      # some options are incompatible with -ch
+      if {$onclose eq {destroy}} {set onclose {}}
+      lappend args -modal 1 -onclose $onclose
+      set com 1
+    } elseif {$comOK eq {}} {
+      set com destroy  ;# non-modal without -ch option
+    } else {
+      set com $comOK
+    }
+    return [list [list $args] $com]
+  }
+
+  ## ________________________ Query _________________________ ##
+
+  proc Query {dlgname icon ttl msg buttons defb inopts argdia {precom ""} args} {
+    # Makes a query (or a message) and gets the user's response.
+    #   dlgname - dialog name
+    #   icon    - icon name (info, warn, ques, err)
+    #   ttl     - title
+    #   msg     - message
+    #   buttons - list of triples "button name, text, ID"
+    #   defb    - default button (OK, YES, NO, CANCEL, RETRY, ABORT)
+    #   inopts  - options for input dialog
+    #   argdia - list of dialog's options
+    #   precom - command(s) performed before showing the dialog
+    #   args - additional options (message's font etc.)
+    # The *argdia* may contain additional options of the query, like these:
+    #   -checkbox text (-ch text) - makes the checkbox's text visible
+    #   -geometry +x+y (-g +x+y) - sets the geometry of dialog
+    #   -color cval    (-c cval) - sets the color of message
+    # If "-geometry" option is set (even equaling "") the Query procedure
+    # returns a list with chosen button's ID and a new geometry.
+    # Otherwise it returns only the chosen button's ID.
+    # See also:
+    # [aplsimple.github.io](https://aplsimple.github.io/en/tcl/pave/index.html)
+
+    namespace upvar ::radxide dan dan
+    variable Indexdlg
+    variable Foundstr
+    variable Dlgpath    
+    variable Dlgname
+    variable dlg
+    
+    #tk_messageBox -title $dan(TITLE) -icon error -message "Query"
+
+    set Winpath $dan(WIN)
+    set Dlgname $dlg(NAME)
+    set wdia $Winpath.dia$Dlgname
+    #append wdia [lindex [split :] end] ;# be unique per apave object
+    #set qdlg [set dlg(PATH) [set Dlgpath $wdia[incr Indexdlg]]]
+    set qdlg $Dlgpath
+    #tk_messageBox -title $dan(TITLE) -icon error -message $qdlg
+    # remember the focus (to restore it after closing the dialog)
+    set focusback [focus]
+    set focusmatch {}
+    # options of dialog
+    lassign {} chmsg geometry optsLabel optsMisc optsFont optsFontM optsHead \
+      root rotext head hsz binds postcom onclose timeout tab2 \
+      tags cc themecolors optsGrid addpopup minsize
+    set wasgeo [set textmode [set stay [set waitvar 0]]]
+    set readonly [set hidefind [set scroll [set modal 1]]]
+    set curpos {1.0}
+    set CheckNomore 0
+    foreach {opt val} {*}$argdia {
+      if {$opt in {-c -color -fg -bg -fgS -bgS -cc -hfg -hbg}} {
+        # take colors by their variables
+        if {[info exist $val]} {set val [set $val]}
+      }
+      switch -- $opt {
+        -H - -head {
+          set head [string map {$ \$ \" \'\' \{ ( \} )} $val]
+        }
+        -help {
+          set buttons "butHELP Help {$val} $buttons"
+        }
+        -ch - -checkbox {set chmsg "$val"}
+        -g - -geometry {
+          set geometry $val
+          if {[set wasgeo [expr {[string first "pointer" $val]<0}]]} {
+            lassign [splitGeometry $geometry] - - gx gy
+          }
+        }
+        -c - -color {append optsLabel " -foreground {$val}"}
+        -a { ;# additional grid options of message labels
+          append optsGrid " $val" }
+        -centerme - -ontop - -themed - -resizable - -checkgeometry - -onclose - -comOK - -transient {
+          lappend args $opt $val ;# options delegated to showModal method
+        }
+        -parent - -root { ;# obsolete, used for compatibility
+          lappend args -centerme $val
+        }
+        -t - -text {set textmode $val}
+        -tags {
+          upvar 2 $val _tags
+          set tags $_tags
+        }
+        -ro - -readonly {set readonly [set hidefind $val]}
+        -rotext {set hidefind 0; set rotext $val}
+        -w - -width {set charwidth $val}
+        -h - -height {set charheight $val}
+        -fg {append optsMisc " -foreground {$val}"}
+        -bg {append optsMisc " -background {$val}"}
+        -fgS {append optsMisc " -selectforeground {$val}"}
+        -bgS {append optsMisc " -selectbackground {$val}"}
+        -cc {append optsMisc " -insertbackground {$val}"}
+        -my - -myown {append optsMisc " -myown {$val}"}
+        -pos {set curpos "$val"}
+        -hfg {append optsHead " -foreground {$val}"}
+        -hbg {append optsHead " -background {$val}"}
+        -hsz {append hsz " -size $val"}
+        -minsize {set minsize "-minsize {$val}"}
+        -focus {set focusmatch "$val"}
+        -theme {append themecolors " {$val}"}
+        -post {set postcom $val}
+        -popup {set addpopup [string map [list %w $qdlg.fra.texM] "$val"]}
+        -timeout - -focusback - -scroll - -tab2 - -stay - -modal - -waitvar {
+          set [string range $opt 1 end] $val
+        }
+        default {
+          append optsFont " $opt $val"
+          if {$opt ne "-family"} {
+            append optsFontM " $opt $val"
+          }
+        }
+      }
+    }
+    if {[set wprev [InfoFind $wdia $modal]] ne {}} {
+      catch {
+        wm withdraw $wprev
+        wm deiconify $wprev
+        puts "$wprev already exists: selected now"
+      }
+      return 0
+    }
+    set optsFont [string trim $optsFont]
+    set optsHeadFont $optsFont
+    set fs [basicFontSize]
+    set textfont "-family {[basicTextFont]}"
+    if {$optsFont ne {}} {
+      if {[string first "-size " $optsFont]<0} {
+        append optsFont " -size $fs"
+      }
+      if {[string first "-size " $optsFontM]<0} {
+        append optsFontM " -size $fs"
+      }
+      if {[string first "-family " $optsFont]>=0} {
+        set optsFont "-font \{$optsFont"
+      } else {
+        set optsFont "-font \{$optsFont -family {[basicDefFont]}"
+      }
+      append optsFont "\}"
+    } else {
+      set optsFont "-font {[basicDefFont] -size $fs}"
+      set optsFontM "-size $fs"
+    }
+    set msgonly [expr {$readonly || $hidefind || $chmsg ne {}}]
+    if {!$textmode || $msgonly} {
+      set textfont "-family {[basicDefFont]}"
+      if {!$textmode} {
+        set msg [string map [list \\ \\\\ \{ \\\\\{ \} \\\\\}] $msg]
+      }
+    }
+    set optsFontM [string trim $optsFontM]
+    set optsFontM "-font \{$optsFontM $textfont\}"
+    # layout: add the icon
+    if {$icon ni {{} -}} {
+      #tk_messageBox -title $dan(TITLE) -icon error -message "Yess!"
+      set widlist [list [list labBimg - - 99 1 \
+        {-st n -pady 7} "-image [iconImage $icon]"]]
+      set prevl labBimg
+    } else {
+      set widlist [list [list labimg - - 99 1]]
+      set prevl labimg ;# this trick would hide the prevw at all
+    }
+    set prevw labBimg
+    #tk_messageBox -title $dan(TITLE) -icon info -message Header:$head
+    if {$head ne {}} {
+      # set the dialog's heading (-head option)
+      if {$optsHeadFont ne {} || $hsz ne {}} {
+        if {$hsz eq {}} {set hsz "-size [basicFontSize]"}
+        set optsHeadFont [string trim "$optsHeadFont $hsz"]
+        set optsHeadFont "-font \"$optsHeadFont\""
+      }
+      set optsFont {}
+      set prevp L
+      set head [string map {\\n \n} $head]
+      foreach lh [split $head "\n"] {
+        set labh "labheading[incr il]"
+        lappend widlist [list $labh $prevw $prevp 1 99 {-st we} \
+          "-t \"$lh\" $optsHeadFont $optsHead"]
+        set prevw [set prevh $labh]
+        set prevp T
+      }
+    } else {
+      # add the upper (before the message) blank frame
+      lappend widlist [list h_1 $prevw L 1 1 {-pady 3}]
+      set prevw [set prevh h_1]
+      set prevp T
+    }
+    # add the message lines
+    set il [set maxw 0]
+    if {$readonly && $rotext eq {}} {
+      # only for messaging (not for editing/viewing texts):
+      set msg [string map {\\\\n \\n \\n \n} $msg]
+    }
+    foreach m [split $msg \n] {
+      set m [string map {$ \$ \" \'\'} $m]
+      if {[set mw [string length $m]] > $maxw} {
+        set maxw $mw
+      }
+      incr il
+      if {!$textmode} {
+        lassign [GetLinkLab $m] m link
+        lappend widlist [list Lab$il $prevw $prevp 1 7 \
+          "-st w -rw 1 $optsGrid" "-t \"$m \" $optsLabel $optsFont $link"]
+      }
+      set prevw Lab$il
+      set prevp T
+    }
+    if {$inopts ne {}} {
+      # here are widgets for input (in fraM frame)
+      set io0 [lindex $inopts 0]
+      lset io0 1 $prevh
+      lset inopts 0 $io0
+      foreach io $inopts {
+        lappend widlist $io
+      }
+      set prevw fraM
+    } elseif {$textmode} {
+      # here is text widget (in fraM frame)
+    ; proc vallimits {val lowlimit isset limits} {
+        set val [expr {max($val,$lowlimit)}]
+        if {$isset} {
+          upvar $limits lim
+          lassign $lim l1 l2
+          set val [expr {min($val,$l1)}] ;# forced low
+          if {$l2 ne {}} {set val [expr {max($val,$l2)}]} ;# forced high
+        }
+        return $val
+      }
+      set il [vallimits $il 1 [info exists charheight] charheight]
+      incr maxw
+      set maxw [vallimits $maxw 20 [info exists charwidth] charwidth]
+      rename vallimits {}
+      lappend widlist [list fraM $prevh T 10 12 {-st nswe -pady 3 -rw 1}]
+      lappend widlist [list TexM - - 1 12 {pack -side left -expand 1 -fill both -in \
+        $qdlg.fra.fraM} [list -h $il -w $maxw {*}$optsFontM {*}$optsMisc \
+        -wrap word -textpop 0 -tabnext "$qdlg.fra.[lindex $buttons 0] *but0"]]
+      if {$scroll} {
+        lappend widlist {sbv texM L 1 1 {pack -in $qdlg.fra.fraM}}
+      }
+      set prevw fraM
+    }
+    # add the lower (after the message) blank frame
+    lappend widlist [list h_2 $prevw T 1 1 {-pady 0 -ipady 0 -csz 0}]
+    # underline the message
+    lappend widlist [list seh $prevl T 1 99 {-st ew}]
+    # add left frames and checkbox (before buttons)
+    lappend widlist [list h_3 seh T 1 1 {-pady 0 -ipady 0 -csz 0}]
+    if {$textmode} {
+      # binds to the special popup menu of the text widget
+      set wt "\[TexM\]"
+      set binds "set pop $wt.popupMenu
+        bind $wt <Button-3> \{[self] themePopup $wt.popupMenu; tk_popup $wt.popupMenu %X %Y \}"
+      if {$msgonly} {
+        append binds "
+          menu \$pop
+           \$pop add command [iconA copy] -accelerator Ctrl+C -label \"Copy\" \\
+            -command \"event generate $wt <<Copy>>\""
+        if {$hidefind || $chmsg ne {}} {
+          append binds "
+            \$pop configure -tearoff 0
+            \$pop add separator
+            \$pop add command [iconA none] -accelerator Ctrl+A \\
+            -label \"Select All\" -command \"$wt tag add sel 1.0 end\"
+             bind $wt <Control-a> \"$wt tag add sel 1.0 end; break\""
+        }
+      }
+    }
+    set appendHL no
+    if {$chmsg eq {}} {
+      if {$textmode} {
+        set noIMG "[iconA none]"
+        if {$hidefind} {
+          lappend widlist [list h__ h_3 L 1 4 {-cw 1}]
+        } else {
+          lappend widlist [list labfnd h_3 L 1 1 "-st e" "-t {$::win::msgarray(find)}"]
+          lappend widlist [list Entfind labfnd L 1 1 \
+            {-st ew -cw 1} "-tvar [namespace current]::Foundstr -w 10"]
+          lappend widlist [list labfnd2 Entfind L 1 1 "-cw 2" "-t {}"]
+          lappend widlist [list h__ labfnd2 L 1 1]
+          #append binds "
+          #  bind \[[self] Entfind\] <Return> {[self] findInText}
+          #  bind \[[self] Entfind\] <KP_Enter> {[self] findInText}
+          #  bind \[[self] Entfind\] <FocusIn> {\[[self] Entfind\] selection range 0 end}
+          #  bind $qdlg <F3> {[self] findInText 1}
+          #  bind $qdlg <Control-f> \"InitFindInText 1; focus \[[self] Entfind\]; break\"
+          #  bind $qdlg <Control-F> \"InitFindInText 1; focus \[[self] Entfind\]; break\""
+        }
+        if {$readonly} {
+          if {!$hidefind} {
+           # append binds "
+           #  \$pop add separator
+           #  \$pop add command [iconA find] -accelerator Ctrl+F -label \\
+           #  \"Find First\" -command \"[self] InitFindInText; focus \[[self] Entfind\]\"
+           #  \$pop add command $noIMG -accelerator F3 -label \"Find Next\" \\
+           #   -command \"[self] findInText 1\"
+           #  $addpopup
+           #  \$pop add separator
+           #  \$pop add command [iconA exit] -accelerator Esc -label \"Close\" \\
+           #   -command \"\[[self] paveoptionValue Defb1\] invoke\"
+           # "
+          } else {
+            set appendHL yes
+          }
+        } else {
+          # make bindings and popup menu for text widget
+          #after idle "set_highlight_matches \[TexM\]"
+          #append binds "
+          #  [setTextBinds $wt]
+          #  menu \$pop
+          #   \$pop add command [iconA cut] -accelerator Ctrl+X -label \"Cut\" \\
+          #    -command \"event generate $wt <<Cut>>\"
+          #   \$pop add command [iconA copy] -accelerator Ctrl+C -label \"Copy\" \\
+          #    -command \"event generate $wt <<Copy>>\"
+          #   \$pop add command [iconA paste] -accelerator Ctrl+V -label \"Paste\" \\
+          #    -command \"event generate $wt <<Paste>>\"
+          #   [popupBlockCommands \$pop $wt]
+          #   [popupHighlightCommands \$pop $wt]
+          #   [popupFindCommands \$pop $wt]
+          #   $addpopup
+          #   \$pop add separator
+          #   \$pop add command [iconA SaveFile] -accelerator Ctrl+W \\
+          #   -label \"Save and Close\" -command \"[self] res $qdlg 1\"
+          #  "
+        }
+        #set onclose [namespace current]::exitEditor
+        #oo::objdefine [self] export InitFindInText
+      } else {
+        lappend widlist [list h__ h_3 L 1 4 {-cw 1}]
+      }
+    } else {
+      lappend widlist [list chb h_3 L 1 1 \
+        {-st w} "-t {$chmsg} -var [namespace current]::CheckNomore"]
+      lappend widlist [list h_ chb L 1 1]
+      lappend widlist [list sev h_ L 1 1 {-st nse -cw 1}]
+      lappend widlist [list h__ sev L 1 1]
+      set appendHL $textmode
+    }
+    #if {$appendHL} {
+    #  after idle "set_highlight_matches $wt"
+    #  append binds "
+    #  [popupHighlightCommands \$pop $wt]"
+    #}
+    # add the buttons
+    
+    # xxx
+    if {$dlgname eq "RenameFile" || $dlgname eq "Find"} {
+      set buttons [string map {"butOK OK 1" "" "butCANCEL Cancel destroy" ""} $buttons]
+    }
+    lassign [AppendButtons widlist $buttons h__ L $defb $timeout $qdlg $modal] \
+      bhelp bcomm
+    # make the dialog's window
+    set wtop [makeWindow $qdlg.fra $ttl]
+    if {$bhelp ne {}} {
+      bind $qdlg <F1> $bcomm
+    }
+    # pave the dialog's window
+    if {$tab2 eq {}} {
+      set widlist [rockWindow $qdlg.fra $widlist]
+    } else {
+      # pave with the notebook tabs (titl1 title2 [title3...] widlist2 [widlist3...])
+      lassign $tab2 ttl1 ttl2 widlist2 ttl3 widlist3 ttl4 widlist4 ttl5 widlist5
+      foreach nt {3 4 5} {
+        set ttl ttl$nt
+        set wdl widlist$nt
+        if {[set _ [set $ttl]] ne {}} {
+          set $ttl [list f$nt "-t {$_}"]
+          set $wdl [list $qdlg.fra.nbk.f$nt "[set $wdl]"]
+        }
+      }
+      set widlist0 [list [list nbk - - - - {pack -side top -expand 1 -fill both} [list \
+        f1 "-t {$ttl1}" \
+        f2 "-t {$ttl2}" \
+        {*}$ttl3 \
+        {*}$ttl4 \
+        {*}$ttl5 \
+      ]]]
+    
+      set widlist1 [list]
+      foreach it $widlist {
+        lassign $it w nei pos r c opt atr
+        set opt [string map {$qdlg.fra $qdlg.fra.nbk.f1} $opt]
+        lappend widlist1 [list $w $nei $pos $r $c $opt $atr]
+      }
+      set widlist [rockWindow $qdlg.fra $widlist0 \
+        $qdlg.fra.nbk.f1 $widlist1 \
+        $qdlg.fra.nbk.f2 $widlist2 \
+        {*}$widlist3 \
+        {*}$widlist4 \
+        {*}$widlist5 \
+      ]
+      set tab2 nbk.f1.
+    }
+    if {$precom ne {}} {
+      {*}$precom  ;# actions before showModal
+    }
+    # if {$themecolors ne {}} {
+    #   # themed colors are set as sequentional '-theme' args
+    #   if {[llength $themecolors]==2} {
+    #     # when only 2 main fb/bg colors are set (esp. for TKE)
+    #     lassign [::apave::parseOptions $optsMisc -foreground black \
+    #       -background white -selectforeground black \
+    #       -selectbackground gray -insertbackground black] v0 v1 v2 v3 v4
+    #     # the rest colors should be added, namely:
+    #     #   tfg2 tbg2 tfgS tbgS tfgD tbgD tcur bclr help fI bI fM bM fW bW bHL2
+    #     lappend themecolors $v0 $v1 $v2 $v3 $v3 $v1 $v4 $v4 $v3 $v2 $v3 $v0 $v1 black #ffff9e $v1
+    #   }
+    #   catch {
+    #     my themeWindow $qdlg $themecolors no
+    #   }
+    # }
+    # after creating widgets - show dialog texts if any
+    SetGetTexts set $qdlg.fra $inopts $widlist
+    lassign [LowercaseWidgetName $qdlg.fra.$tab2$defb] focusnow
+    if {$textmode} {
+      displayTaggedText [TexM] msg $tags
+      if {$defb eq "ButTEXT"} {
+        if {$readonly} {
+          lassign [LowercaseWidgetName $Defb1] focusnow
+        } else {
+          set focusnow [TexM]
+          catch "::tk::TextSetCursor $focusnow $curpos"
+          foreach k {w W} \
+            {catch "bind $focusnow <Control-$k> {[self] res $qdlg 1; break}"}
+        }
+      }
+      if {$readonly} {
+        readonlyWidget ::[TexM] true false
+      }
+    }
+    if {$focusmatch ne {}} {
+      foreach w $widlist {
+        lassign $w widname
+        lassign [LowercaseWidgetName $widname] wn rn
+        if {[string match $focusmatch $rn]} {
+          lassign [LowercaseWidgetName $qdlg.fra.$wn] focusnow
+          break
+        }
+      }
+    }
+    catch "$binds"
+    set args [removeOptions $args -focus]
+    set querydlg $qdlg
+    showModal $qdlg -modal $modal -waitvar $waitvar -onclose $onclose \
+      -focus $focusnow -geometry $geometry {*}$minsize {*}$args
+    if {![winfo exists $qdlg] || (!$modal && !$waitvar)} {
+      return 0
+    }
+    set pdgeometry [wm geometry $qdlg]
+    # the dialog's result is defined by "pave res" + checkbox's value
+    # xxx
+    #tk_messageBox -title $dan(TITLE) -icon info -message $qdlg 
+    set res [set result [::radxide::win::res $qdlg]]
+    #tk_messageBox -title $dan(TITLE) -icon info -message resX=$res
+    set chv $CheckNomore
+    if { [string is integer $res] } {
+      if {$res && $chv} { incr result 10 }
+    } else {
+      set res [expr {$result ne {} ? 1 : 0}]
+      if {$res && $chv} { append result 10 }
+    }
+    if {$textmode && !$readonly} {
+      set focusnow [TexM]
+      set textcont [$focusnow get 1.0 end]
+      if {$res && $postcom ne {}} {
+        {*}$postcom textcont [TexM] ;# actions after showModal
+      }
+      set textcont " [$focusnow index insert] $textcont"
+    } else {
+      set textcont {}
+    }
+    if {$res && $inopts ne {}} {
+      SetGetTexts get $qdlg.fra $inopts $widlist
+      set inopts " [GetVarsValues $widlist]"
+    } else {
+      set inopts {}
+    }
+    if {$textmode && $rotext ne {}} {
+      set $rotext [string trimright [TexM] get 1.0 end]]
+    }
+    if {!$stay} {
+      destroy $qdlg
+      update
+      # pause a bit and restore the old focus
+      if {$focusback ne {} && [winfo exists $focusback]} {
+        set w ".[lindex [split $focusback .] 1]"
+        after 50 [list if "\[winfo exist $focusback\]" "focus -force $focusback" elseif "\[winfo exist $w\]" "focus $w"]
+      } else {
+        after 50 list focus .
+      }
+    }
+    if {$wasgeo} {
+      lassign [splitGeometry $pdgeometry] w h x y
+      catch {
+        # geometry option can contain pointer/root etc.
+        if {abs($x-$gx)<30} {set x $gx}
+        if {abs($y-$gy)<30} {set y $gy}
+      }
+      return [list $result ${w}x$h$x$y $textcont [string trim $inopts]]
+    }
+    return "$result$textcont$inopts"
+  }
+
+# ________________________ readonlyWidget _________________________ #
+
+
+  proc readonlyWidget {w {on yes} {popup yes}} {
+    # Switches on/off a widget's readonly state for a text widget.
+    #   w - text widget's path
+    #   on - "on/off" boolean flag
+    #   popup - "make popup menu" boolean flag
+    # See also:
+    #   [wiki.tcl-lang.org](https://wiki.tcl-lang.org/page/Read-only+text+widget)
+
+    #my TextCommandForChange $w {} $on
+    #if {$popup} {my makePopup $w $on yes}
+    return
+  }
+
+
+	proc readTextFile {fileName {varName ""} {doErr 0} args} {
+		# Reads a text file.
+		#   fileName - file name
+		#   varName - variable name for file content or ""
+		#   doErr - if 'true', exit at errors with error message
+		# Returns file contents or "".
+
+		variable _PU_opts
+		if {$varName ne {}} {upvar $varName fvar}
+		if {[catch {set chan [open $fileName]} _PU_opts(_ERROR_)]} {
+		  if {$doErr} {error [::radxide::win::error $fileName]}
+		  set fvar {}
+		} else {
+		  set enc [getOption -encoding {*}$args]
+		  set eol [string tolower [getOption -translation {*}$args]]
+		  if {$eol eq {}} {set eol auto} ;# let EOL be autodetected by default
+		  textChanConfigure $chan $enc $eol
+		  set fvar [read $chan]
+		  close $chan
+		  logMessage "read $fileName"
+		}
+		return $fvar
+	}
+
+# ________________________ renameFileOK _________________________ #
+
+
+  proc renameFileOK {} {
+  
+    namespace upvar ::radxide dan dan project project
+
+    variable dlg
+    
+    #set t $Dlgpath.fra.fraM.fraent.ent
+    set t [dlgPath].fra.[FieldName [lindex [getDialogField 0] 0]]
+    #tk_messageBox -title $dan(TITLE) -icon info -message textbox=$t
+    set varname [lindex [getDialogField end] 0]
+    #tk_messageBox -title $dan(TITLE) -icon info -message varname=$varname
+    set oldpath [lindex [getDialogField end] 1]
+    #tk_messageBox -title $dan(TITLE) -icon info -message oldpath=$oldpath
+    set newpath [string trim [$t get]]
+    #tk_messageBox -title $dan(TITLE) -icon info -message newpath=$newpath
+
+    set pathlength [expr [string length $newpath]-1] 
+    if {[string range $newpath $pathlength $pathlength] eq "/"} {
+      tk_messageBox -title $dan(TITLE) -icon info -message "Destination can't be a folder!"
+      return 0
+    }
+
+    if {[string first $dan(WORKDIR) $newpath] eq -1} {
+      tk_messageBox -title $dan(TITLE) -icon info -message "New file path outside the Working Dir!"
+      return 0
+    }
+
+    if {[string first $project(ROOT) $newpath] eq -1} {
+      tk_messageBox -title $dan(TITLE) -icon info -message "New file path outside the Project Dir!"
+      return 0
+    }
+    
+    if {[catch {file rename $oldpath $newpath} e]} {
+			set msg "\nERROR in win:"
+			puts \n$msg\n\n$e$::errorInfo\n
+			set msg "$msg\n\n$e\n\nPlease, inform authors.\nDetails are in stdout."
+			tk_messageBox -title $dan(TITLE) -icon error -message $msg  
+			return 0 
+    }
+    
+	  # savind {field oldval newval} for later use
+	  editDialogField end $varname $oldpath $newpath
+
+    ::radxide::tree::create
+    
+    # Workaround for an overwheling activation of the main text editor..
+    if {$project(CUR_FILE_PATH) eq ""} {
+      $dan(TEXT) configure -state disabled
+    }
+        
+    catch {destroy [dlgPath]}
+
+    return 1
+  }
+
+# ________________________ renameFileCancel _________________________ #
+
+
+  proc renameFileCancel {} {
+  
+    #catch {[destroy .danwin.diaRenameFile1]}    
+    catch {[destroy [dlgPath]]}
+        
+    return 0
+  }
+
+
+
+# ________________________ Replace_Tcl _________________________ #
+
+
+  proc Replace_Tcl {r1 r2 r3 args} {
+    # Replaces Tcl code with its resulting items in *lwidgets* list.
+    #   r1 - variable name for a current index in *lwidgets* list
+    #   r2 - variable name for a length of *lwidgets* list
+    #   r3 - variable name for *lwidgets* list
+    #   args - "tcl" and "tcl code" for "tcl" type of widget
+    # The code should use the wildcard that goes first at a line:
+    #   %C - a command for inserting an item into lwidgets list.
+    # The "tcl" widget type can be useful to automate the inserting
+    # a list of similar widgets to the list of widgets.
+    # See tests/test2_pave.tcl where the "tcl" fills "Color schemes" tab.
+
+    lassign $args _name _code
+    if {[ownWName $_name] ne {tcl}} {return $args}
+    upvar 1 $r1 _ii $r2 _lwlen $r3 _lwidgets
+  ; proc lwins {lwName i w} {
+      upvar 2 $lwName lw
+      set lw [linsert $lw $i $w]
+    }
+    set _lwidgets [lreplace $_lwidgets $_ii $_ii]  ;# removes tcl item
+    set _inext [expr {$_ii-1}]
+    eval [string map {%C {lwins $r3 [incr _inext] }} $_code]
+    return {}
+  }
+
+# ________________________ removeOptions _________________________ #
+
+
+	proc removeOptions {options args} {
+		# Removes some options from a list of options.
+		#   options - list of options and values
+		#   args - list of option names to remove
+		# The `options` may contain "key value" pairs and "alone" options
+		# without values.
+		# To remove "key value" pairs, `key` should be an exact name.
+		# To remove an "alone" option, `key` should be a glob pattern with `*`.
+
+		foreach key $args {
+		  while {[incr maxi]<99} {
+		    if {[set i [lsearch -exact $options $key]]>-1} {
+		      catch {
+		        # remove a pair "option value"
+		        set options [lreplace $options $i $i]
+		        set options [lreplace $options $i $i]
+		      }
+		    } elseif {[string first * $key]>=0 && \
+		      [set i [lsearch -glob $options $key]]>-1} {
+		      # remove an option only
+		      set options [lreplace $options $i $i]
+		    } else {
+		      break
+		    }
+		  }
+		}
+		return $options
+	}
+
+
+# ________________________ res _________________________ #
+
+
+  proc res {{win {}} {result get}} {
+    # Gets/sets a variable for *vwait* command.
+    #   win - window's path
+    #   result - value of variable
+    # This method is used when
+    #  - an event cycle should be stopped with changing a variable's value
+    #  - a result of event cycle (the variable's value) should be got
+    # In the first case, *result* is set to an integer. In *apave* dialogs
+    # the integer is corresponding a pressed button's index.
+    # In the second case, *result* is omitted or equal to "get".
+    # Returns a value of variable that controls an event cycle.
+
+    if {$win eq {}} {set win [dlgPath]}
+    set varname [WinVarname $win]
+    if {$result eq {get}} {
+      return [set $varname]
+    }
+    #CleanUps $win
+    return [set $varname $result]
+  }
+
+# ___________________ rockWindow _________________ #
+
+
+  proc rockWindow {args} {
+    # Processes "win / list_of_widgets" pairs.
+    #   args - list of pairs "win / lwidgets"
+    # The *win* is a window's path. The *lwidgets* is a list of widget items.
+    # Each widget item contains:
+    #   name - widget's name (first 3 characters define its type)
+    #   neighbor - top or left neighbor of the widget
+    #   posofnei - position of neighbor: T (top) or L (left)
+    #   rowspan - row span of the widget
+    #   colspan - column span of the widget
+    #   options - grid/pack options
+    #   attrs - attributes of widget
+    # First 3 items are mandatory, others are set at need.
+    # This method calls *paveWindow* in a cycle, to process a current "win/lwidgets" pair.
+
+    namespace upvar ::radxide dan dan
+
+    #tk_messageBox -title $dan(TITLE) -icon info -message "Start rock-Window!"
+
+    set res [list]
+    set wmain [set wdia {}]
+    foreach {w lwidgets} $args {
+      if {[lindex $lwidgets 0 0] eq {after}} {
+        # if 1st item is "after idle" or like "after 1000", layout the window after...
+        # (fit for "invisible independent" windows/frames/tabs)
+        set what [lindex $lwidgets 0 1]
+        if {$what eq {idle} || [string is integer -strict $what]} {
+          after $what [rockWindow $w [lrange $lwidgets 1 end]]
+          #after $what [list [self] colorWindow $w -doit]
+        }
+        continue
+      }
+      lappend res {*}[Window $w $lwidgets]
+      if {[set ifnd [regexp -indices -inline {[.]dia\d+} $w]] ne {}} {
+        set wdia [string range $w 0 [lindex $ifnd 0 1]]
+      } else {
+        set wmain .[lindex [split $w .] 1]
+      }
+    }
+    # add a system Menu binding for the created window
+    #if {[winfo exists $wdia]} {::apave::initPOP $wdia} elseif {
+    #    [winfo exists $wmain]} {::apave::initPOP $wmain}
+    return $res
+  }
+
+# ________________________ Search _________________________ #
+
+
+#	proc Search {wtxt} {
+#		# Searches a text for a string to find.
+#		#   wtxt - text widget's path
+#
+#		namespace upvar ::alited obPav obPav
+#		variable counts
+#		variable data
+#		set idx [$wtxt index insert]
+#		#lassign [FindOptions $wtxt] findstr options
+#	  set options {}
+#    set findstr $data(en1)
+#		if {![CheckData find]} {return {}}
+#		$obPav set_HighlightedString $findstr
+#		SetTags $wtxt
+#		lassign [Search1 $wtxt 1.0] err fnd
+#		if {$err} {return {}}
+#		set i 0
+#		set res [list]
+#		foreach index1 $fnd {
+#		  set index2 [$wtxt index "$index1 + [lindex $counts $i]c"]
+#		  if {[CheckWord $wtxt $index1 $index2]} {
+#		    lappend res [list $index1 $index2]
+#		  }
+#		  incr i
+#		}
+#		return $res
+#	}
+
+#_______________________ selectedWordText _____________________ #
+
+
+  proc selectedWordText {txt} {
+    # Returns a word under the cursor or a selected text.
+    #   txt - the text's path
+
+    set seltxt {}
+    if {![catch {$txt tag ranges sel} seltxt]} {
+      if {$seltxt eq ""} {return ""}
+      set forword [expr {$seltxt eq {}}]
+      #if {[set forword [expr {$seltxt eq {}}]]} {
+      #  set pos  [$txt index "insert wordstart"]
+      #  set pos2 [$txt index "insert wordend"]
+      #  set seltxt [string trim [$txt get $pos $pos2]]
+      #  if {![string is wordchar -strict $seltxt]} {
+      #    # when cursor just at the right of word: take the word at the left
+      #    set pos  [$txt index "insert -1 char wordstart"]
+      #    set pos2 [$txt index "insert -1 char wordend"]
+      #  }
+      #} else {
+        lassign $seltxt pos pos2
+      #}
+      #catch {
+        set seltxt [$txt get $pos $pos2]
+        if {[set sttrim [string trim $seltxt]] ne {}} {
+          if {$forword} {set seltxt $sttrim}
+        }
+      #}
+    }
+    return $seltxt
+  }
+
+# ________________________ setAppIcon _________________________ #
+
+
+  proc setAppIcon {win {winicon ""}} {
+    # Sets application's icon.
+    #   win - path to a window of application
+    #   winicon - data of icon
+    # The *winicon* may be a contents of variable (as supposed by default) or
+    # a file's name containing th image data.
+    # If it fails to find an image in either, no icon is set.
+
+    set appIcon {}
+    if {$winicon ne {}} {
+      if {[catch {set appIcon [image create photo -data $winicon]}]} {
+        catch {set appIcon [image create photo -file $winicon]}
+      }
+    }
+    if {$appIcon ne {}} {wm iconphoto $win -default $appIcon}
+  }
+
+# ________________________ SetGetTexts _________________________ #
+
+
+  proc SetGetTexts {oper w iopts lwidgets} {
+    # Sets/gets contents of text fields.
+    #   oper - "set" to set, "get" to get contents of text field
+    #   w - window's name
+    #   iopts - equals to "" if no operation
+    #   lwidgets - list of widget items
+
+    if {$iopts eq {}} return
+    foreach widg $lwidgets {
+      set wname [lindex $widg 0]
+      set name [ownWName $wname]
+      if {[string range $name 0 1] eq "te"} {
+        set vv [::radxide::win::varName $name]
+        if {$oper eq "set"} {
+          displayText $w.$wname [set $vv]
+        } else {
+          set $vv [string trimright [$w.$wname get 1.0 end]]
+        }
+      }
+    }
+    return
+  }
+
+# ________________________ set_HighlightedString _________________________ #
+
+
+  proc set_HighlightedString {sel} {
+    # Saves a string got from highlighting by Alt+left/right/q/w.
+    #   sel - the string to be saved
+
+    set HLstring $sel
+    if {$sel ne {}} {set Foundstr $sel}
+  }
+
+# ________________________ set_highlight_matches _________________________ #
+
+
+  proc set_highlight_matches {w} {
+    # Creates bindings to highlight matches in a text.
+    #   w - path to the text
+
+  }
+
+# ________________________ setTextBinds _________________________ #
+
+
+  proc setTextBinds {wt} {
+    # Returns bindings for a text widget.
+    #   wt - the text's path
+
+    set res ""
+
+    return $res
+  }
+
+# ________________________ showModal _________________________ #
+
+
+  proc showModal {win args} {
+    # Shows a window as modal.
+    #   win - window's name
+    #   args - attributes of window ("-name value" pairs)
+
+    namespace upvar ::radxide dan dan
+ 
+    variable MODALWINDOW
+
+    set MODALWINDOW [set Modalwin $win]
+    setAppIcon $win
+    lassign [extractOptions args -centerme {} -ontop 0 -modal yes -minsize {} \
+      -themed {} -input 0 -variable {} -waitvar {} -transient {-} -root {} -parent {}] \
+      centerme ontop modal minsize themed input varname waitvar transient root parent
+    $win configure -bg $dan(BG)  ;# removes blinking by default bg
+    #if {$themed in {{} {0}} && [my csCurrent] != [apave::cs_Non]} {
+    #  my colorWindow $win
+    #}
+    if {$centerme eq {}} {
+      # obsolete options: -root, -parent
+      if {$root ne {}} {set centerme $root} {set centerme $parent}
+    }
+    set root [winfo parent $win]
+    set rooted 1
+    if {$centerme ne {}} {
+      ;# forced centering relative to a caller's window
+      lassign [split $centerme x+] rw rh rx ry
+      set rooted [expr {![regexp {[+|-]+\d+\++} $centerme]}]
+      if {$rooted && [winfo exist $centerme]} {
+        set root $centerme
+      }
+    }
+    set decor [expr {$root in {{} .}}]
+    foreach {o v} [list -decor $decor -focus {} -onclose {} -geometry {} \
+    -resizable {} -ontop 0 -escape 1 -checkgeometry 1] {
+      lappend defargs $o [getShowOption $o $v]
+    }
+    if {$varname ne {}} {
+      set waitvar 1
+    } else {
+      set waitvar [string is true $waitvar]  ;# default 1: wait for closing the window
+      set varname [WinVarname $win]
+    }
+    array set opt [list {*}$defargs {*}$args]
+    if {$ontop eq {}} {
+      if {$opt(-ontop)} {
+        set ontop yes
+      } else {
+        set ontop no
+        catch {
+          set ontop [wm attributes [winfo parent $win] -topmost]
+        }
+        if {!$ontop} {
+          # find if a window child of "." is topmost
+          # if so, let this one be topmost too
+          foreach w [winfo children .] {
+            catch {set ontop [wm attributes $w -topmost]}
+            if {$ontop} break
+          }
+        }
+      }
+    }
+    if {$rooted} {
+      lassign [splitGeometry [wm geometry [winfo toplevel $root]]] rw rh rx ry
+    }
+    if {$transient ne {-}} {
+      wm transient $win $transient
+    } elseif {!$opt(-decor)} {
+      wm transient $win $root
+    }
+    if {[set destroy [expr {$opt(-onclose) eq {destroy}}]]} {
+      set opt(-onclose) {}
+    }
+    if {$opt(-onclose) eq {}} {
+      set opt(-onclose) "set $varname 0"
+    } else {
+      set opt(-onclose) "$opt(-onclose) $varname"  ;# $opt(-onclose) is a command
+    }
+    #if {$destroy} {append opt(-onclose) " ; destroy $win"}    
+    if {$destroy} {append opt(-onclose) " ; destroy $win"}
+    if {$opt(-resizable) ne {}} {
+      if {[string is boolean $opt(-resizable)]} {
+        set opt(-resizable) "$opt(-resizable) $opt(-resizable)"
+      }
+      wm resizable $win {*}$opt(-resizable)
+    }
+    if {!($modal || $waitvar)} {
+      append opt(-onclose) "; CleanUps $win"
+    }
+    wm protocol $win WM_DELETE_WINDOW $opt(-onclose)
+    # get the window's geometry from its requested sizes
+    set inpgeom $opt(-geometry)
+    if {$inpgeom eq {}} {
+      # this is for less blinking:
+      set opt(-geometry) [centeredXY $win $rw $rh $rx $ry \
+        [winfo reqwidth $win] [winfo reqheight $win]]
+    } elseif {[string first pointer $inpgeom]==0} {
+      lassign [split $inpgeom+0+0 +] -> x y
+      set inpgeom +[expr {$x+[winfo pointerx .]}]+[expr {$y+[winfo pointery .]}]
+      set opt(-geometry) $inpgeom
+    } elseif {[string first root $inpgeom]==0} {
+      set root .[string trimleft [string range $inpgeom 5 end] .]
+      set opt(-geometry) [set inpgeom {}]
+    }
+    if {$opt(-geometry) ne {}} {
+      lassign [splitGeometry $opt(-geometry) {} {}] - - x y
+      if {$x ne {}} {wm geometry $win $x$y}
+    }
+    if {$opt(-focus) eq {}} {
+      set opt(-focus) $win
+    }
+    set $varname {-}
+    if {$opt(-escape)} {bind $win <Escape> $opt(-onclose)}
+    update
+    if {![winfo exists $win]} {
+      return 0 ;# looks idiotic, yet possible at sporadic calls
+    }
+    set w [winfo reqwidth $win]
+    set h [winfo reqheight $win]
+    if {$inpgeom eq {}} {  ;# final geometrizing with actual sizes
+      set geo [centeredXY $win $rw $rh $rx $ry $w $h]
+      set y [lindex [split $geo +] end]
+      if {!$rooted || $root ne {.} && (($h/2-$ry-$rh/2)>30 || [::radxide::iswindows] && $y>0)} {
+        # ::tk::PlaceWindow needs correcting in rare cases, namely:
+        # when 'root' is of less sizes than 'win' and at screen top
+        wm geometry $win $geo
+      } else {
+        ::tk::PlaceWindow $win widget $root
+      }
+    } else {
+      lassign [splitGeometry $inpgeom {} {}] - - x y
+      if {$x ne {} && $y ne {} && [string first x $inpgeom]<0 && $opt(-checkgeometry)} {
+        set inpgeom [checkXY $win $w $h $x $y]
+      } elseif {$x eq {} && $y eq {} && $centerme ne {} && $opt(-geometry) ne {}} {
+        lassign [split $opt(-geometry) x+] w h
+        lassign [split [centeredXY $win $rw $rh $rx $ry $w $h] +] -> x y
+        set inpgeom ${w}x$h+$x+$y
+      }
+      wm geometry $win $inpgeom
+    }
+    after 50 [list if "\[winfo exist $opt(-focus)\]" "focus -force $opt(-focus)"]
+    #if {[info exists ::transpops::my::cntwait]} {
+    #  # this specific bind - for transpops package (to hide a demo message by keys)
+    #  bind $win <Control-Alt-0> {set ::transpops::my::cntwait 0}
+    #}
+    showWindow $win $modal $ontop $varname $minsize $waitvar
+    set res 0
+    #catch {
+      if {$modal || $waitvar} {CleanUps $win}
+      if {[winfo exists $win]} {
+        if {$input} {GetOutputValues}
+        set res [set [set _ $varname]]
+      }
+    #}
+    return $res
+  }
+
+# ________________________ showWindow _________________________ #
+
+
+  proc showWindow {win modal ontop {var ""} {minsize ""} {waitvar 1}} {
+    # Displays a windows and goes in tkwait cycle to interact with a user.
+    #   win - the window's path
+    #   modal - yes at showing the window as modal
+    #   ontop - yes at showing the window as topmost
+    #   var - variable's name to receive a result (tkwait's variable)
+    #   minsize - list {minwidth minheight} or {}
+    #   waitvar - if yes, force tkwait variable (mostly for non-modal windows)
+
+    InfoWindow [expr {[InfoWindow] + 1}] $win $modal $var yes
+    #::apave::deiconify $win
+    if {$minsize eq {}} {
+      set minsize [list [winfo width $win] [winfo height $win]]
+    }
+    wm minsize $win {*}$minsize
+    bind $win <Configure> "[namespace current]::WinResize $win"
+    if {$ontop} {wm attributes $win -topmost 1}
+    if {$modal} {
+      # modal window:
+      waitWinVar $win $var $modal
+      InfoWindow [expr {[InfoWindow] - 1}] $win $modal $var
+    } else {
+      # non-modal window:
+      if {[set wgr [grab current]] ne {}} {
+        # otherwise the non-modal window is irresponsive (in Windows even at WM level):
+        grab release $wgr
+      }
+      if {$waitvar && $var ne {}} {
+        waitWinVar $win $var $modal ;# show and wait for closing the window
+      }
+    }
+  }
+
+# ________________________ setShowOption _________________________ #
+
+  proc setShowOption {name args} {
+    # Sets / gets a default show option, used in showModal.
+    #   name - name of option
+    #   args - value of option
+    # See also: showModal
+
+    setProperty [ShowOption $name] {*}$args
+  }
+
+# ________________________ setProperty _________________________ #
+
+
+	proc setProperty {name args} {
+		# Sets a property's value as "application-wide".
+		#   name - name of property
+		#   args - value of property
+		# If *args* is omitted, the method returns a property's value.
+		# If *args* is set, the method sets a property's value as $args.
+
+		variable _AP_Properties
+		switch -exact [llength $args] {
+		  0 {return [getProperty $name]}
+		  1 {return [set _AP_Properties($name) [lindex $args 0]]}
+		}
+		puts -nonewline stderr \
+		  "Wrong # args: should be \"::win::setProperty propertyname ?value?\""
+		return -code error
+	}
+
+# ________________________ ShowOption _________________________ #
+
+
+  proc ShowOption {name} {
+    # Gets a default show option, used in showModal.
+    #   name - name of option
+    # See also: getShowOption, setShowOption
+
+    return "_SHOWMODAL_$name"
+  }
+
+# ________________________ SpanConfig _________________________ #
+
+  proc SpanConfig {w rcnam rc rcspan opt val} {
+    # The method is used by *GetIntOptions* method to configure
+    # row/column for their *span* options.
+
+    for {set i $rc} {$i < ($rc + $rcspan)} {incr i} {
+      eval [grid ${rcnam}configure $w $i $opt $val]
+    }
+    return
+  }
+
+# ________________________ splitGeometry _________________________ #
+
+
+	proc splitGeometry {geom {X +0} {Y +0}} {
+		# Gets widget's geometry components.
+		#   geom - geometry
+		#   X - default X-coordinate
+		#   Y - default Y-coordinate
+		# Returns a list of width, height, X and Y (coordinates are always with + or -).
+
+		lassign [split $geom x+-] w h
+		lassign [regexp -inline -all {([+-][[:digit:]]+)} $geom] -> x y
+		if {$geom ne {}} {
+		  if {$x in {"" 0} || [catch {expr {$x+0}}]} {set x $X}
+		  if {$y in {"" 0} || [catch {expr {$y+0}}]} {set y $Y}
+		}
+		return [list $w $h $x $y]
+	}
+
+# ________________________ textChanConfigure _________________________ #
+
+
+	proc textChanConfigure {channel {coding {}} {eol {}}} {
+		# Configures a channel for text file.
+		#   channel - the channel
+		#   coding - if set, defines encoding of the file
+		#   eol - if set, defines EOL of the file
+
+		if {$coding eq {}} {
+		  chan configure $channel -encoding utf-8
+		} else {
+		  chan configure $channel -encoding $coding
+		}
+		if {$eol eq {}} {
+		  chan configure $channel {*}[textEOL translation]
+		} else {
+		  chan configure $channel -translation $eol
+		}
+	}
+
+# ________________________ textEOL _________________________ #
+
+
+	proc textEOL {{EOL "-"}} {
+		# Gets/sets End-of-Line for text reqding/writing.
+		#   EOL - LF, CR, CRLF or {}
+		# If EOL omitted or equals to {} or "-", return the current EOL.
+		# If EOL equals to "translation", return -translation option or {}.
+
+		variable _PU_opts
+		if {$EOL eq "-"} {return $_PU_opts(_EOL_)}
+		if {$EOL eq "translation"} {
+		  if {$_PU_opts(_EOL_) eq ""} {return ""}
+		  return "-translation $_PU_opts(_EOL_)"
+		}
+		set _PU_opts(_EOL_) [string trim [string tolower $EOL]]
+	}
+
+# ________________________ TreSelect _________________________ #
+
+
+	proc TreSelect {w idx} {
+		# Selects a treeview item.
+		#   w - treeview's path
+		#   idx - item index
+
+		set items [$w children {}]
+		catch {
+		  set it [lindex $items $idx]
+		  $w see $it
+		  $w focus $it
+		  $w selection set $it  ;# generates <<TreeviewSelect>>
+		}
+	}
+
+# ________________________ varName _________________________ #
+
+
+  proc varName {wname} {
+    # Gets a variable name associated with a widget's name of "input" dialogue.
+    #   wname - widget's name
+
+    return [namespace current]::var$wname
+  }
+	
+# ________________________ waitWinVar _________________________ #
+
+
+	proc waitWinVar {win var modal} {
+		# Tk waiting for variable's change.
+		#   win - the window's path
+		#   var - variable's name to receive a result (tkwait's variable)
+		#   modal - yes at showing the window as modal
+
+		# first of all, wait till the window be visible
+		after 1 ;# solves an issue with doubleclicking buttons
+		if {![winfo viewable $win]} {
+		  tkwait visibility $win
+		}
+		set wmain [winfo parent $win]
+		if {$modal} {      ;# for modal, grab the window
+		  set wgr [grab current]
+		  if {$wmain ne {} && $wmain ne $win} {
+		    if {[catch {grab set $win} e]} {
+		      catch {tkwait visibility $win}  ;# 2nd attempt to get the window visible, by force
+		      catch {grab set $win}           ;# (not sure, where it can fire, still let it be)
+		      puts stderr "\n::radxide::win::waitWinVar - please send a note to apave developers on this catch. Error: $e"
+		      catch {puts stderr "::radxide::win::waitWinVar - [info level -1]\n"}
+		    }
+		  }
+		}
+		# at need, wait till the window associated variable be changed
+		if {$var ne {}} {
+		  tkwait variable $var
+		}
+		if {$modal} {      ;# for modal, release the grab and restore the old one
+		  catch {grab release $win}
+		  if {$wgr ne {}} {
+		    catch {grab set $wgr}
+		  }
+		}
+	}
+
+# ________________________ widgetType _________________________ #
+
+
+  proc widgetType {wnamefull options attrs} {
+    # Gets the widget type based on 3 initial letters of its name. Also
+    # fills the grid/pack options and attributes of the widget.
+    #   wnamefull - path to the widget
+    #   options - grid/pack options of the widget
+    #   attrs - attribute of the widget
+    # Returns a list of items:
+    #   widget - Tk/Ttk widget name
+    #   options - grid/pack options of the widget
+    #   attrs - attribute of the widget
+    #   nam3 - 3 initial letters of widget's name
+    #   disabled - flag of *disabled* state
+
+    set disabled [expr {[getOption -state {*}$attrs] eq {disabled}}]
+    set pack $options
+    set name [ownWName $wnamefull]
+    #if {[info exists ::apave::_AP_VARS(ProSplash,type)] && \
+    #$::apave::_AP_VARS(ProSplash,type) eq {}} {
+    #  set val [my progress_Go [incr ::apave::_AP_VARS(ProSplash,curvalue)] {} $name]
+    #}
+    set nam3 [string tolower [string index $name 0]][string range $name 1 2]
+    if {[string index $nam3 1] eq "_"} {set k [string range $nam3 0 1]} {set k $nam3}
+    lassign [defaultATTRS $k] defopts defattrs newtype
+    set options "$defopts $options"
+    set attrs "$defattrs $attrs"
+    switch -glob -- $nam3 {
+      #bts {
+      #  set widget ttk::frame
+      #  if {![info exists ::bartabs::NewBarID]} {package require bartabs}
+      #  set attrs "-bartabs {$attrs}"
+      #}
+      but {
+        set widget ttk::button
+        AddButtonIcon $name attrs
+      }
+      buT - btT {
+        set widget button
+        AddButtonIcon $name attrs
+      }
+      can {set widget canvas}
+      chb {set widget ttk::checkbutton}
+      swi {
+        set widget ttk::checkbutton
+        #if {![my apaveTheme]} {
+        #  set attrs "$attrs -style Switch.TCheckbutton"
+        #}
+      }
+      chB {set widget checkbutton}
+      cbx - fco {
+        set widget ttk::combobox
+        if {$nam3 eq {fco}} {  ;# file content combobox
+          set attrs [FCfieldValues $wnamefull $attrs]
+        }
+        set attrs [FCfieldAttrs $wnamefull $attrs -tvar]
+      }
+      ent {set widget ttk::entry}
+      enT {set widget entry}
+      fil - fiL -
+      fis - fiS -
+      dir - diR -
+      fon - foN -
+      clr - clR -
+      dat - daT -
+      sta -
+      too -
+      fra {
+        # + frame for choosers and bars
+        set widget ttk::frame
+      }
+      frA {
+        set widget frame
+        if {$disabled} {set attrs [removeOptions $attrs -state]}
+      }
+      ftx {set widget ttk::labelframe}
+      gut {set widget canvas}
+      lab {
+        set widget ttk::label
+        if {$disabled} {
+          set grey lightgray
+          set attrs "-foreground $grey $attrs"
+        }
+        lassign [parseOptions $attrs -link {} -style {} -font {}] \
+          cmd style font
+        if {$cmd ne {}} {
+          set attrs "-linkcom {$cmd} $attrs"
+          set attrs [removeOptions $attrs -link]
+        }
+        if {$style eq {} && $font eq {}} {
+          set attrs "-font {$::radxide::dan(CHARFAMILY)} $attrs"
+        } elseif {$style ne {}} {
+          # some themes stumble at ttk styles, so bring their attrs directly
+          set attrs [removeOptions $attrs -style]
+          set attrs "[ttk::style configure $style] $attrs"
+        }
+      }
+      laB {set widget label}
+      lfr {set widget ttk::labelframe}
+      lfR {
+        set widget labelframe
+        if {$disabled} {set attrs [removeOptions $attrs -state]}
+      }
+      lbx - flb {
+        set widget listbox
+        if {$nam3 eq {flb}} {  ;# file content listbox
+          set attrs [FCfieldValues $wnamefull $attrs]
+        }
+        set attrs "[FCfieldAttrs $wnamefull $attrs -lvar]"
+        set attrs "[ListboxesAttrs $wnamefull $attrs]"
+        AddPopupAttr $wnamefull attrs -entrypop 1
+        foreach {ev com} {Home {LbxSelect %w 0} End {LbxSelect %w end}} {
+          append attrs " -bindEC {<$ev> {$com}} "
+        }
+      }
+      meb {set widget ttk::menubutton}
+      meB {set widget menubutton}
+      nbk {
+        set widget ttk::notebook
+        set attrs "-notebazook {$attrs}"
+      }
+      opc {
+        # tk_optionCascade - example of "my method" widget
+        # arguments: vname items mbopts precom args
+        #set widget {tk_optionCascade}
+        #set imax [expr {min(4,[llength $attrs])}]
+        #for {set i 0} {$i<$imax} {incr i} {
+        #  set atr [lindex $attrs $i]
+        #  if {$i!=1} {
+        #    lset attrs $i \{$atr\}
+        #  } elseif {[llength $atr]==1 && [info exist $atr]} {
+        #    lset attrs $i [set $atr]  ;# items stored in a variable
+        #  }
+        #}
+      }
+      pan {set widget ttk::panedwindow
+        if {[string first -w $attrs]>-1 && [string first -h $attrs]>-1} {
+          # important for panes with fixed (customized) dimensions
+          set attrs "-propagate {$options} $attrs"
+        }
+      }
+      pro {set widget ttk::progressbar}
+      rad {set widget ttk::radiobutton}
+      raD {set widget radiobutton}
+      sca {set widget ttk::scale}
+      scA {set widget scale}
+      sbh {set widget ttk::scrollbar}
+      sbH {set widget scrollbar}
+      sbv {set widget ttk::scrollbar}
+      sbV {set widget scrollbar}
+      scf {
+      #  if {![namespace exists ::apave::sframe]} {
+      #    namespace eval ::apave {
+      #      source [file join $::apave::apaveDir sframe.tcl]
+      #    }
+      #  }
+      #  # scrolledFrame - example of "my method" widget
+      #  set widget {my scrolledFrame}
+      }
+      seh {set widget ttk::separator}
+      sev {set widget ttk::separator}
+      siz {set widget ttk::sizegrip}
+      spx - spX {
+        if {$nam3 eq {spx}} {set widget ttk::spinbox} {set widget spinbox}
+        lassign [::apave::parseOptions $attrs \
+          -command {} -com {} -from {} -to {}] cmd cmd2 from to
+        append cmd $cmd2
+        lassign [::apave::extractOptions attrs -tip {} -tooltip {}] t1 t2
+        set t2 "$t1$t2"
+        if {$from ne {} || $to ne {}} {
+          if {$t2 ne {}} {set t2 "\n $t2"}
+          set t2 " $from .. $to $t2"
+        }
+        if {$t2 ne {}} {set t2 "-tip {$t2}"}
+        append attrs " -onReturn {$UFF{$cmd} {$from} {$to}$UFF} $t2"
+      }
+      tbl { ;# tablelist
+        package require tablelist
+        set widget tablelist::tablelist
+        set attrs "[FCfieldAttrs $wnamefull $attrs -lvar]"
+        set attrs "[ListboxesAttrs $wnamefull $attrs]"
+      }
+      tex {set widget text
+        if {[getOption -textpop {*}$attrs] eq {}} {
+          AddPopupAttr $wnamefull attrs -textpop \
+            [expr {[getOption -rotext {*}$attrs] ne {}}] -- disabled
+        }
+        lassign [parseOptions $attrs -ro {} -readonly {} -rotext {} \
+          -gutter {} -gutterwidth 5 -guttershift 6] r1 r2 r3 g1 g2 g3
+        set b1 [expr [string is boolean -strict $r1]]
+        set b2 [expr [string is boolean -strict $r2]]
+        if {($b1 && $r1) || ($b2 && $r2) || \
+        ($r3 ne {} && !($b1 && !$r1) && !($b2 && !$r2))} {
+          set attrs "-takefocus 0 $attrs"
+        }
+        set attrs [removeOptions $attrs -gutter -gutterwidth -guttershift]
+        if {$g1 ne {}} {
+          set attrs "$attrs -gutter {-canvas $g1 -width $g2 -shift $g3}"
+        }
+      }
+      tre {
+        set widget ttk::treeview
+        foreach {ev com} {Home {TreSelect %w 0} End {TreSelect %w end}} {
+          append attrs " -bindEC {<$ev> {$com}} "
+        }
+      }
+      h_* {set widget ttk::frame}
+      v_* {set widget ttk::frame}
+      default {set widget $newtype}
+    }
+    #set attrs [GetMC $attrs]
+    if {$nam3 in {cbx ent enT fco spx spX}} {
+      # entry-like widgets need their popup menu
+      set clearcom [lindex [parseOptions $attrs -clearcom -] 0]
+      if {$clearcom eq {-}} {
+        AddPopupAttr $wnamefull attrs -entrypop 0 readonly disabled
+      }
+    }
+    if {[string first pack [string trimleft $pack]]==0} {
+      catch {
+        # try to expand -after option (if set as WidgetName instead widgetName)
+        if {[set i [lsearch -exact $pack {-after}]]>=0} {
+          set aft [lindex $pack [incr i]]
+          if {[regexp {^[A-Z]} $aft]} {
+            set aft [my $aft]
+            set pack [lreplace $pack $i $i $aft]
+          }
+        }
+      }
+      set options $pack
+    }
+    set options [string trim $options]
+    set attrs   [list {*}$attrs]
+    return [list $widget $options $attrs $nam3 $disabled]
+  }
+
+
+# ________________________ WidgetNameFull _________________________ #
+
+
+  proc WidgetNameFull {w name {an {}}} {
+    # Gets a full name of a widget.
+    #   w - name of root widget
+    #   name - name of widget
+    #   an - additional prefix for name
+    # See also: apave::sframe::content
+
+    set wn [string trim [parentWName $name].$an[ownWName $name] .]
+    set wnamefull $w.$wn
+    set wcc canvas.container.content ;# sframe.tcl may be not sourced
+    if {[set i1 [string first .scf $wnamefull]]>0 && \
+    [set i2 [string first . $wnamefull $i1+1]]>0 && \
+    [string first .$wcc. $wnamefull]<0} {
+      # insert a container's name into a scrolled frame's child
+      set wend [string range $wnamefull $i2 end]
+      set wnamefull [string range $wnamefull 0 $i2]
+      append wnamefull $wcc $wend
+    }
+    return $wnamefull
+  }
+
+# ________________________ Window _________________________ #
+
+  proc Window {w inplists} {
+    # Paves the window with widgets.
+    #   w - window's name (path)
+    #   inplists - list of widget items (lists of widget data)
+    # Contents of a widget's item:
+    #   name - widget's name (first 3 characters define its type)
+    #   neighbor - top (T) or left (L) neighbor of the widget
+    #   posofnei - position of neighbor: T (top) or L (left)
+    #   rowspan - row span of the widget
+    #   colspan - column span of the widget
+    #   options - grid/pack options
+    #   attrs - attributes of widget
+    # First 3 items are mandatory, others are set at need.
+    # Called by *paveWindow* method to process a portion of widgets.
+    # The "portion" refers to a separate block of widgets such as
+    # notebook's tabs or frames.
+
+    namespace upvar ::radxide dan dan 
+
+    #tk_messageBox -title $dan(TITLE) -icon info -message "Start Window!"
+
+    set lwidgets [list]
+    # comments be skipped
+    foreach lst $inplists {
+      if {[string index $lst 0] ne {#}} {
+        lappend lwidgets $lst
+      }
+    }
+    set lused [list]
+    set lwlen [llength $lwidgets]
+    if {$lwlen<2 && [string trim $lwidgets "{} "] eq {}} {
+      set lwidgets [list {fra - - - - {pack -padx 99 -pady 99}}]
+      set lwlen 1
+    }
+    for {set i 0} {$i < $lwlen} {} {
+      set lst1 [lindex $lwidgets $i]
+      if {[Replace_Tcl i lwlen lwidgets {*}$lst1] ne {}} {incr i}
+    }
+    # firstly, normalize all names that are "subwidgets" (.lab for fra.lab)
+    # also, "+" for previous neighbors
+    set i [set lwlen [llength $lwidgets]]
+    while {$i>1} {
+      incr i -1
+      set lst1 [lindex $lwidgets $i]
+      lassign $lst1 name neighbor
+      if {$neighbor eq {+}} {set neighbor [lindex $lwidgets $i-1 0]}
+      lassign [NormalizeName name i lwidgets] name wname
+      set neighbor [lindex [NormalizeName neighbor i lwidgets] 0]
+      set lst1 [lreplace $lst1 0 1 $wname $neighbor]
+      set lwidgets [lreplace $lwidgets $i $i $lst1]
+    }
+    for {set i 0} {$i < $lwlen} {} {
+      # List of widgets contains data per widget:
+      #   widget's name,
+      #   neighbor widget, position of neighbor (T, L),
+      #   widget's rowspan and columnspan (both optional),
+      #   grid options, widget's attributes (both optional)
+      set lst1 [lindex $lwidgets $i]
+      #set lst1 [my Replace_chooser w i lwlen lwidgets {*}$lst1]
+      #if {[set lst1 [my Replace_bar w i lwlen lwidgets {*}$lst1]] eq {}} {
+      #  incr i
+      #  continue
+      #}
+      lassign $lst1 name neighbor posofnei rowspan colspan options1 attrs1
+      lassign [NormalizeName name i lwidgets] name wname
+      set wname [MakeWidgetName $w $wname]
+      if {$colspan eq {} || $colspan eq {-}} {
+        set colspan 1
+        if {$rowspan eq {} || $rowspan eq {-}} {
+          set rowspan 1
+        }
+      }
+      foreach ao {attrs options} {
+        if {[catch {set $ao [uplevel 2 subst -nocommand -nobackslashes [list [set ${ao}1]]]}]} {
+          set $ao [set ${ao}1]
+        }
+      }
+      lassign [widgetType $wname $options $attrs] widget options attrs nam3 dsbl
+      # The type of widget (if defined) means its creation
+      # (if not defined, it was created after "makewindow" call
+      # and before "window" call)
+      if { !($widget eq {} || [winfo exists $widget])} {
+        set attrs [GetAttrs $attrs $nam3 $dsbl]
+        set attrs [ExpandOptions $attrs]
+        # for scrollbars - set up the scrolling commands
+        if {$widget in {ttk::scrollbar scrollbar}} {
+          set neighbor [lindex [LowercaseWidgetName $neighbor] 0]
+          set wneigb [WidgetNameFull $w $neighbor]
+          if {$posofnei eq {L}} {
+            $wneigb config -yscrollcommand "$wname set"
+            set attrs "$attrs -com \\\{$wneigb yview\\\}"
+            append options { -side right -fill y} ;# -after $wneigb"
+          } elseif {$posofnei eq {T}} {
+            $wneigb config -xscrollcommand "$wname set"
+            set attrs "$attrs -com \\\{$wneigb xview\\\}"
+            append options { -side bottom -fill x} ;# -before $wneigb"
+          }
+          set options [string map [list %w $wneigb] $options]
+        }
+        #% doctest 1
+        #%   set a "123 \\\\\\\\ 45"
+        #%   eval append b {*}$a
+        #%   set b
+        #>   123\45
+        #> doctest
+        Pre attrs
+        #set addcomms [my AdditionalCommands $w $wname attrs]
+        eval $widget $wname {*}$attrs
+        #my Post $wname $attrs
+        #foreach acm $addcomms {{*}$acm}
+        # for buttons and entries - set up the hotkeys (Up/Down etc.)
+        #my DefineWidgetKeys $wname $widget
+      }
+      if {$neighbor eq {-} || $row < 0} {
+        set row [set col 0]
+      }
+      # check for simple creation of widget (without pack/grid)
+      if {$neighbor ne {#}} {
+        set options [GetIntOptions $w $options $row $rowspan $col $colspan]
+        set pack [string trim $options]
+        if {[string first add $pack]==0} {
+          set comm "[winfo parent $wname] add $wname [string range $pack 4 end]"
+          {*}$comm
+        } elseif {[string first pack $pack]==0} {
+          set opts [string trim [string range $pack 5 end]]
+          if {[string first forget $opts]==0} {
+            pack forget {*}[string range $opts 6 end]
+          } else {
+            pack $wname {*}$opts
+          }
+        } else {
+          grid $wname -row $row -column $col -rowspan $rowspan \
+             -columnspan $colspan -padx 1 -pady 1 {*}$options
+        }
+      }
+      lappend lused [list $name $row $col $rowspan $colspan]
+      if {[incr i] < $lwlen} {
+        lassign [lindex $lwidgets $i] name neighbor posofnei
+        set neighbor [lindex [LowercaseWidgetName $neighbor] 0]
+        set row -1
+        foreach cell $lused {
+          lassign $cell uname urow ucol urowspan ucolspan
+          if {[lindex [LowercaseWidgetName $uname] 0] eq $neighbor} {
+            set col $ucol
+            set row $urow
+            if {$posofnei eq {T} || $posofnei eq {}} {
+              incr row $urowspan
+            } elseif {$posofnei eq {L}} {
+              incr col $ucolspan
+            }
+          }
+        }
+      }
+    }
+    return $lwidgets
+  }
+
+# ________________________ WindowStatus _________________________ #
+
+
+  proc WindowStatus {w name {val ""} {defval ""}} {
+    # Sets/gets a status of window. The status is a value assigned to a name.
+    #   w - window's path
+    #   name - name of status
+    #   val - if blank, to get a value of status; otherwise a value to set
+    #   defval - default value (actual if the status not set beforehand)
+    # Returns a value of status.
+    # See also: IntStatus
+
+    variable _AP_VARS
+    if {$val eq {}} {  ;# getting
+      if {[info exist _AP_VARS($w,$name)]} {
+        return $_AP_VARS($w,$name)
+      }
+      return $defval
+    }
+    return [set _AP_VARS($w,$name) $val]  ;# setting
+  }
+
+# ________________________ WinResize _________________________ #
+
+
+  proc WinResize {win} {
+    # Restricts the window's sizes (thus fixing Tk's issue with a menubar)
+    #   win - path to a window to be of restricted sizes
+
+    if {[$win cget -menu] ne {}} {
+      lassign [splitGeometry [wm geometry $win]] w h
+      lassign [wm minsize $win] wmin hmin
+      if {$w<$wmin && $h<$hmin} {
+        set corrgeom ${wmin}x$hmin
+      } elseif {$w<$wmin} {
+        set corrgeom ${wmin}x$h
+      } elseif {$h<$hmin} {
+        set corrgeom ${w}x$hmin
+      } else {
+        return
+      }
+      wm geometry $win $corrgeom
+    }
+    return
+ }
+
+# ________________________ WinVarname _________________________ #
+
+
+  proc WinVarname {win} {
+    # Gets a unique varname for a window.
+    #   win - window's path
+
+    return [namespace current]::PV(_WIN_,$win)
+  }
+
+# ________________________ withdraw _________________________ #
+
+
+	proc withdraw {w} {
+		# Does 'withdraw' for a window.
+		#   w - the window's path
+		# See also: iconifyOption
+
+		switch -- [iconifyOption] {
+		  none {          ; # no withdraw/deiconify actions
+		  }
+		  Linux {         ; # do it for Linux
+		    wm withdraw $w
+		  }
+		  Windows {       ; # do it for Windows
+		    wm withdraw $w
+		    wm attributes $w -alpha 0.0
+		  }
+		  default {       ; # do it depending on the platform
+		    wm withdraw $w
+		    if {[::radxide::iswindows]} {
+		      wm attributes $w -alpha 0.0
+		    }
+		  }
+		}
+	}
+
+# ________________________ #
+
+}
+