radxide.tcl 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. #! /usr/bin/env tclsh
  2. ###########################################################
  3. # Name: radxide.tcl
  4. # Author: Daniele Bonini (posta@elettronica.lol)
  5. # Date: 08/10/2024
  6. # Desc: Bootstrap file of RadXIDE.
  7. #
  8. # Bootstrap file and most of the code
  9. # here presented and distributed contains 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 contains
  18. # excerpts 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. set version "1.5.5"
  31. set os "$::tcl_platform(os) $::tcl_platform(osVersion)"
  32. package provide radxide $version
  33. set _ [package require Tk]
  34. wm withdraw .
  35. if {![package vsatisfies $_ 8.6.10-]} {
  36. tk_messageBox -message "\nradxide needs Tcl/Tk v8.6.10+ \
  37. \n\nwhile the current is v$_\n"
  38. exit
  39. }
  40. unset -nocomplain _
  41. # __________________________ radxide:: Main _________________________ #
  42. namespace eval radxide {
  43. variable dan; array set dan [list]
  44. variable tcltk_version "Tcl/Tk [package versions Tk]"
  45. ## ________________________ Main variables _________________________ ##
  46. set DEBUG no ;# debug mode
  47. set dan(WIN) .danwin ;# main form
  48. set dan(TITLE) RADXIDE
  49. set tmpfname "~"
  50. set userhome [file normalize $tmpfname]
  51. if {$userhome eq "/root"} {
  52. tk_messageBox -title $dan(TITLE) -icon error -message "RADXIDE can't run under root."
  53. exit 0
  54. }
  55. set dan(WORKDIR) "$userhome/.radxwork" ;# working dir
  56. # Check workdir existance..
  57. if {![file exists $dan(WORKDIR)]} {
  58. file mkdir $dan(WORKDIR)
  59. }
  60. # Check Code Library dir existance.. (WORKDIR)/.examples)
  61. if {![file exists $dan(WORKDIR)/.snippets]} {
  62. file mkdir $dan(WORKDIR)/.snippets
  63. }
  64. set dan(TREEVIEW) "" ;# ide project tree
  65. set dan(GUTTEXT) "" ;# ide guttext control
  66. set dan(GUTTERWIDTH) 12
  67. set dan(TEXT) "" ;# ide text control
  68. set dan(TEXTBG) "#222223"
  69. set dan(TEXTFG) "#55ff55"
  70. set dan(TEXTSELFG) "red"
  71. set dan(TEXTFONT) "Monospace Semi-Condensed"
  72. set dan(TEXTFONTSIZE) "10"
  73. set dan(CURSORCOLOR) "red"
  74. set dan(CURSORWIDTH) "5"
  75. set dan(TOTLINES) 1
  76. set dan(CUR_FILE_MAX_YVIEW) 1.0
  77. set dan(prjdirignore) {.git nbproject} ;# ignored subdirectories of project
  78. set project(NAME) "" ;# project default name
  79. set project(ROOT) "" ;# project default root
  80. set project(PATH) "" ;# project default path
  81. set project(CUR_FILE_PATH) "" ;# project current file path
  82. set project(TREE_PROJECT_ROOT) "" ;# Treeview: Project root node
  83. set project(TREE_PRIVATE_ROOT) "" ;# Treeview: Private node
  84. set project(TREE_PUBLIC_ROOT) "" ;# Treeview: Public node
  85. set files(FILE1) "" ;# Array files
  86. set files(FILE2) ""
  87. set files(FILE3) ""
  88. set files(FILE4) ""
  89. set files(FILE5) ""
  90. # main data of radxide (others are in ini.tcl)
  91. variable SCRIPT [info script]
  92. variable SCRIPTNORMAL [file normalize $SCRIPT]
  93. variable FILEDIR [file dirname $SCRIPTNORMAL]
  94. variable DIR [file dirname $FILEDIR]
  95. # directories of sources
  96. variable SRCDIR [file join $DIR src]
  97. variable LIBDIR [file join $DIR lib]
  98. variable ICONDIR [file join $SRCDIR icons]
  99. # misc. vars
  100. variable pID 0
  101. # directory tree's content
  102. variable _dirtree [list]
  103. set dan(TITLE_TEMPL) {%f :: %t} ;# radxide title's template
  104. set dan(WIDTH) 1280
  105. set dan(HEIGHT) 760
  106. #set al(MOVEFG) "black"
  107. #set al(MOVEBG) "#7eeeee"
  108. set dan(FG) "#000000"
  109. set dan(BG) "#cecece"
  110. set dan(fgred) "red"
  111. set dan(fgbold) "magenta"
  112. set dan(fgtodo) "orange"
  113. set dan(fgbranch) "blue"
  114. set dan(CHARFAMILY) "Sans"
  115. set dan(CHARSIZE) 10
  116. set dan(MAXFILES) 15000
  117. set dan(MAXFILESIZE) 150000
  118. set dan(MAXFINDLENGTH) 50
  119. set dan(TAB_IN_SPACE) " "
  120. # icons
  121. set dan(ICON) "$ICONDIR/radxide.png"
  122. set dan(ICONI) [image create photo imgobj1 -file $dan(ICON)]
  123. set icons(PROJECT-ICON) "$ICONDIR/archive.png"
  124. set icons(PROJECT-ICONI) [image create photo imgobj2 -file $icons(PROJECT-ICON)]
  125. set icons(PUBLICF-ICON) "$ICONDIR/public-folder.png"
  126. set icons(PUBLICF-ICONI) [image create photo imgobj3 -file $icons(PUBLICF-ICON)]
  127. set icons(PRIVATEF-ICON) "$ICONDIR/private-folder.png"
  128. set icons(PRIVATEF-ICONI) [image create photo imgobj4 -file $icons(PRIVATEF-ICON)]
  129. set icons(HTML-ICON) "$ICONDIR/file-html.png"
  130. set icons(HTML-ICONI) [image create photo imgobj5 -file $icons(HTML-ICON)]
  131. set icons(JS-ICON) "$ICONDIR/file-js.png"
  132. set icons(JS-ICONI) [image create photo imgobj6 -file $icons(JS-ICON)]
  133. set icons(IMG-ICON) "$ICONDIR/image.png"
  134. set icons(IMG-ICONI) [image create photo imgobj7 -file $icons(IMG-ICON)]
  135. set icons(CSS-ICON) "$ICONDIR/file-css.png"
  136. set icons(CSS-ICONI) [image create photo imgobj8 -file $icons(CSS-ICON)]
  137. set icons(PHP-ICON) "$ICONDIR/file-php.png"
  138. set icons(PHP-ICONI) [image create photo imgobj9 -file $icons(PHP-ICON)]
  139. set icons(TXT-ICON) "$ICONDIR/file-txt.png"
  140. set icons(TXT-ICONI) [image create photo imgobj10 -file $icons(TXT-ICON)]
  141. set icons(GENERIC-FILE-ICON) "$ICONDIR/file-generic.png"
  142. set icons(GENERIC-FILE-ICONI) [image create photo imgobj11 -file $icons(GENERIC-FILE-ICON)]
  143. set icons(FOLDER-ICON) "$ICONDIR/folder.png"
  144. set icons(FOLDER-ICONI) [image create photo imgobj12 -file $icons(FOLDER-ICON)]
  145. # Menu variables
  146. set menu(ROOT) "";
  147. set menu(ADD_FILE_ENTRY_IDX) 2;
  148. set menu(SAVE_AS_ENTRY_IDX) 4;
  149. set menu(SAVE_ENTRY_IDX) 5;
  150. set menu(CLOSE_ENTRY_IDX) 7;
  151. set menu(CLOSE_PROJECT_ENTRY_IDX) 8;
  152. set menu(UNDO_ENTRY_IDX) 0;
  153. set menu(REDO_ENTRY_IDX) 1;
  154. set menu(COPY_ENTRY_IDX) 3;
  155. set menu(PASTE_ENTRY_IDX) 4;
  156. set menu(CUT_ENTRY_IDX) 5;
  157. set menu(INDENT_ENTRY_IDX) 7;
  158. set menu(UNINDENT_ENTRY_IDX) 8;
  159. set menu(FIND_ENTRY_IDX) 10;
  160. set menu(GOTO_ENTRY_IDX) 11;
  161. # a couplle of extension definitions..
  162. set dan(PhpExts) {.php .php2 .php3 .php4 .php5 .inc} ;# extensions of php files
  163. set dan(HtmlExts) {.html .htm .xml .xsl} ;# extensions of html files
  164. set dan(CssExts) {.css} ;# extensions of css files
  165. set dan(JsExts) {.js} ;# extensions of js files
  166. set dan(TxtExts) {.txt .rtf} ;# extensions of txt files
  167. set dan(ImgExts) {.gif .png .jpg .jpeg .ico} ;# extensions of images
  168. set dan(OfficeExts) {.doc .docx .xls .xlsx .ppt .pptx} ;# extensions of office files
  169. set dan(BinExts) {.so .o .exe} ;# extensions of binary
  170. # __________________ iswindows ___________________ #
  171. proc iswindows {} {
  172. # Checks for "platform is MS Windows".
  173. expr {$::tcl_platform(platform) eq {windows}}
  174. }
  175. # __________________ quit ___________________ #
  176. proc quit {{w ""} {res 0} {ask yes}} {
  177. # Closes alited application.
  178. # w - not used
  179. # res - result of running of main window
  180. # ask - if "yes", requests the confirmation of the exit
  181. set answer [tk_messageBox -message "Really quit RADXIDE?" \
  182. -icon question -type yesno \
  183. -detail "Select \"Yes\" to make the application exit"]
  184. switch -- $answer {
  185. yes exit 0
  186. no
  187. }
  188. return
  189. }
  190. # __________________ raise_window ___________________ #
  191. proc raise_window {} {
  192. # Raises the app's window.
  193. variable dan
  194. catch {
  195. wm withdraw $dan(WIN)
  196. wm deiconify $dan(WIN)
  197. }
  198. }
  199. # __________________ Tclexe ___________________ #
  200. proc Tclexe {} {
  201. # Gets Tcl's executable file.
  202. variable dan
  203. set tclexe [info nameofexecutable]
  204. return $tclexe
  205. }
  206. source [file join $SRCDIR main.tcl]
  207. source [file join $SRCDIR filelib.tcl]
  208. source [file join $SRCDIR win.tcl]
  209. source [file join $SRCDIR menu.tcl]
  210. source [file join $SRCDIR tree.tcl]
  211. source [file join $SRCDIR eglib.tcl]
  212. ## _ EONS: radxide _ ##
  213. }
  214. # ________________________ ::argv, ::argc _________________________ #
  215. set ::radxide::ARGV $::argv
  216. set ::radxide::dan(IsWindows) [expr {$::tcl_platform(platform) eq {windows}}]
  217. # _________________________ Run the app _________________________ #
  218. namespace upvar ::radxide dan dan
  219. radxide::main::_create ;# create the main form
  220. unset -nocomplain _
  221. if {[catch {set res [radxide::main::_run]} err]} {
  222. set res 0
  223. set msg "\nERROR in radxide:"
  224. puts \n$msg\n\n$::errorInfo\n
  225. set msg "$msg\n\n$err\n\nPlease, inform authors.\nDetails are in stdout."
  226. tk_messageBox -title $dan(TITLE) -icon error -message $msg
  227. exit 2
  228. }
  229. exit 0
  230. # _________________________________ EOF _________________________________ #