Explorar el Código

Add files via upload

Capitan Cloud hace 1 año
padre
commit
1e0f6b5e60
Se han modificado 7 ficheros con 234 adiciones y 22 borrados
  1. 32 3
      filelib.tcl
  2. BIN
      icons/file-html.png
  3. BIN
      icons/file-js.png
  4. 13 4
      radxide.tcl
  5. BIN
      res/screenshot1.png
  6. 108 12
      tree.tcl
  7. 81 3
      win.tcl

+ 32 - 3
filelib.tcl

@@ -37,9 +37,7 @@ namespace eval filelib {
 		
 		if {$destfolder ne ""} {
 		
-		  #tk_messageBox -title $dan(TITLE) -icon error -message "Yess!"
-		
-		  set num 1
+  	  set num 1
 		  while {[file exists $destfolder/$n$num]} {  
 		    incr num
 		  }
@@ -55,6 +53,37 @@ namespace eval filelib {
 		}
 	}
 
+
+# __________________________ createFile _________________________ #
+
+
+	proc createFolder {{parentfolder ""}} {
+		# Create a file.
+		#   fname - file name
+		#   stxt - text to save
+
+		namespace upvar ::radxide dan dan project project
+		
+		set n "newfolder"
+		
+		#tk_messageBox -title $dan(TITLE) -icon error -message $parentfolder
+		
+		if {$parentfolder ne ""} {
+		
+		  set num 1
+		  while {[file exists $parentfolder/$n$num]} {  
+		    incr num
+		  }
+
+		  #tk_messageBox -title $dan(TITLE) -icon error -message $parentfolder/$n$num	
+		  
+		  set fname $parentfolder/$n$num
+		
+      file mkdir $fname 
+		  
+		}
+	}
+
 # __________________________ delFile _________________________ #
 
 

BIN
icons/file-html.png


BIN
icons/file-js.png


+ 13 - 4
radxide.tcl

@@ -131,12 +131,18 @@ namespace eval radxide {
   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(HTML-ICON) "icons/file-html.png"
+  set icons(HTML-ICONI) [image create photo imgobj5 -file $icons(HTML-ICON)]
+  set icons(JS-ICON) "icons/file-js.png"
+  set icons(JS-ICONI) [image create photo imgobj6 -file $icons(JS-ICON)]  
   set icons(PHP-ICON) "icons/file-php.png"
-  set icons(PHP-ICONI) [image create photo imgobj5 -file $icons(PHP-ICON)]
+  set icons(PHP-ICONI) [image create photo imgobj7 -file $icons(PHP-ICON)]
+  set icons(TXT-ICON) "icons/file-txt.png"
+  set icons(TXT-ICONI) [image create photo imgobj8 -file $icons(TXT-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(GENERIC-FILE-ICONI) [image create photo imgobj9 -file $icons(GENERIC-FILE-ICON)]
   set icons(FOLDER-ICON) "icons/folder.png"
-  set icons(FOLDER-ICONI) [image create photo imgobj7 -file $icons(FOLDER-ICON)]
+  set icons(FOLDER-ICONI) [image create photo imgobj10 -file $icons(FOLDER-ICON)]
   
   # Menu variables
   set menu(ROOT) "";
@@ -150,7 +156,10 @@ namespace eval radxide {
   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
+  set dan(PhpExts) {.php .php2 .php3 .php4 .php5 .funny}     ;# extensions of php files
+  set dan(HtmlExts) {.html .htm}                             ;# extensions of html files
+  set dan(JsExts) {.js}                                      ;# extensions of js files
+  set dan(TxtExts) {.txt .rtf}                               ;# extensions of txt files
      
 # __________________ iswindows ___________________ #
 

BIN
res/screenshot1.png


+ 108 - 12
tree.tcl

@@ -20,12 +20,12 @@
 
 namespace eval tree {
 
-# ________________________ AddItem _________________________ #
+# ________________________ addFile _________________________ #
 
 
 	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).
+		#   ID - an item's ID where the new file will be added (for the file tree).
 
 		namespace upvar ::radxide dan dan
 
@@ -46,6 +46,33 @@ namespace eval tree {
 
 	}
 
+# ________________________ addFolder _________________________ #
+
+
+	proc addFolder {{ID ""}} {
+		# Adds a new item to the tree.
+		#   ID - an item's ID where the new folder will be added (for the file tree).
+
+		namespace upvar ::radxide dan dan
+
+    set tree $dan(TREEVIEW)
+    lassign [$tree item $ID -values] -> fname isfile
+    set parentfolder $fname
+    
+    if {!$isfile} {
+    
+      #tk_messageBox -title $dan(TITLE) -icon error -message $parentfolder
+        
+      ::radxide::filelib::createFolder $parentfolder
+      
+      # Refreshing TreeView
+      ::radxide::tree::create
+      
+    }  
+
+	}
+
+
 # ________________________ addTags _________________________ #
 
 
@@ -266,8 +293,14 @@ namespace eval tree {
 		      continue
 		    } 
 		  
-		    if {[isPhp $fname]} {
+		    if {[isHtml $fname]} {
+		      set imgopt $icons(HTML-ICONI)
+		    } elseif {[isJs $fname]} {
+		      set imgopt $icons(JS-ICONI)		      
+		    } elseif {[isPhp $fname]} {
 		      set imgopt $icons(PHP-ICONI)
+		    } elseif {[isTxt $fname]} {
+		      set imgopt $icons(TXT-ICONI)		      		      
 		    } else {
 		      set imgopt $icons(GENERIC-FILE-ICONI)
 		    }
@@ -496,6 +529,30 @@ namespace eval tree {
 		return [expr {[lsearch -exact $dan(_dirignore) $dir]>-1}]
 	}
 
+# ________________________ isHtml _________________________ #
+
+	proc isHtml {fname} {
+		# Checks if a file is of Html.
+		#   fname - file name
+
+		if {[string tolower [file extension $fname]] in $radxide::dan(HtmlExts)} {
+		  return yes
+		}
+		return no
+	}
+
+# ________________________ isJs _________________________ #
+
+	proc isJs {fname} {
+		# Checks if a file is of JS.
+		#   fname - file name
+
+		if {[string tolower [file extension $fname]] in $radxide::dan(JsExts)} {
+		  return yes
+		}
+		return no
+	}
+
 # ________________________ isPhp _________________________ #
 
 	proc isPhp {fname} {
@@ -508,6 +565,18 @@ namespace eval tree {
 		return no
 	}
 
+# ________________________ isTxt _________________________ #
+
+	proc isTxt {fname} {
+		# Checks if a file is of Txt.
+		#   fname - file name
+
+		if {[string tolower [file extension $fname]] in $radxide::dan(TxtExts)} {
+		  return yes
+		}
+		return no
+	}
+
 # ________________________ newItemID _________________________ #
 
 	proc newItemID {iit} {
@@ -637,10 +706,35 @@ namespace eval tree {
       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
-  
   }
+  
+# ________________________ renameFolder _________________________ #
+
+
+  proc renameFolder {{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::renameFolderOK butCANCEL CANCEL ::radxide::win::renameFolderCancel}"
+       
+    catch {lassign [::radxide::win::input "RenameFolder" {} "Rename folder" [list \
+      ent "{} {} {-w 64}" "{$fname}"] \
+      -head "Folder name:" {*}$args] res}
+  
+  }  
 
 # ________________________ showPopupMenu _________________________ #
 
@@ -665,10 +759,11 @@ namespace eval tree {
 		
 		set m1 "Refresh project"
 		set m2 "Add file"
+		set m2f "Add folder"
 		set m3 "Rename file"
 		set m4 "Delete file"
-		set m3b "Rename folder"
-		set m4b "Delete folder"
+		set m3f "Rename folder"
+		set m4f "Delete folder"
 		set m5 "Open file" 
 		set m6 "Open dir"  
 		
@@ -683,12 +778,13 @@ namespace eval tree {
   		$popm add command -label $m3 -command "::radxide::tree::renameFile $ID"
 	  	$popm add command -label $m4 -command "::radxide::tree::deleteFile $ID" 
 	  } else {
+	    $popm add command -label $m2f -command "::radxide::tree::addFolder $ID"
   		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
+	  		$popm add command -label $m3f -command "::radxide::tree::renameFolder $ID" -state disabled
+  	  	$popm add command -label $m4f -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 command -label $m3f -command "::radxide::tree::renameFolder $ID" -state normal
+  	  	$popm add command -label $m4f -command "::radxide::tree::delFolder $ID" -state disabled
       }  	  	
 	  }	
 		$popm add separator

+ 81 - 3
win.tcl

@@ -133,7 +133,7 @@ namespace eval win {
     set com [getOption -com {*}$attrs]
     if {[string is integer -strict $com]} {
       extractOptions attrs -com {}
-      append attrs " -com {[self] res {} $com}" ;# returned integer result
+      append attrs " -com {::radxide::win::res {} $com}" ;# returned integer result
     }
     if {[getOption -image {*}$attrs] ne {}} return
     set txt [getOption -t {*}$attrs]
@@ -2512,7 +2512,7 @@ namespace eval win {
     # add the buttons
     
     # xxx
-    if {$dlgname eq "RenameFile" || $dlgname eq "Find"} {
+    if {$dlgname eq "RenameFile" || $dlgname eq "RenameFolder" || $dlgname eq "Find"} {
       set buttons [string map {"butOK OK 1" "" "butCANCEL Cancel destroy" ""} $buttons]
     }
     lassign [AppendButtons widlist $buttons h__ L $defb $timeout $qdlg $modal] \
@@ -2753,7 +2753,7 @@ namespace eval win {
 			return 0 
     }
     
-	  # savind {field oldval newval} for later use
+	  # saving {field oldval newval} for later use
 	  editDialogField end $varname $oldpath $newpath
 
     ::radxide::tree::create
@@ -2779,6 +2779,84 @@ namespace eval win {
     return 0
   }
 
+# ________________________ renameFolderOK _________________________ #
+
+
+  proc renameFolderOK {} {
+  
+    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 oldparent [string range $oldpath 0 [expr [string last "/" $oldpath]-1]]
+    #tk_messageBox -title $dan(TITLE) -icon info -message oldparent=$oldparent
+    set newparent [string range $newpath 0 [expr [string last "/" $newpath]-1]]
+    #tk_messageBox -title $dan(TITLE) -icon info -message newparent=$newparent
+    
+    set pathlength [expr [string length $newpath]-1] 
+    if {[string range $newpath $pathlength $pathlength] eq "/"} {
+      tk_messageBox -title $dan(TITLE) -icon info -message "Please delete the final '\/'!"
+      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 {$oldparent ne $newparent} {
+      tk_messageBox -title $dan(TITLE) -icon info -message "Change of parent folder disallowed!"
+      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
+  }
+
+# ________________________ renameFolderCancel _________________________ #
+
+
+  proc renameFolderCancel {} {
+  
+    #catch {[destroy .danwin.diaRenameFolder1]}    
+    catch {[destroy [dlgPath]]}
+        
+    return 0
+  }
+
 
 
 # ________________________ Replace_Tcl _________________________ #