radxide.tcl 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #! /usr/bin/env tclsh
  2. ###########################################################
  3. # Name: radxide.tcl
  4. # Author: Daniele Bonini (posta@elettronica.lol)
  5. # Date: 05/12/2023
  6. # Desc: Starting file of RadXIDE.
  7. #
  8. # Starting file and most of code
  9. # here presented and distributed contain excerpts
  10. # from [alited](https://github.com/aplsimple/alited
  11. # by Alex Plotnikov and contributors to the project.
  12. # The original code of these excerpts could be
  13. # borrowed from other sources which the author
  14. # and the contributors to this RadXIDE have no
  15. # knowledge about.
  16. #
  17. # Code Library scaffolding and most of its code
  18. # from "Practical Programming in Tcl and Tk, 4th Ed."
  19. # by Brent B. Welch, Ken Jones, Jeffrey Hebbs.
  20. # The original code of these excerpts could be
  21. # borrowed from other sources which the author
  22. # and the contributors to RadXIDE have no
  23. # knowledge about. For the related copyright notice
  24. # refer <eglib.tcl> part of this software.
  25. #
  26. # License: MIT. Copyrights 5 Mode (Last implementation and adaptations.)
  27. # Copyright (c) 2021-2023 Alex Plotnikov https://aplsimple.github.io (original scaffolding and excerpts.)
  28. #
  29. ###########################################################
  30. package provide radxide 1.0.6
  31. set _ [package require Tk]
  32. wm withdraw .
  33. if {![package vsatisfies $_ 8.6.10-]} {
  34. tk_messageBox -message "\nradxide needs Tcl/Tk v8.6.10+ \
  35. \n\nwhile the current is v$_\n"
  36. exit
  37. }
  38. unset -nocomplain _
  39. # __________________________ radxide:: Main _________________________ #
  40. namespace eval radxide {
  41. variable dan; array set dan [list]
  42. variable tcltk_version "Tcl/Tk [package versions Tk]"
  43. ## ________________________ Main variables _________________________ ##
  44. set DEBUG no ;# debug mode
  45. set dan(WIN) .danwin ;# main form
  46. set dan(WORKDIR) "/home/YourUser/.radxwork" ;# root working dir
  47. set dan(TITLE) RADXIDE
  48. # Check workdir existance..
  49. if {![file exists $dan(WORKDIR)]} {
  50. file mkdir $dan(WORKDIR)
  51. }
  52. # Check Code Library dir existance.. (WORKDIR)/.examples)
  53. if {![file exists $dan(WORKDIR)/.examples]} {
  54. file mkdir $dan(WORKDIR)/.examples
  55. }
  56. set dan(TREEVIEW) "" ;# ide project tree
  57. set dan(GUTTEXT) "" ;# ide guttext control
  58. set dan(TEXT) "" ;# ide text control
  59. set dan(prjdirignore) {.git .bak} ;# ignored subdirectories of project
  60. set project(NAME) "" ;# project default name
  61. set project(ROOT) "" ;# project default root
  62. set project(PATH) "" ;# project default path
  63. set project(CUR_FILE_PATH) "" ;# project current file path
  64. set project(TREE_PROJECT_ROOT) "" ;# Treeview: Project root node
  65. set project(TREE_PRIVATE_ROOT) "" ;# Treeview: Private node
  66. set project(TREE_PUBLIC_ROOT) "" ;# Treeview: Public node
  67. set files(FILE1) "" ;# Array files
  68. set files(FILE2) ""
  69. set files(FILE3) ""
  70. set files(FILE4) ""
  71. set files(FILE5) ""
  72. # main data of radxide (others are in ini.tcl)
  73. variable SCRIPT [info script]
  74. variable SCRIPTNORMAL [file normalize $SCRIPT]
  75. variable FILEDIR [file dirname $SCRIPTNORMAL]
  76. variable DIR [file dirname $FILEDIR]
  77. # directories of sources
  78. variable SRCDIR [file join $DIR src]
  79. variable LIBDIR [file join $DIR lib]
  80. # misc. vars
  81. variable pID 0
  82. # directory tree's content
  83. variable _dirtree [list]
  84. set dan(TITLE_TEMPL) {%f :: %t} ;# radxide title's template
  85. set dan(WIDTH) 1280
  86. set dan(HEIGHT) 760
  87. #set al(MOVEFG) "black"
  88. #set al(MOVEBG) "#7eeeee"
  89. set dan(FG) "#000000"
  90. set dan(BG) "#cecece"
  91. set dan(fgred) "red"
  92. set dan(fgbold) "magenta"
  93. set dan(fgtodo) "orange"
  94. set dan(fgbranch) "blue"
  95. set dan(CHARFAMILY) "Sans"
  96. set dan(CHARSIZE) 10
  97. set dan(MAXFILES) 250
  98. set dan(MAXFILESIZE) 65534
  99. set dan(MAXFINDLENGTH) 50
  100. # icons
  101. set dan(ICON) "icons/radxide.png"
  102. set dan(ICONI) [image create photo imgobj1 -file $dan(ICON)]
  103. set icons(PROJECT-ICON) "icons/archive.png"
  104. set icons(PROJECT-ICONI) [image create photo imgobj2 -file $icons(PROJECT-ICON)]
  105. set icons(PUBLICF-ICON) "icons/public-folder.png"
  106. set icons(PUBLICF-ICONI) [image create photo imgobj3 -file $icons(PUBLICF-ICON)]
  107. set icons(PRIVATEF-ICON) "icons/private-folder.png"
  108. set icons(PRIVATEF-ICONI) [image create photo imgobj4 -file $icons(PRIVATEF-ICON)]
  109. set icons(PHP-ICON) "icons/file-php.png"
  110. set icons(PHP-ICONI) [image create photo imgobj5 -file $icons(PHP-ICON)]
  111. set icons(GENERIC-FILE-ICON) "icons/file-generic.png"
  112. set icons(GENERIC-FILE-ICONI) [image create photo imgobj6 -file $icons(GENERIC-FILE-ICON)]
  113. set icons(FOLDER-ICON) "icons/folder.png"
  114. set icons(FOLDER-ICONI) [image create photo imgobj7 -file $icons(FOLDER-ICON)]
  115. # Menu variables
  116. set menu(ROOT) "";
  117. set menu(ADD_FILE_ENTRY_IDX) 2;
  118. set menu(SAVE_AS_ENTRY_IDX) 4;
  119. set menu(SAVE_ENTRY_IDX) 5;
  120. set menu(CLOSE_ENTRY_IDX) 7;
  121. set menu(CLOSE_PROJECT_ENTRY_IDX) 8;
  122. set menu(COPY_ENTRY_IDX) 0;
  123. set menu(PASTE_ENTRY_IDX) 1;
  124. set menu(CUT_ENTRY_IDX) 2;
  125. set menu(FIND_ENTRY_IDX) 4;
  126. set dan(PhpExts) {.php .php2 .php3 .php4 .php5 .funny} ;# extensions of Php files
  127. # __________________ iswindows ___________________ #
  128. proc iswindows {} {
  129. # Checks for "platform is MS Windows".
  130. expr {$::tcl_platform(platform) eq {windows}}
  131. }
  132. # __________________ quit ___________________ #
  133. proc quit {{w ""} {res 0} {ask yes}} {
  134. # Closes alited application.
  135. # w - not used
  136. # res - result of running of main window
  137. # ask - if "yes", requests the confirmation of the exit
  138. exit 0;
  139. }
  140. # __________________ raise_window ___________________ #
  141. proc raise_window {} {
  142. # Raises the app's window.
  143. variable dan
  144. catch {
  145. wm withdraw $dan(WIN)
  146. wm deiconify $dan(WIN)
  147. }
  148. }
  149. # __________________ Tclexe ___________________ #
  150. proc Tclexe {} {
  151. # Gets Tcl's executable file.
  152. variable dan
  153. set tclexe [info nameofexecutable]
  154. return $tclexe
  155. }
  156. source [file join $SRCDIR main.tcl]
  157. source [file join $SRCDIR filelib.tcl]
  158. source [file join $SRCDIR win.tcl]
  159. source [file join $SRCDIR menu.tcl]
  160. source [file join $SRCDIR tree.tcl]
  161. source [file join $SRCDIR eglib.tcl]
  162. ## _ EONS: radxide _ ##
  163. }
  164. # ________________________ ::argv, ::argc _________________________ #
  165. set ::radxide::ARGV $::argv
  166. set ::radxide::dan(IsWindows) [expr {$::tcl_platform(platform) eq {windows}}]
  167. # _________________________ Run the app _________________________ #
  168. namespace upvar ::radxide dan dan
  169. radxide::main::_create ;# create the main form
  170. unset -nocomplain _
  171. if {[catch {set res [radxide::main::_run]} err]} {
  172. set res 0
  173. set msg "\nERROR in radxide:"
  174. puts \n$msg\n\n$::errorInfo\n
  175. set msg "$msg\n\n$err\n\nPlease, inform authors.\nDetails are in stdout."
  176. tk_messageBox -title $dan(TITLE) -icon error -message $msg
  177. exit 2
  178. }
  179. # _________________________________ EOF _________________________________ #