/
radxide.tcl
292 lines (230 loc) · 9.37 KB
/
radxide.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#! /usr/bin/env tclsh
###########################################################
# Name: radxide.tcl
# Author: Daniele Bonini (posta@elettronica.lol)
# Date: 05/12/2023
# Desc: Bootstrap file of RadXIDE.
#
# Bootstrap file and most of the code
# here presented and distributed contains 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 contains
# 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. 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.)
#
###########################################################
set version "1.5.0"
set os "$::tcl_platform(os) $::tcl_platform(osVersion)"
package provide radxide $version
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(TITLE) RADXIDE
set tmpfname "~"
set userhome [file normalize $tmpfname]
if {$userhome eq "/root"} {
tk_messageBox -title $dan(TITLE) -icon error -message "RADXIDE can't run under root."
exit 0
}
set dan(WORKDIR) "$userhome/.radxwork" ;# working dir
# Check workdir existance..
if {![file exists $dan(WORKDIR)]} {
file mkdir $dan(WORKDIR)
}
# Check Code Library dir existance.. (WORKDIR)/.examples)
if {![file exists $dan(WORKDIR)/.snippets]} {
file mkdir $dan(WORKDIR)/.snippets
}
set dan(TREEVIEW) "" ;# ide project tree
set dan(GUTTEXT) "" ;# ide guttext control
set dan(GUTTERWIDTH) 12
set dan(TEXT) "" ;# ide text control
set dan(TEXTBG) "#222223"
set dan(TEXTFG) "#55ff55"
set dan(TEXTSELFG) "red"
set dan(TEXTFONT) "Monospace Semi-Condensed"
set dan(TEXTFONTSIZE) "10"
set dan(CURSORCOLOR) "red"
set dan(CURSORWIDTH) "5"
set dan(TOTLINES) 1
set dan(CUR_FILE_MAX_YVIEW) 1.0
set dan(prjdirignore) {.git nbproject} ;# 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]
variable ICONDIR [file join $SRCDIR icons]
# 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) 1280
set dan(HEIGHT) 760
#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) 15000
set dan(MAXFILESIZE) 150000
set dan(MAXFINDLENGTH) 50
set dan(TAB_IN_SPACE) " "
# icons
set dan(ICON) "$ICONDIR/radxide.png"
set dan(ICONI) [image create photo imgobj1 -file $dan(ICON)]
set icons(PROJECT-ICON) "$ICONDIR/archive.png"
set icons(PROJECT-ICONI) [image create photo imgobj2 -file $icons(PROJECT-ICON)]
set icons(PUBLICF-ICON) "$ICONDIR/public-folder.png"
set icons(PUBLICF-ICONI) [image create photo imgobj3 -file $icons(PUBLICF-ICON)]
set icons(PRIVATEF-ICON) "$ICONDIR/private-folder.png"
set icons(PRIVATEF-ICONI) [image create photo imgobj4 -file $icons(PRIVATEF-ICON)]
set icons(HTML-ICON) "$ICONDIR/file-html.png"
set icons(HTML-ICONI) [image create photo imgobj5 -file $icons(HTML-ICON)]
set icons(JS-ICON) "$ICONDIR/file-js.png"
set icons(JS-ICONI) [image create photo imgobj6 -file $icons(JS-ICON)]
set icons(IMG-ICON) "$ICONDIR/image.png"
set icons(IMG-ICONI) [image create photo imgobj7 -file $icons(IMG-ICON)]
set icons(CSS-ICON) "$ICONDIR/file-css.png"
set icons(CSS-ICONI) [image create photo imgobj8 -file $icons(CSS-ICON)]
set icons(PHP-ICON) "$ICONDIR/file-php.png"
set icons(PHP-ICONI) [image create photo imgobj9 -file $icons(PHP-ICON)]
set icons(TXT-ICON) "$ICONDIR/file-txt.png"
set icons(TXT-ICONI) [image create photo imgobj10 -file $icons(TXT-ICON)]
set icons(GENERIC-FILE-ICON) "$ICONDIR/file-generic.png"
set icons(GENERIC-FILE-ICONI) [image create photo imgobj11 -file $icons(GENERIC-FILE-ICON)]
set icons(FOLDER-ICON) "$ICONDIR/folder.png"
set icons(FOLDER-ICONI) [image create photo imgobj12 -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(UNDO_ENTRY_IDX) 0;
set menu(REDO_ENTRY_IDX) 1;
set menu(COPY_ENTRY_IDX) 3;
set menu(PASTE_ENTRY_IDX) 4;
set menu(CUT_ENTRY_IDX) 5;
set menu(INDENT_ENTRY_IDX) 7;
set menu(UNINDENT_ENTRY_IDX) 8;
set menu(FIND_ENTRY_IDX) 10;
set menu(GOTO_ENTRY_IDX) 11;
# a couplle of extension definitions..
set dan(PhpExts) {.php .php2 .php3 .php4 .php5 .inc} ;# extensions of php files
set dan(HtmlExts) {.html .htm .xml .xsl} ;# extensions of html files
set dan(CssExts) {.css} ;# extensions of css files
set dan(JsExts) {.js} ;# extensions of js files
set dan(TxtExts) {.txt .rtf} ;# extensions of txt files
set dan(ImgExts) {.gif .png .jpg .jpeg .ico} ;# extensions of images
set dan(OfficeExts) {.doc .docx .xls .xlsx .ppt .pptx} ;# extensions of office files
set dan(BinExts) {.so .o .exe} ;# extensions of binary
# __________________ 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
set answer [tk_messageBox -message "Really quit RADXIDE?" \
-icon question -type yesno \
-detail "Select \"Yes\" to make the application exit"]
switch -- $answer {
yes exit 0
no
}
return
}
# __________________ 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
}
exit 0
# _________________________________ EOF _________________________________ #