radxide.tcl 8.7 KB

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