#!/usr/bin/wish
#   August - HTML Editor for UNIX by Johan Bengtsson 
#   Copyright (C) 1999-2001 Johan Bengtsson johanb@lls.se
#   Snail mail: Johan Bengtsson, Fangdammsvagen 10, 433 43 Partille, Sweden.
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

if { $argv == "-hlp" } then {
        puts {AUGUST COMMANDLINE OPTIONS:

<filename> - open file with the given name or
create a new file if it doesn't exist.

-all - open all files in the current directory
with *.html, *.htm, *.css or *.txt extension.

-hlp  - display this help message.}
        exit
 }

# Make sure that no other instance of August is running...

   if {[tk appname] != "august" && $tcl_platform(platform) == "unix"} then {
     wm withdraw .
       catch {
     send august [list wm deiconify .ed]
             }
     exit
}

# Create gif icons (gif images base64 encoded with the free uuenview program).

# tpl.gif

set tpl\
 "R0lGODlhGAAYAOcAAAICBD6aZE7ChKbCrFLilJbmvGLypIKChIrKpB5ONKampKK+tLLqzGbinGL6
pFLSjLa2tFbqlCpiRMbCxHrSpG76rGrWnBY2JJbCrL6+vEaudD5CRNLS1A4SDL62vF7qnFrilHb+
zD6qbLK2tOLi5Gb6rFLelLa6tG5ubG7+vHLWnJbKrAIKBLLaxCZWPKqyrJ7CrM7a1I72vF7elD6e
bLbGxHL2rFrunJrStG7WnAoCBGLKjFLmlGL2pJLKrCZSPF7+rLq2tFrqlDp+XMrKzILerGbalDpK
RF7unFrmnH7+1K6+tOry7FralHL+vAIGBErOhK7GvI6OjIbOpB5SNK6qrKq+tML+3HLqrDJuTILS
pGr+tDY2NJbGrEq+hNbW1BoaHGb+rLq6tH5+fLKytKLCrNra3EKeZGb2rGranAYCBEKabFLChKbC
tFbilI7uvIaGjCJOPKqqrKa+tKryxG7mnGL6rLa2vFbqnCpmRMbGxH7SpMK+vEaufEZCRNbS1BYW
FP7+/E5OTOrq7Ib+xMLCxEI2PAoODM7OzN7e3EaqdL66vLK6tCZaPFrelHr+1HJudGLenIL+3Fbe
lHbWnFbmlGL+rF7mnLK+tIrOpG7+tJrGrLaytF7qpFrinG7+xGL2rLq2vFrqnGbanF7upHL+xGb+
tLq6vKLCtEKebLKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKy
srKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKy
srKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKy
srKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKy
srKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysiH+Dk1hZGUgd2l0aCBHSU1Q
ACwAAAAAGAAYAAAI/gDJQBhIsKDBgxAEnjoFYeGpOxAgSozosGLCOxkK6dFDpKMePgwHCjQYshAR
FGOkHIBzAFKQCR5ChQoSauJCMmQKjQGkQA6AMS82GKoxAoKHIDGDQGw4sJCcP4hiAGBQQMaOOhYo
IJhzQswpMQNP4XSYoQUAG5UIqDVBwI2RKVZoMgxJE0KUNwAMJGnCl++ktloYzfRKZkQoMSdwoAEA
qseWFFssadrSo5IjHzSDMOS0KMiIIpYAbAlzAYCAIT86pNrCQ4XgE2INQ5iDRQSAPCk0AHhkwEkA
AI4qzUDFyQNYTqeCLGgA5YEXB4oAKEGS4gwAUaLcbDoFmwxyCDAi/lX68AE6ADYBspgO48ZRFwih
GBr2MMcCAU+OekSXZKlUCCd2EABCGZx0B58HVqhAwCSO2KHbI5MgAQAAlhBgxBKcaJbQCUFAgMAk
7YXRCAApeLKFC4c4YcIURnW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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAGAAYAAAIbAAfCBxI
sKBBgQceHFjIsKHDhwcQKIRI8aHEihgZXsyIcSNHih4/WpzIEIDJkygBjBQJkmTJlCchhmSp0SXM
mw5n0ozo8mXKljtz2rz5s6FOmjOJxhQa1GjPnUdZRhU59SOCiAiyat3KtSuCgAA7"

# cls.gif

set cls\
  "R0lGODlhGAAYAPcAAAAAAAAACAgAABAAABAYGBgAABgYIRghISEIACEpKSkIADEIADEYGDEpKTEp
MTExMTkIADkhIUoQCFIQAGsQAHMQAHsQAHsYAIQYAIwYAJwYAJyclKUYAKUhAKWcpb0hAL2clL29
vb3Gxr3Gzr3OzsYhAMYxEMZCIcZKMcZSOcZaQsZjSsZrUsZrWsZ7a8aEc8aEe8aMe8aUhMaUjMac
lMalpcatpcatrca1rca1tca9vcbGxsbOxsbOzs4hAM4pAM4pCM4xCM4xEM45GM5CIc6Ec86clM69
tc7Ozs7W1tYpANZSMdZjStZzWtaEc9a1rda9tdbOxtbW1t4hAN4pAN45EN5KKd5jSucpAOc5EO8p
AP8xAP//////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gBDCBxI
sKBBgjtCJFyosCHDhwcHigghQsSIigcTOnQo4oYLFi5q5AjRQ4QOkxF3IDnCpEqQEkBMnFji5AmS
HRM1LkSSAIBPAB2UlPhR4icAA0gy1gAQoOkALD+wKGgaAACIHg0bVmRyoamAABewdKAagMISgydx
nMBSgKwWrwGeloBBQofAhCJAAPkBBG5bqh+IpsA4cAQMolQqkA3wdQLUEkNyTGxIosXQqAjgMsYC
ZKiJG5ND6BixYmgJLAuofl0AlagJGwPxriCqpCvjAASaYqBCVIWN0CFGvBiqZPHXpj9+mGAx8i5F
GyiwZL6dAa4CLCdiCJx8MkQTDHAnbWyRQBbDkhqhNfagwfQ47+K3ARRBiRDJAZ9VNQitbTSBFPoL
bWDAAw9EIAFvJZhQRQQNEHiABxohJMWEUTwxQwwyyBDCE1FMKIVOWYm2XUUXXUQRQd05NxF92wlk
10kp2qWRXc4lZNeKKE4UEAAAOw=="

# color.gif

set color\
  "R0lGODlhGAAYAPcAAAAAAAAAKQAAUgAAWgAAawAAcwAAhAAAjAAAxgAA9wAA/wD/AAD/OQgIAAgI
MQgIOQgIpRgYABgYGBgYYxgYayEhACEhECEhGCEhMSkphDExADk5ADk5zkJCAEJCQkJCY0JCa0JC
e0JChEJC/0L/jEpKGEpKUlJSAFJSOVJSWlJSrVJSvVJS71L/CFpaAGNjY2trGGtrY2trjGtrxnNz
a3t7AISEAISEKYSEMYSEc4T/MYyMAIyMvYyM/5SUAJSUWpSUzpSU95ycAJycY5yc/6WlAKWlWqWl
Y62tAK2tra2t/7W1ALW1Y7W1pbW1tbW1vbW13rW15729AL29e729vb29xr29zr291r29973/AMbG
AMbGa8bGxsbG787OAM7OjM7Ozs7O987/ANbW1tbW3tbW79bW/97e3t7e/+fnAOfnxufn3ufn5+fn
7+fn9+fn/+/vAO/vEO/vOe/vpe/v//f3Off3zvf39/8AAP8A//8ha/8h//8ppf85//9Cc/9C//9K
hP9SAP+EAP+Evf+c9/+9AP+9///GCP/W///eWv/e///33v//AP//CP//EP//Mf//Qv//Sv//Wv//
Y///a///c///e///hP//jP//lP//nP//pf//rf//tf//vf//xv//zv//1v//3v//5///9///////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gBLCRwI
oMGDBgAGKlwokE0pDxkAkNqE6VMoFwaalBpzpiPHNot2CAQAIFMpRpE6MYJ0UoATKkmcxEwyBgOS
hwktMcrDM08fRqU0JXzJhQqVOyYSZshkyVIlQD15MurkQ8QZo1S4gKEhoVSFk5ZICYqaZ8+jUkOp
PCGVMKEKRqQ0NSpVKKoeTEAlPlHThSTJTZY4tSCRyROjP4P8VLrUdE5CGUEAoNDy4FKpBZgZZDk5
iRQjS2DREuFAZ0uRBqEYYV4tppRO10AzMUoABQCZKUJQr8aso1NTS5cqzdjAxECBOJogwFjyAPRq
Rp48W2Y040UVAQcumIQDIE0Dw6U4/kFClMgRbK9QCAxA+wloDRcAQjWlhAgPHj6/LdkBgICUBSCV
WJJJCUeU4sJJhNhnXybTVYIWAD18VkojIZRRygTmBaKgfZg0QsokQG0C1GsdhFGKBpFcssiGeByi
CSUrjNAIJsA1pUkHFgZwByMO2mfIVB8oIKQCUoTmSAhcjFRKJUCpVAoIQw6pBSmXALXBGxuhJUqA
i0nCQpRCahIgJnUU8EkpZ4ARQ0KQTBdJlIxoIgojnKD1hQ+ltHEFliRlcpMmjIwCYimYOIKGBgkN
UUQpa+BgRA4A8EBBASd0EEIHlmKaAgBK2PHDDYvaIAQSO9gghxalRFEGGGGs2qoVCqUgIUQRRaQR
EAAAOw=="

# rowspan.gif

set rowspan\
  "R0lGODlhGAAYAPcAAAAAAAAACAAAEAAAGAgAEBgQISEYKSkhMZycnK2tra2tta21tbWtrbW1tbXW
1rXW3rXe3r29vb3Gxr3Gzr3Ozr3O1r3W1sa9vcbGxsbOxsbOzsbO1sbW1s6UjM6UlM6clM7Gxs7O
xs7Ozs7e3taEe9bW1tbe1tbe3tbn59bv795rWt5zY957a957c97W1t7e1t7e3t7n5+djSudjUudr
Wud7a+fn3ufn5+9CMe9KMe9SQu/v5/cxGPc5IfdCKff39/f/9/8AAP8IAP8QAP8YAP8hAP8pEP//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gAjCBwo
8ALBggcjGFQoIQIGhxEaSjD4sCHEigIbLlSIUKPAhwg7QmxY0SDJjxE5TkzIkqVGEy9gxJz5YqbM
mjJllnCIAYDPn0ADAB16YGfPGyKSlhBRYucApCJGJGWaoEAJDD1fRNyIoQEBExEckHgwEQMCA0YB
lKDgoG0FChUUCChRQYUQHhIkmLWKFQAKGTx68FDRgkWCAWB1EBmC44FZtA7VBhEiZIhly0UqEymS
WYUFBHx7oviwgkUOHjwwU+acuYMG0GldSKAA1wFZBQTo8igSxIODx1d7gj2IYQFiBzmIzHYIO/IP
mzFhZCDwAwaKFDltKEDbd6j37wAgL0eAkTN6zBIvSsBAr579TogtH8q/SH/gfPgtieOnP7//fvv5
5effgPzVF+CBEQQEADs="

# comment.gif

set comment\
  "R0lGODlhGAAYAPcAAAAAAAgICBAQEBgYGCkpKTExMUpKSlJSUlpaWmNjY2tra3t7e4SEhJSUlJyc
nKWlpa2trbW1tb29vcbGxs7OztbW1t7e3ufn5///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI3gAlCBxI
sKBBghMkJFyosCHDhwcjSkz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3PGjJSM/5SU/5TG
pZyU/5yc/5zGraWl76Wl96Wl/6Wt3q2l962t562t96213q3Gta3Gva3//7Wt57W1vbW11rW13rW1
57W9vbXGvbXe1rXe57Xn97Xv/7X3/7211r29vb29xr29zr291r3Gvb3Gxr3Gzr3Oxr3Ozr3O1r3W
1r3W3r3e573n78a9vca9xsbGtcbGvcbGxs5rUs5zWs6Ec869xs69zs7OnM7OztZSKdZSMdZSOdZa
OdZjQtZzSta9zta91tbWjN5CId691t7ee97e3t7nc97ne+chAOe15+e91ue95+fna+fnc+fn3ufn
5+fva+8AAO+93u+95++97+/vWu/vY+/va+/v5+/v7/cAAPe95/e97/f3Svf3Uvf37/f39/f/Svf/
9/8AAP+t//+17/+19/+1//+97/+99//enP//AP//CP//EP//GP//If//Kf//Mf//////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gB7CBxI
sKBBgk96CEGCY8iSIEwgBvHRow+gNgITJhQopEeWKAoLLmkDIECFPjVE+hiyBY+ZHT2WCHnY4wkk
AAD69PDhhGJIJVtuvMEx0OcYDR06YGAjMMiSmD1evJkKJUcPJwJj3JQAAQCklD574NDy5oUQPEQ6
JmRTAQBFAA/sCMS6BEcWMEKgYJFiZOCTGDGC9IhRcydBhgtx9J349ImVJY4TOs14cLLggxEJYt1s
eOPEHoI3+mjcQwaLGSooYhXIhEqXLkyaZhYoQ80c200o+oDYhUQLEkyYPGUtUMUiRo+Qm5g8CAED
BAcOCLIhcyBWFSMY7Uk0o2mPMGcMyig4UGNKzM8UZYhJBCKRGhZLKDLJQx6BAUIDn2JdkYjMh/Um
gNZDHhRIx8EBaTwUlgxVKCLGg4t8IYNAhBxgwRlnHHABHJqV8EgjjCiyiCONBBiGB9AxwEACCOAn
oA8yJOKDCCyA4EMiPaAgyAERDEKCD14cEM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oc87Ozs733ta9IdbGxtbW1tbW3t7OUt7O
zt7Wzt7e3t7e797n797vjN7/5+eUQufOUu/v//fGEPfWY/f39/f3///OIf/WKf/WMf/eIf/eKf/n
Kf/nMf/vMf/3Of/3Qv//Qv//Sv//Uv//Wv//Y///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gBJCRxI
sKDBgweHIVxoMFWQYQoZIrQEBhaOiBILjnLTy1aoIRgzkhoGQI6rWoZoqBEpcJgaU1wo2XoBSUgl
kcPCaKo0R8aMHooqubi5EKIWU5IANNDwIQMAIZ9qTFq4CI6oQABAnLDD5wqmPQo2zRB08E+eH8OY
WDCRYgWrQo2oAOgzC8CYVwT1+OlFRAqDEiJIjLhgxkgMFAGeoAkWJVVER71oCUMkQEQHFSyAsFnC
Y8eAWMFo/bqBl1QRQLqsdBmwQcmqVqA4SMjhQMaWO7qyEBzmxJCASUIebAjRCQuGChMIkGHU4gxC
J6PEFJigA4YHCBEQAFBEx8WghT5GUqUZcMCCjQQGAiR6IyXkQR+b3jgJIACAF0JqtLhHSGSUIjyP
JCHLF/qxRMoMAHhSyxEBfLEfQ3CUkostu0ARiYEEZVLLDZZgWFAbl3hYUCoSBQQAOw=="


# mailsend.gif

set mailsend\
  "R0lGODdhGAAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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RxJkmSzYgKNGaLxrJmHlzBj
yvTQLOXKZ9Vm6oRZbWMiHNGe7dxZMxfFF5WOhSzJVORJgcy0bXMGLKNVga1e0kq2tGnJp7nufAth
SNpQnUWFUfNwK9vZmT1zHfu0BprZtzGL1vrgaAyzrl5Hgg1Dw8YeYlYzCnzWTduzYIkxCqzTxIMs
ZIADVwN7aZyPUNHw5hVYrIYHX95E89y4zccNt6ppCizyy40TaJkDgy3SRIwyYZEjCjy2zBjk4BoP
Kl8eEAA7"

# p.gif

set p\
  "R0lGODlhGAAYAPcAAAAAAAAACAAAEAAAGAgIGBAQISkpOTExQjk5SkJCSkJCUkpKWlpaY2trc3Nz
e3t7e4yMlJSUlJSUnJycnKWlpaWlra2trbW1tb29vcbGxs7OztbWztbW1t7e1t7e3ufn3v//////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI6gAxCBxI
sKBBghkwJFyosCHDhwcjSkzosCJEiBIxbODQgSOHjxsoVrSo4YAAAgQGoCxwYAIHkRE5GBBAM0AA
mgIANNAwkiEGmTQTLFiQgCYBAA0PJgQawEIHDRw8FBAQYGfSqz9NBqBAUYODmwt4XmXIlIKGDBk+
KKDK4CxCgkwnYLhQgUGAo1wFwqTIwSSBAAAA2PxrgANWiktn/rUJGICClwP3CgQq4IEECBHMuj0c
ecPMpmfRwtT79ufnvG9Hi8zgmWpen6Qlm86JOrbB1SUJCHh9m7PAjZBtjx4bGWvq0pwxIl+dkWFA
AAA7"

# paste.gif

set paste\
  "R0lGODdhGAAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAGAAYAAAIwAAfCBxI
sKBBgQceHFjIsKHDhwcQKEyIkOHAhhcXSlxIoCOBhQ88fkwoUqNCBAg0MnjAIGXElS01mnQIoGbN
hTZvNtyIUiOAAwBcIvgZVGbEiQAIJGWoVCnTpD+PQpwKcSNVpiJHSr3KEeUDBASETrxKQOFAsDO5
ap040upUjxYjth37sKPEkWzTQgxr9+PJuVT98k3IUe9DiT+d/jW880FSp4QPAD4MtCvKy5MdDm2Y
VatbrlM/g6Z8ubTp06YDAgA7"

# pict.gif

set pict\
  "R0lGODlhGAAYAPcAAAAAAAA5OQBCQgBKSgB7ewCMjAgAAAgICAgYGAghIQg5OQhKSgjGxhAAABAQ
EBBaWhDW1hgQEBgYGBhKShhjYxje3iEYGCEhISE5OSFraykYGCkhISkpKSlCQilzczk5OTlKSjnv
7zn39zn//0IhIUIpKUJCQkJKSkL//0pKSkpSUkpaWkrOzlJSAFJSUlJjY1Lv71L//1paWlr391r/
/2NjY2P392P//2tra2ve3mv//3P//3t7e3v//4T//4yEhIyMjIz//5T//5zW1pz//6WlpaX//62t
ra3Gxq3//7W9vbX//729vb3//8aMjMa1tcbGxsb//861tc7Ozs7//9a1tdb//97e3t7n5+fe3ufn
5++lpe+tre/n5+/v7+/v9/f39/97AP/Gxv/v7//3zv/39///tf//////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gDPaPEy
0IvBggcNJlQoEIDDhxAjSnR4piKAI2eAAKh4IEXDKWdwbDwDAEdFi1DOFBl5wIVFLWd4jATA4wyY
AxwAOLhwAMCFCw4vSNAJ1GdOBxxIOuRgoumHDyZq1IBqgmqKhybOXAHAwcuVr1munHHh8atZLVuz
au14hckTKUqyPDyQRYmUJ0yUlAFQo+KVAyaubLGRw4cPBA4RGM5hY4sSLwBk+AUsRoSPJih+QPyB
ookPEVvARJ6MYYcQIRActggTpoVDCESCwBgzWquBFDeiMAAgBYAZMmTM8AbAgMqNHbWvNBhwpgAA
KxUAfKmoBUAFKwAKGDGS/MCCMwSGvghhAQBmQxZEhhAQQiS5gRM3luyIgaQ8dQBIYuxYcqNH9wlC
9NCDbACUUdFeMAThQw8+CFGbFsslEYMPSdBwQwIVJXDDDUb4EIMQS/DlFwAlUOjDDU4osIIAAayg
gBM3+LBEDyEAoNZDJAzQwQoAZPACBRSs4AEAJ3QwwAlY3XSUBj1xsIFDG0QAgAQXGODTk0idBEBK
K3EkGUkwyWRRTVpipBFHHlUHkkgWmVTdRHBOJBBBCtGpEEJ2GnRGQAAAOw=="

# pre.gif

set pre\
  "R0lGODlhGAAYAPcAAAAAAAgICBAQECEhISkpKTExMTk5OUJCQkpKSlJSUlpaWmNjY2tra3Nzc3t7
e4SEhIyMjJSUlJycnKWlpa2trbW1tb29vcbGxs7OztbW1t7e3ufn5+/v7/f39///////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gAtYLhA
UGCGCxYSKlzIMAOAhxAFDLSAsCLFiwgpUigAwIGDBQACZGBI8qKFDAoAZMCgwQEAjDAtKsSQUkOG
DQcAYCjJMCNNAAYMBADQYEOGlRZlzkwJEQACAlAXFFwoU0NKDhwmNIVYMCPVCAMAKEhQAQOACBs2
UBC7M+ZJAU0VXAAAQYOGCgASTCyJoa9fvAWePpyaNGHSC3ibXmjLsydetBAeIh1IWaFMDHgfHI1s
QAKEz58feDV8oUFTlgi2clWKmIFr0YsZ5KxQwQJIwoYF9p2qgQGADRM+68xt0vJMkA2GbthLnLVA
kBA17PU62isGkBqEakBQgbpx4r1/J2vYMLeB8+KLoRMYwJ4oY+8mMSAIIEAA/QABRKP/nhDD0f9H
IRQQAAA7"

# right.gif

set right\
  "R0lGODdhGAAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD/
/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAGAAYAAAIbAAfCBxI
sKBBgQceHFjIsKHDhwcQKIRI8aHEihgZXsyIcSNHih4/Wpz4EIDJkygBaCQp0mHIkilPrmwJ8eWB
mDhn0nTJkmLOhTZpvsT5M2LPnUFvEjWpc2dTp0ahPnWaVCSCiAiyat3KtSuCgAA7"

# colspan.gif 

set colspan\
  "R0lGODlhGAAYAPcAAAAAAAAACAAAEAAAGAgAEBgQISEYKSkhMZycnK2tra2tta21tbWtrbW1tbXW
1rXW3rXe3r29vb3Gxr3Gzr3Ozr3O1r3W1sa9vcbGxsbOxsbOzsbO1sbW1s6UjM6UlM6clM7Gxs7O
xs7Ozs7e3taEe9bW1tbe1tbe3tbn59bv795rWt5zY957a957c97W1t7e1t7e3t7n5+djSudjUudr
Wud7a+fn3ufn5+9CMe9KMe9SQu/v5/cxGPc5IfdCKff39/f/9/8AAP8IAP8QAP8YAP8hAP8pEP//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gAjCBwY
AUPBgwYTEhyoMCGGhxAjXpAw8cJCgTAAaNzIEYAJixEkCFQYIeMPEy5QlFD54gaAFyFBEjT44mXI
D0FkUIggAgAMhiMJZvxJYYUQHg4k9IRpcObBmjApsBDSw8GFnj+DHhw4NEKFHEOQRihhk+LCphlh
OuAxREUFnj4Hmm1KM+4Dti12kmV6Ea1PDBKGDGFRAcNegRO1FiSbYYECwQkUNIhQNoLMrTUJDCBQ
pMgAAZoD/Eys2DCAkyWECDFRwoRLmIq3DnVQQcgQr3B/mi1NFkUOHkWI6FDhYKlcmU1rpiDSObgQ
EiNsNuXtU0KQzmEfGN8KtORLCh5UQ+OQoDSu1ummfzrooOIBRePTu9e08VCDBYhks25FT1YBgv8A
IpBAWZdtVYIBBhSQoIIMHlDCcdwZVMKEFFb44G4RBAQAOw=="

# table.gif

set table\
  "R0lGODlhGAAYAPcAAAAAAAAACAgICAgYABgYGCEhISE5ACkpKTExMTk5QkJCQkpKSlJSUlpaWmNj
Y2tra3Nzc4SEhIyMjIytAJSUlJSUnKWlpb29vcbGxs7OztbO/9bW1t7e3ufn5+/v7/f39//3////
AP//////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gAxYNiw
gYPBgwgTEswgEAMHERAjSpwosQPDDSIAaNzIsSPHAx8GZvS4kUOHDR1OPgSwQITDkQAqiEgQEUDE
Dx5qMnC5EgAGkh9ECNgIkSXPkUVDGACRMagEohlbvuQ4IUQIoh5sfrAZ9ajGogO+AgjasetUmwEA
aLD5lWLGnWeHFr2QEcKDBgwaNHhAAUADryQDb/w79aGHoDkzRnALwIHXh0EfFr0LAKOIAhkJr8Tg
Iavctx2yIvXrlfOGDxC4AtgJQMGGAgIyl/aQwQMCER0yIuBbeWhWzRkxdBgIwGBmDhAgfsggeypG
gx825ASwmGJjr25hknQ8cKtgwQpcLGbocGABgwXo0Tdw8ACC+/cPFljgIPB09vsiOGS4gIG/QIYY
ANjQgAReEBAAADs="

# tablec.gif

set tablec\
  "R0lGODlhGAAYAPcAAAAAAAAACAAAEAAAGAAIEAAIGAAIIQAQIQAQKQAYOQBSjABalABanACU7wCc
9wCl/wCt/wC1/wgAAAgAEAgIGBAQMRAhMRgYKRgYMSEYMSEhMTk5SjnGADnOADnWADneAEI5EELn
AEL3AEL/AEr/AGsICGtjGHMICHMQEHNrGHsICHtzGIQQEIyEIZSMIZyMIaWUIcbGxs7Oxs7OztbW
1t7OIecYEOfeIe/eIfchEPfnIffvIf8hEP/vIf/3If/3Kf//Kf//////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gBjCBxI
sKBBgzRmJFyosCHDhQQ3aJiYgeJEDRgqaNyIgcJAGhcEEBhJcqQAECtSqEyxwgSAjxoGhCAhomZN
EgNgANnJU8dLgTQ0COjgoahREQNcAOnxg+mPGz9jzIjZ4YPRokiVMu2x40cNADKAUr2KNenSpj+e
ApghdkBVsjiVotWhduBUt2Q9ZD3r9CvbGEHdhgjhgXAIpC+ApE0LBCpMARwid+AwOcSAFj104MCh
Q4dfgXcHGBBNesAAAQBSAwgAYEBUGhZQ8JhNezaLBA8a6G7w4ABY0LFr174NwUED4xB8fwwufDYK
3LsbQKDwWyrz5sSjJ399XfhzCNp9R4e1Lrs5j9sRHqh/EEE50O7DESxQQF/BAurjZ1gokcOG//85
oFCABBNIYOAE1H1EnWoMNuigQWyFxVaEUoEm0HgHZahhDAEBADs="

# tt.gif

set tt\
  "R0lGODlhGAAYAPcAAAAAABgYGDExMTk5OUJCQkpKSlJSUlpaWmNjY2tra3Nzc3t7e4SEhJycnKWl
pa2trbW1tb29vcbGxs7OztbW1t7e3ufn5+/v7///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////ywAAAAAGAAYAAAI/gAjCBxI
sKBBghIiJFyosCHDhwcjSkzosCJEiBIzInQ4gcKEjh89TpAgIaTJjyMbGDjAsiVLAwILuHRpoIEC
ADhz6hSosycABQsABDhQACdLnDwBHAUgMwCABUEJXICA04IFpBGqXgUQwQKBpzcFVHiAkwIFpFQB
mMX5gIKAn2QZTCCrdsKAAB8DDOjIdgIDABAkeJRAl0JJCgoHnwXwgKThgYTLCqQ4cHHjhg4LU2Zo
mfJkCmktTMCscEIFnBAMU5TgIAECnAsSVIyQICgABAkaUFzcMwDiCG59AhgdYcICAQOSDxDgYLUD
5ASSC1BAOaRZswwTe7xOnHTB1ZA3E4bPPrm8+fDfSYOfXd7zefcCAwIAOw=="

# underlin.gif

set underlin\
  "R0lGODdhGAAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD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HEihgZXsyIcaNDAAA+hnTosSFIkRYnojQ5smFJhidZpoQYE2ZL
jSpl6nSZ0+ZKnjRvHqiJM+jPog+JDhUasedCBAAQaIw6MyjIqxBfurwqNatTjkAjXh1LlqxUrWCR
pq26lmREBHDjyp1LF0FAADs="

# The commands below loads gif images from the data variables above.

image create photo fopen -data $fopen
image create photo filenew -data $filenew
image create photo fsave -data $fsave
image create photo fexit -data $fexit
image create photo fsaveas -data $fsaveas
image create photo bold -data $bold
image create photo italics -data $italics
image create photo underlin -data $underlin
image create photo center -data $center
image create photo left -data $left
image create photo right -data $right
image create photo comment -data $comment
image create photo cut -data $cut
image create photo copy -data $copy
image create photo paste -data $paste
image create photo tt -data $tt
image create photo pre -data $pre
image create photo color -data $color
image create photo cls -data $cls
image create photo p -data $p
image create photo br -data $br
image create photo fontc -data $fontc
image create photo numlist -data $numlist
image create photo pict -data $pict
image create photo mailsend -data $mailsend
image create photo link -data $link
image create photo bulllist -data $bulllist
image create photo table -data $table
image create photo rowspan -data $rowspan
image create photo colspan -data $colspan
image create photo help -data $help
image create photo ins -data $ins
image create photo tablec -data $tablec
image create photo deflist -data $deflist
image create photo justify -data $justify
image create photo ag -data $ag
image create photo h1h2 -data $h1h2
image create photo h3h4 -data $h3h4
image create photo h5h6 -data $h5h6
image create photo tpl -data $tpl
image create photo block -data $block

# Set options in an array. Many of these values is used in the set_options proc \
 that creates the "August options" dialog.

set August(docpath) $env(HOME)
set August(bold) "B"
set August(ital) "I"
set August(prname) ""
set August(copies) "1"
set August(prcomm) "lpr"
set August(tpldialog) "yes"
set August(netscapepath) "netscape"
set August(identifypath) "identify"
set August(lynxterm) "rxvt"
set August(specchars) "none"
set August(font) "times"
set August(fontsize) "12"
set August(wrap) "word"
set August(openlastdir) "yes"
set August(syncolor) "yes"

# Check if August directory exists in the user's home directory and create it\
  if it doesn't exist.

set checkdir [file exists $env(HOME)/.August]
           if {$checkdir == 1} then {
        } else {
           file mkdir $env(HOME)/.August
    }

set Augustdir "$env(HOME)/.August"

# Make sure that the path is platform independent with "file join" command.

set Augustdir [file join $Augustdir]
global Augustdir

# Check if template directory exists in the .August directory and create it\
  if it doesn't exist.

set checkdir [file exists $env(HOME)/.August/templates]
           if {$checkdir == 1} then {
# don't do anything...
         } else {
           file mkdir $env(HOME)/.August/templates
   }

# Check if configuration file exists and read it if it does.

set checkfile [file exists $Augustdir/Augustoptions.tcl]

if {$checkfile == 1} then {
    source $Augustdir/Augustoptions.tcl
}

# Set variables

# This variable carries the name of the textwidget.

set textname .ed.te.edit1
global textname

set filesave(Untitled) Untitled
global filesave

set filename Untitled
global filename

set data ""
global data

# This variable contains a number that is incremented every time a new file is opened/created.
#Used when creating the filebuffer array that contains a list of buffert files.
set filelist 1
global filelist

# Directory for buffert files.
set temp $Augustdir
global temp

set current $filelist
global current

set filebuffer($filelist) "$filelist"
global filebuffer

# This variable carries the name of the "Window" menu.
set filesel .ed.mb.button3.m
global filesel

set align "X"
global align

# This is a list of all open files.
set filenamelist [list foo]
global filenamelist

set fsize "X"
global fsize

set tcalign "X"
global tcalign

set tcvalign "X"
global tcvalign

set tralign "X"
global tralign

set trvalign "X"
global trvalign

# weblintversion is used in the weblint_check proc
set weblintversion ""
global weblintversion

# netwin is used in the prev_multi proc.
set netwin 0
global netwin

# konqwin is used in the prev_konqueror proc.
set konqwin 0
global konqwin

# version is used by find & replace dialog.
set version ""
global version

# lastdir is used by file_open_get and other procs.
set lastdir "none"
global lastdir

# konq exp
set fooid 0
global fooid

toplevel .ed
wm title .ed "August (Untitled)"
wm withdraw .
wm geometry .ed  +100+100
# Run prompt_close when user exits main window.
wm protocol .ed WM_DELETE_WINDOW "prompt_close .ed"

# Create frame...

frame .ed.mb -relief raised -borderwidth 1
menubutton .ed.mb.button1 -text "File" -menu .ed.mb.button1.m
menubutton .ed.mb.button2 -text "Edit" -menu .ed.mb.button2.m
menubutton .ed.mb.button3 -text "Window" -menu $filesel
menubutton .ed.mb.button5 -text "Tags" -menu .ed.mb.button5.m
menubutton .ed.mb.buttont -text "Tools" -menu .ed.mb.buttont.m
menubutton .ed.mb.buttonu -text "User" -menu .ed.mb.buttonu.m
menubutton .ed.mb.buttonp -text "Preview" -menu .ed.mb.buttonp.m
menubutton .ed.mb.button6 -text "Help" -menu .ed.mb.button6.m

pack .ed.mb.button1 .ed.mb.button2 .ed.mb.button3 .ed.mb.button5\
.ed.mb.buttont   .ed.mb.buttonu  .ed.mb.buttonp  .ed.mb.button6 -side left

menu .ed.mb.button1.m
menu .ed.mb.button2.m
menu $filesel
menu .ed.mb.button5.m
menu .ed.mb.buttont.m
menu .ed.mb.buttonp.m
menu .ed.mb.buttonu.m
menu .ed.mb.button6.m

.ed.mb.button1.m add command -label "New file (Ctrl-n)" -command "file_new .ed\
  $textname Untitled \$August(tpldialog)"
.ed.mb.button1.m add command -label "Open... (Ctrl-o)" -command "file_open .ed\
  $textname no none"
.ed.mb.button1.m add command -label "Append..." -command "file_insert .ed\
  $textname"
.ed.mb.button1.m add command -label "Reload file" -command "file_reload"
.ed.mb.button1.m add command -label "Save (Ctrl-s)" -command\
  "file_save $textname"
.ed.mb.button1.m add command -label "Save As..." -command\
  "file_save_as $textname"
 .ed.mb.button1.m add command -label "Save all files" -command\
  "save_all_files"
.ed.mb.button1.m add command -label "Print" -command "print_doc"
.ed.mb.button1.m add command -label "Close file (Ctrl-w)" -command\
  "file_close $textname yes"
.ed.mb.button1.m add command -label "Close all files" -command "exit_files no"
.ed.mb.button1.m add command -label "Exit (Ctrl-q)" -command {exit_files yes}

.ed.mb.button2.m add command -label "Undo (Ctrl-z)" -command\
  {undo}
.ed.mb.button2.m add command -label "Cut (Ctrl-x)" -command\
  {tk_textCut $textname}
.ed.mb.button2.m add command -label "Copy (Ctrl-c)" -command\
  {tk_textCopy $textname}
.ed.mb.button2.m add command -label "Paste (Ctrl-v)" -command\
  {tk_textPaste $textname; run_tags}
.ed.mb.button2.m add command -label "Find... (Ctrl-f)" -command\
  {set version find;  SearchDialog $textname}
.ed.mb.button2.m add command -label "Replace... (Ctrl-r)" -command\
  {set version replace; SearchDialog $textname}
.ed.mb.button2.m add command -label "Go to line... (Ctrl-g)" -command {go_to}
.ed.mb.button2.m add command -label "Select all (Ctrl-/)" -command\
  {$textname tag add sel 1.0 end}
.ed.mb.button2.m add command -label "August options (F6)" -command {set_options}
pack .ed.mb -side top -fill x

# Add stuff to tags menu.

.ed.mb.button5.m add command -label "Basic structure" -command {insert_basic}

.ed.mb.button5.m add cascade -label "Misc" -menu .ed.mb.button5.m.misc

menu .ed.mb.button5.m.misc

.ed.mb.button5.m.misc add command -label "Html 4.0 prologue" -command {insert_code [set c\
{<!DOCTYPE HTML PUBLIC  "-//W3C//DTD HTML 4.0//EN">}]}
.ed.mb.button5.m.misc add command -label "Script" -command {formating <SCRIPT>\
  </SCRIPT>}
.ed.mb.button5.m.misc add command -label "Code" -command {formating <CODE>\
  </CODE>}
.ed.mb.button5.m.misc add command -label "Quote" -command {formating <Q>\
  </Q>}
.ed.mb.button5.m.misc add command -label "Address" -command\
  {formating <ADRESS> </ADRESS>}
.ed.mb.button5.m.misc add command -label "Definition" -command\
  {formating <DFN> </DFN>}
.ed.mb.button5.m.misc add command -label "Keyboard" -command {formating <KBD>\
  </KBD>}
.ed.mb.button5.m.misc add command -label "Sample" -command {formating <SAMP>\
  </SAMP>}
.ed.mb.button5.m.misc add command -label "Variable" -command {formating <VAR>\
  </VAR>}
.ed.mb.button5.m.misc add command -label "Nobreak" -command {formating <NOBR>\
  </NOBR>}
.ed.mb.button5.m.misc add command -label "Wordbreak" -command {formating <WBR>\
  </WBR>}
.ed.mb.button5.m.misc add command -label "Big" -command {formating <BIG> </BIG>}
.ed.mb.button5.m.misc add command -label "Small" -command {formating <SMALL>\
  </SMALL>}

.ed.mb.button5.m add cascade -label "Style sheets" -menu .ed.mb.button5.m.style

menu .ed.mb.button5.m.style

.ed.mb.button5.m.style add command -label "Style" -command {insert_code [set c\
{<STYLE TYPE="text/css"></STYLE>}]; set_cur "insert-8c"}
.ed.mb.button5.m.style add command -label "Style/Import" -command {insert_code [set c\
{<STYLE TYPE="text/css">
   @import url ()
</STYLE>}]; set_cur "insert-10c"}
.ed.mb.button5.m.style add command -label "Style/Link" -command {insert_code [set c\
{<LINK REL=STYLESHEET  TYPE="text/css" HREF="" TITLE="">}]; set_cur "insert-11c"}

.ed.mb.button5.m add cascade -label "Special chars" -menu .ed.mb.button5.m.chars

menu .ed.mb.button5.m.chars

.ed.mb.button5.m.chars add command -label "" -command {insert_code "&copy;"}
.ed.mb.button5.m.chars add command -label "" -command {insert_code "&reg;"}
.ed.mb.button5.m.chars add command -label "&" -command {insert_code "&amp;"}
.ed.mb.button5.m.chars add command -label "<" -command {insert_code "&lt;"}
.ed.mb.button5.m.chars add command -label ">" -command {insert_code "&gt;"}

.ed.mb.button5.m add cascade -label "Forms" -menu .ed.mb.button5.m.form

menu .ed.mb.button5.m.form

.ed.mb.button5.m.form add cascade -label "Form"\
  -menu .ed.mb.button5.m.form.forms

menu .ed.mb.button5.m.form.forms

.ed.mb.button5.m.form.forms add command -label "Get" -command {insert_code\
  [set c {<FORM ACTION="" METHOD="GET"></FORM>}]; set_cur "insert-22c"}

.ed.mb.button5.m.form.forms add command -label "Post" -command {insert_code\
  [set c {<FORM ACTION="" METHOD="POST"></FORM>}]; set_cur "insert-23c"}


.ed.mb.button5.m.form add cascade -label "Input"\
  -menu .ed.mb.button5.m.form.input

menu .ed.mb.button5.m.form.input

.ed.mb.button5.m.form.input add command -label "Text" -command {insert_code\
  [set c {<INPUT TYPE="TEXT" NAME="" VALUE="" SIZE="" MAXLENGTH="">}]; set_cur "insert-32c"}

.ed.mb.button5.m.form.input add command -label "Password" -command\
  {insert_code [set c {<INPUT TYPE="PASSWORD" NAME="" VALUE="" SIZE=""\
  MAXLENGTH="">}]; set_cur "insert-32c"}

.ed.mb.button5.m.form.input add command -label "Checkbox" -command\
  {insert_code [set c {<INPUT TYPE="CHECKBOX" NAME="" VALUE="">}]; set_cur "insert-11c"}

.ed.mb.button5.m.form.input add command -label "Radio" -command {insert_code\
  [set c {<INPUT TYPE="RADIO" NAME="" VALUE="">}]; set_cur "insert-11c"}

.ed.mb.button5.m.form.input add command -label "Button" -command {insert_code\
  [set c {<INPUT TYPE="BUTTON" VALUE="" ONCLICK="">}]; set_cur "insert-13c"}

.ed.mb.button5.m.form.input add command -label "Image" -command {insert_code\
  [set c {<INPUT TYPE="IMAGE" SRC="" ALT="">}]; set_cur "insert-9c"}

.ed.mb.button5.m.form.input add command -label "Hidden" -command {insert_code\
  [set c {<INPUT TYPE="HIDDEN" NAME="" VALUE="">}]; set_cur "insert-11c"}

.ed.mb.button5.m.form.input add command -label "Submit" -command {insert_code\
  [set c {<INPUT TYPE="SUBMIT" VALUE="">}]; set_cur "insert-2c"}

.ed.mb.button5.m.form.input add command -label "Reset" -command {insert_code\
  [set c {<INPUT TYPE="RESET" VALUE="">}]; set_cur "insert-2c"}

.ed.mb.button5.m.form add cascade -label "Select"\
  -menu .ed.mb.button5.m.form.select

menu .ed.mb.button5.m.form.select

.ed.mb.button5.m.form.select add command -label "Select 1" -command\
  {insert_code [set c {<SELECT NAME="">
<OPTION></OPTION>
<OPTION></OPTION>
</SELECT>}]; set_cur "insert-48c"}

.ed.mb.button5.m.form.select add command -label "Select 2" -command\
  {insert_code [set c {<SELECT NAME="" MULTIPLE SIZE="">
<OPTION VALUE=""></OPTION>
<OPTION VALUE=""></OPTION>
</SELECT>}]; set_cur "insert-83c"}

.ed.mb.button5.m.form add cascade -label "Textarea"\
  -menu .ed.mb.button5.m.form.area

menu .ed.mb.button5.m.form.area

.ed.mb.button5.m.form.area add command -label "Textarea" -command {insert_code\
  [set c {<TEXTAREA NAME="" COLS="" ROWS="">}]; set_cur "insert-18c"}

.ed.mb.button5.m.form.area add command -label "Disabled textarea" -command\
  {insert_code [set c {<TEXTAREA NAME="" COLS="" ROWS="" DISABLED>}]; set_cur "insert-27c"}

.ed.mb.button5.m.form.area add command -label "Readonly textarea" -command\
  {insert_code [set c {<TEXTAREA NAME="" COLS="" ROWS="" READONLY>}]; set_cur "insert-27c"}

.ed.mb.button5.m add cascade -label "Frames" -menu .ed.mb.button5.m.frame

menu .ed.mb.button5.m.frame

.ed.mb.button5.m.frame add command -label "Frameset-cols" -command {insert_code [set c {<FRAMESET COLS=""> </FRAMESET>}]; set_cur "insert-14c"}
.ed.mb.button5.m.frame add command -label "Frameset-rows" -command {insert_code [set c {<FRAMESET ROWS=""> </FRAMESET>}]; set_cur "insert-14c"}
.ed.mb.button5.m.frame add command -label "Frameset-No border" -command {insert_code [set c {<FRAMESET COLS=""\
FRAMEBORDER="0" BORDER="no" FRAMESPACING="0"> </FRAMESET>}]; set_cur "insert-59c"}
.ed.mb.button5.m.frame add command -label "Noframes" -command {insert_code [set c {<NOFRAMES> </NOFRAMES>}]; set_cur "insert-12c"}
.ed.mb.button5.m.frame add command -label "Frame src" -command {insert_code [set c {<FRAME SRC="" NAME="">}]; set_cur "insert-10c"}
.ed.mb.button5.m.frame add command -label "Floating frame" -command {insert_code [set c {<IFRAME SRC="" NAME=""\
WIDTH="" HEIGHT="" ALIGN=""> </IFRAME>}]; set_cur "insert-48c"}
.ed.mb.button5.m.frame add command -label "Frameborder" -command {insert_code [set c {FRAMEBORDER=""}]; set_cur "insert-1c"}
.ed.mb.button5.m.frame add command -label "Marginwidth" -command {insert_code [set c {MARGINWIDTH=""}]; set_cur "insert-1c"}
.ed.mb.button5.m.frame add command -label "Marginheight" -command {insert_code [set c {MARGINHEIGHT=""}]; set_cur "insert-1c"}
.ed.mb.button5.m.frame add command -label "Scrolling" -command {insert_code [set c {SCROLLING=""}]; set_cur "insert-1c"}
 .ed.mb.button5.m.frame add command -label "Noresize" -command {insert_code [set c {NORESIZE=""}]; set_cur "insert-1c"}


# Tools menu.

      .ed.mb.buttont.m add command -label "Manage User menu... (F3)" -command {manage_tags}
      .ed.mb.buttont.m add command -label "Create template" -command {create_template}
      .ed.mb.buttont.m add command -label "Use template (F2)" -command {use_template}
      .ed.mb.buttont.m add command -label "Remove tags" -command {remove_tags}
      .ed.mb.buttont.m add cascade -label "Case" -menu .ed.mb.buttont.m.case
      .ed.mb.buttont.m add command -label "Remove tabs (keep format)" -command {remove_tabs yes}
      .ed.mb.buttont.m add command -label "Remove tabs (remove format)" -command {remove_tabs no}
      .ed.mb.buttont.m add command -label "Weblint check (F4)" -command {weblint_check}
      .ed.mb.buttont.m add cascade -label "Insert date/time" -menu .ed.mb.buttont.m.datetime

      menu .ed.mb.buttont.m.case
      menu .ed.mb.buttont.m.datetime

     .ed.mb.buttont.m.case add command -label "Uppercase" -command\
     {change_case toupper}
     .ed.mb.buttont.m.case add command -label "Lowercase" -command\
     {change_case tolower}

     .ed.mb.buttont.m.datetime add command -label "Date" -command\
     {insert_date_time date}
      .ed.mb.buttont.m.datetime add command -label "Time" -command\
     {insert_date_time time}
      .ed.mb.buttont.m.datetime add command -label "Date + Time" -command\
     {insert_date_time date_time}

# User configurable menu.

      for {set m 1} {$m < 100} {incr m} {
      set mvar [array get August u$m]
    if  {$mvar != ""} then {
      set tagstat [llength $August(u$m)]
   }
     if {$mvar != "" && $tagstat == "3"} then {
     .ed.mb.buttonu.m add command -label "[lindex $August(u$m) 0]" -command "formating {[lindex $August(u$m) 1]} {[lindex $August(u$m) 2]}"
    } elseif  {$mvar != "" && $tagstat == "2"} then {
     .ed.mb.buttonu.m add command -label "[lindex $August(u$m) 0]" -command "insert_code {[lindex $August(u$m) 1]}"
    } else {
 #    break
    }
 }

 # Preview menu

 .ed.mb.buttonp.m add command -label "Netscape/IExplorer... (F9)" -command {prev_multi}
 .ed.mb.buttonp.m add command -label "Konqueror...(experimental...) (F10) " -command {prev_konqueror}
 .ed.mb.buttonp.m add command -label "Lynx... (F11)" -command {prev_lynx}
 .ed.mb.buttonp.m add command -label "Kdehelp... (F12)" -command {prev_kdehelp}

# Help menu

.ed.mb.button6.m add command -label "August help (F1)" -command {get_help}
.ed.mb.button6.m add command -label "License info" -command {about_lic}
.ed.mb.button6.m add command -label "About August..." -command {about_box}


# New frame

frame .ed.bt1 -relief raised -borderwidth 1

button .ed.bt1.button1 -image fexit -command "exit_files yes"
button .ed.bt1.button2 -image cls -command "file_close $textname yes"
button .ed.bt1.button3 -image filenew -command "file_new .ed $textname Untitled  \$August(tpldialog)"
button .ed.bt1.button4 -image fopen -command "file_open .ed $textname no none"
button .ed.bt1.button5 -image fsave -command "file_save $textname"
button .ed.bt1.button6 -image fsaveas -command "file_save_as $textname"
button .ed.bt1.button7 -image cut -command {tk_textCut $textname}
button .ed.bt1.button8 -image copy -command {tk_textCopy $textname}
button .ed.bt1.button9 -image paste -command {tk_textPaste $textname}
button .ed.bt1.button10 -image bold -command {formating <$August(bold)>\
  </$August(bold)>}
button .ed.bt1.button11 -image italics -command {formating <$August(ital)>\
  </$August(ital)>}
button .ed.bt1.button12 -image underlin -command {formating <U> </U>}
button .ed.bt1.button13 -image tt -command {formating <TT> </TT>}
button .ed.bt1.button14 -image pre -command {formating <PRE> </PRE>}
button .ed.bt1.button15 -image p -command {insert_code <P>}
button .ed.bt1.button16 -image br -command {insert_code <BR>}
button .ed.bt1.button17 -image comment -command {formating <!-- -->}
button .ed.bt1.button18 -image help -command {get_help}

pack .ed.bt1.button1 .ed.bt1.button2 .ed.bt1.button3 .ed.bt1.button4\
  .ed.bt1.button5 .ed.bt1.button6 .ed.bt1.button7 .ed.bt1.button8\
  .ed.bt1.button9 .ed.bt1.button10 .ed.bt1.button11 .ed.bt1.button12\
  .ed.bt1.button13 .ed.bt1.button14 .ed.bt1.button14 .ed.bt1.button15\
  .ed.bt1.button16 .ed.bt1.button17 .ed.bt1.button18 -padx 1 -side left

pack .ed.bt1 -side top -fill x

# Another frame.

frame .ed.bt2 -relief raised -borderwidth 1

button .ed.bt2.button1 -image color -command {color_code_insert $textname}
button .ed.bt2.button2 -image fontc -command {font_style}
button .ed.bt2.button3 -image pict -command {get_pict}
button .ed.bt2.button4 -image link -command {formating [set f1\
  {<A HREF="}] [set f2 {"></A>}]}
button .ed.bt2.button5 -image mailsend -command {insert_code [set c\
  {<A HREF="mailto:"></A>}]; set_cur "insert-6c"}
button .ed.bt2.button6 -image numlist -command {insert_code [set c {<OL>
<LI>
</OL>}]}
button .ed.bt2.button7 -image bulllist -command {insert_code [set c {<UL>
<LI>
</UL>}]}
button .ed.bt2.button7b -image deflist -command {insert_code [set c {<DL>
<DT>
<DD>
</DL>}]}
button .ed.bt2.button8 -image ins -command {insert_code [set c {<LI>}]}
button .ed.bt2.button9 -image left -command {formating [set f1\
  {<DIV ALIGN="LEFT">}] [set f2 {</DIV>}]}
button .ed.bt2.button10 -image center -command {formating [set f1 <CENTER>]\
  [set f2 </CENTER>]}
button .ed.bt2.button11 -image right -command {formating [set f1\
  {<DIV ALIGN="RIGHT">}] [set f2 {</DIV>}]}
button .ed.bt2.button12 -image justify -command {formating [set f1\
  {<DIV ALIGN="JUSTIFY">}] [set f2 {</DIV>}]}
button .ed.bt2.button13 -image table -command {build_table}
button .ed.bt2.button14 -image rowspan -command {insert_code [set c\
  {ROWSPAN=""}]}
button .ed.bt2.button15 -image colspan -command {insert_code [set c\
  {COLSPAN=""}]}
button .ed.bt2.button16 -image tablec -command "insert_code [set c\
  {BGCOLOR="[tk_chooseColor]"}]"
button .ed.bt2.button17 -image tpl -command {use_template}

pack .ed.bt2.button1 .ed.bt2.button2 .ed.bt2.button3 .ed.bt2.button4\
  .ed.bt2.button5 .ed.bt2.button6 .ed.bt2.button7 .ed.bt2.button7b\
  .ed.bt2.button8 .ed.bt2.button9 .ed.bt2.button10 .ed.bt2.button11\
  .ed.bt2.button12 .ed.bt2.button13 .ed.bt2.button14 .ed.bt2.button15\
  .ed.bt2.button16 .ed.bt2.button17 -padx 1 -side left
pack .ed.bt2 -side top -fill x

# Third button frame.

# This frame is for the textwidget to hang on to...

frame .ed.bt3 -relief raised -borderwidth 1

frame .ed.bbar -relief raised -borderwidth 1

button .ed.bbar.button1 -image h1h2 -command {formating <H1> </H1>}
button .ed.bbar.button2 -image h3h4 -command  {formating <H3> </H3>}
button .ed.bbar.button3 -image h5h6 -command  {formating <H5> </H5>}
button .ed.bbar.button4 -image block -command  {formating <BLOCKQUOTE> </BLOCKQUOTE>}
button .ed.bbar.button5 -image ag -command {notice_box "This button is not used yet."}
button .ed.bbar.button6 -image ag -command {notice_box "This button is not used yet."}
button .ed.bbar.button7 -image ag -command {notice_box "This button is not used yet."}
button .ed.bbar.button8 -image ag -command {notice_box "This button is not used yet."}
button .ed.bbar.button9 -image ag -command {notice_box "This button is not used yet."}
button .ed.bbar.button10 -image ag -command {notice_box "This button is not used yet."}
button .ed.bbar.button11 -image ag -command {notice_box "This button is not used yet."}

grid .ed.bbar.button1  -row 1 -column 1   -sticky n
grid .ed.bbar.button2  -row 2 -column 1   -sticky n
grid .ed.bbar.button3  -row 3 -column 1    -sticky n
grid .ed.bbar.button4  -row 4 -column 1    -sticky n
grid .ed.bbar.button5  -row 5 -column 1    -sticky n
grid .ed.bbar.button6  -row 6 -column 1    -sticky n
grid .ed.bbar.button7  -row 7 -column 1    -sticky n
grid .ed.bbar.button8  -row 8 -column 1    -sticky n
grid .ed.bbar.button9  -row 9 -column 1    -sticky n
grid .ed.bbar.button10  -row 10 -column 1    -sticky n
grid .ed.bbar.button11  -row 11 -column 1    -sticky n

pack .ed.bt3  -side top  -expand yes -fill both
pack .ed.bbar  -side left  -in  .ed.bt3  -expand no -anchor n  -in  .ed.bt3

# Set up frame for text edit

frame .ed.te -relief raised -borderwidth 2
scrollbar .ed.te.vscroll -relief sunken -command "after idle run_tags; .ed.te.edit1 yview"
scrollbar .ed.te.hscroll -relief sunken -orient horizontal -command ".ed.te.edit1 xview"
text $textname -yscroll ".ed.te.vscroll set" -xscroll ".ed.te.hscroll set" -background white\
  -foreground black -exportselection true -wrap $August(wrap) -font "$August(font) $August(fontsize)" -width 30 -height 10

pack .ed.te.vscroll -side right -fill both
pack .ed.te.hscroll -side bottom -fill x
pack .ed.te.edit1  -side top -fill both -expand yes -padx 1 -pady 1
pack .ed.te -side top -fill both -expand yes  -in  .ed.bt3

# Status area

frame .ed.sa -relief raised -borderwidth 2
label .ed.sa.status2 -relief sunken -anchor w -borderwidth 1 -width 12 -text ""
label .ed.sa.status3 -relief sunken -anchor w -borderwidth 1 -width 12 -text ""
pack  .ed.sa.status2  .ed.sa.status3 -side left -padx 2 -pady 1 -fill x
pack .ed.sa -side bottom -fill x

# Balloon help

proc balloon_help {w msg} {
bind $w <Enter> "after 1000 \"balloon_aux %W [list $msg]\""
bind $w <Leave> "after cancel \"balloon_aux %W [list $msg]\"
after 100 {catch {destroy .ed.balloon_help}}"
}

proc balloon_aux {w msg} {
set t .ed.balloon_help
catch {destroy $t}
toplevel $t
wm overrideredirect $t 1
pack [label $t.l -text $msg -relief groove -bd 1 -bg gold] -fill both
set x [expr [winfo rootx $w]+6+[winfo width $w]/2]
set y [expr [winfo rooty $w]+6+[winfo height $w]/2]
wm geometry $t +$x\+$y
bind $t <Enter> {after cancel {catch {destroy .balloon_help}}}
bind $t <Leave> "catch {destroy .balloon_help}"
}

balloon_help .ed.bt1.button1   "EXIT"
balloon_help .ed.bt1.button2   "CLOSE FILE"
balloon_help .ed.bt1.button3   "NEW FILE"
balloon_help .ed.bt1.button4   "OPEN"
balloon_help .ed.bt1.button5   "SAVE"
balloon_help .ed.bt1.button6   "SAVE AS"
balloon_help .ed.bt1.button7   "CUT"
balloon_help .ed.bt1.button8   "COPY"
balloon_help .ed.bt1.button9   "PASTE"
balloon_help .ed.bt1.button10 "BOLD"
balloon_help .ed.bt1.button11 "ITALICS"
balloon_help .ed.bt1.button12  "UNDERLINE"
balloon_help .ed.bt1.button13  "TELETYPE"
balloon_help .ed.bt1.button14  "PREFORMATTED"
balloon_help .ed.bt1.button15  "PARAGRAPH/RIGHT BTN: CONTAINER STYLE"
balloon_help .ed.bt1.button16  "LINEBREAK/RIGHT BTN: HORIZONTAL RULE"
balloon_help .ed.bt1.button17   "COMMENT"
balloon_help .ed.bt1.button18   "HELP"
balloon_help .ed.bt2.button1     "INSERT COLOR"
balloon_help .ed.bt2.button2     "FONT SIZE AND COLOR/RIGHT BTN: BASEFONT"
balloon_help .ed.bt2.button3     "INSERT PICTURE"
balloon_help .ed.bt2.button4     "WWW LINK/RIGHT BTN: ANCHOR/3RD BTN: LOCAL LINK"
balloon_help .ed.bt2.button5     "MAILTO"
balloon_help .ed.bt2.button6     "NUMBERED LIST"
balloon_help .ed.bt2.button7     "BULLET LIST"
balloon_help .ed.bt2.button7b   "DEFINITION LIST"
balloon_help .ed.bt2.button8     "INSERT LIST ITEM/RIGHT BTN: DEFINITION"
balloon_help .ed.bt2.button9     "LEFT"
balloon_help .ed.bt2.button10   "CENTER"
balloon_help .ed.bt2.button11   "RIGHT"
balloon_help .ed.bt2.button12   "JUSTIFY"
balloon_help .ed.bt2.button13   "TABLE/RIGHT BTN: CELL/3RD BTN: ROW"
balloon_help .ed.bt2.button14   "ROWSPAN"
balloon_help .ed.bt2.button15    "COLUMNSPAN"
balloon_help .ed.bt2.button16    "BG COLOR"
balloon_help .ed.bt2.button17    "USE TEMPLATE"
balloon_help .ed.bbar.button1    "H1/RIGHT BTN: H2"
balloon_help .ed.bbar.button2    "H3/RIGHT BTN: H4"
balloon_help .ed.bbar.button3    "H5/RIGHT BTN: H6"
balloon_help .ed.bbar.button4    "BLOCKQUOTE"
balloon_help .ed.bbar.button5    "NOT USED YET"
balloon_help .ed.bbar.button6    "NOT USED YET"
balloon_help .ed.bbar.button7    "NOT USED YET"
balloon_help .ed.bbar.button8    "NOT USED YET"
balloon_help .ed.bbar.button9    "NOT USED YET"
balloon_help .ed.bbar.button10  "NOT USED YET"
balloon_help .ed.bbar.button11  "NOT USED YET"

# Key bindings

# Uncomment this to see name of the key pressed.
# bind all <Key> {notice_box "Key %K pressed"}

# Wish I knew what happens here!:-)
bindtags $textname "Text $textname . all"

bind Text <Control-v> {}
bind Text <Control-o> {}
event add <<Paste>> <Control-v>
bind $textname <Control-v> {+ run_tags}
event add <<Paste>> <Button-3>
bind $textname <Control-n> "file_new .ed $textname Untitled  \$August(tpldialog)"
bind $textname <Control-o> "file_open .ed $textname no none"
bind $textname <Control-s> "file_save $textname"
bind $textname <Control-w> "file_close $textname yes"
bind all <Control-q> "exit_files yes"
bind $textname <Control-f> {set version find; SearchDialog $textname}
bind $textname <Control-r> {set version replace; SearchDialog $textname}
bind $textname <Control-g> "go_to"
bind $textname <Control-z> "undo"
bind all <F1> {get_help}
bind $textname <F2> {use_template}
bind $textname <F3> {manage_tags}
bind $textname <F4> {weblint_check}
bind $textname <F5> {run_tags}
bind $textname <F6> {set_options}
bind $textname <F9> {prev_multi}
bind $textname <F10> {prev_konqueror}
bind $textname <F11> {prev_lynx}
bind $textname <F12> {prev_kdehelp}

bind .ed.bt2.button2 <Button-3> {insert_code [set c\
{<BASEFONT SIZE="">}]; set_cur "insert-2c"}
bind .ed.bt2.button4 <Button-2> get_local
bind .ed.bt2.button4 <Button-3> {insert_code {<A NAME=""></A>}; set_cur "insert-6c"}
bind .ed.bt2.button8 <Button-3> {insert_code {<DT>
<DD>}}
bind .ed.bt2.button13 <Button-3> {table_cell}
bind .ed.bt2.button13 <Button-2> {table_row}
bind .ed.bt1.button16  <Button-3> {insert_code <HR>}
bind .ed.bt1.button15  <Button-3> {formating <P> </P>}
bind .ed.bbar.button1  <Button-3> {formating <H2> </H2>}
bind .ed.bbar.button2  <Button-3> {formating <H4> </H4>}
bind .ed.bbar.button3  <Button-3> {formating <H6> </H6>}

bind $textname <Return> {after idle run_tags}
bind $textname <Key-space> {after idle run_tags}
bind $textname <Prior> {after idle run_tags}
bind $textname <Next> {after idle run_tags}
bind $textname <End> {run_tags}
bind $textname <Home> {run_tags}
bind .ed.te.edit1 <Configure> {after idle run_tags}
bind $textname <Delete> {after idle run_tags}
bind $textname <Control-z> {+ after idle run_tags}

#  Swedish

proc swe_chars { } {
global textname
bind $textname <odiaeresis> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&ouml;"}
bind $textname <Odiaeresis> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Ouml;"}
bind $textname <adiaeresis> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&auml;"}
bind $textname <Adiaeresis> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&Auml;"}
bind $textname <aring> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&aring;"}
bind $textname <Aring> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&Aring;"}
   }

proc italian_chars { } {
global textname
bind $textname <agrave> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&agrave;"}
bind $textname <Agrave> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Agrave;"}
bind $textname <egrave> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&egrave;"}
bind $textname <Egrave> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&Egrave;"}
bind $textname <eacute> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&eacute;"}
bind $textname <Eacute> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&Eacute;"}
bind $textname <igrave> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&igrave;"}
bind $textname <Igrave> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&Igrave;"}
bind $textname <ograve> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&ograve;"}
bind $textname <Ograve> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&Ograve;"}
bind $textname <ugrave> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&ugrave;"}
bind $textname <Ugrave> {$textname delete  "[$textname index insert] -1 chars"; $textname insert insert "&Ugrave;"}
   }

proc spanish_chars { } {
global textname
bind $textname <aacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&aacute;"}
bind $textname <Aacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Aacute;"}
bind $textname <eacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&eacute;"}
bind $textname <Eacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Eacute;"}
bind $textname <iacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&iacute;"}
bind $textname <Iacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Iacute;"}
bind $textname <oacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&oacute;"}
bind $textname <Oacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Oacute;"}
bind $textname <uacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&uacute;"}
bind $textname <Uacute> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Uacute;"}
bind $textname <udiaeresis> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&uuml;"}
bind $textname <Udiaeresis> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Uuml;"}
bind $textname <ntilde> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&ntilde;"}
bind $textname <Ntilde> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&Ntilde;"}
bind $textname <guillemotleft> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&laquo;"}
bind $textname <guillemotright> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&raquo;"}
bind $textname <exclamdown> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&iexcl;"}
bind $textname <questiondown> {$textname delete  "[$textname  index insert] -1 chars"; $textname insert insert "&iquest;"}
   }

if {$August(specchars) == "swedish"} then {
swe_chars
}

if {$August(specchars) == "italian"} then {
italian_chars
}

if {$August(specchars) == "spanish"} then {
spanish_chars
}

# Help window

proc get_help {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .hlpbox] == 1 } then {
	wm deiconify .hlpbox
	return
	}
    catch {
	set hlp .hlpbox
	toplevel $hlp
	dialog_position $hlp
	wm protocol $hlp WM_DELETE_WINDOW "destroy $hlp"
	wm title $hlp {HELP}
	frame .hlpbox.tx
	scrollbar .hlpbox.tx.scroll -relief sunken -command\
	  ".hlpbox.tx.text yview"
	text .hlpbox.tx.text -yscroll ".hlpbox.tx.scroll set"
	.hlpbox.tx.text configure -height 30 -width 60 -background white\
	  -exportselection true -wrap word

	pack .hlpbox.tx.scroll -side right -fill y
	pack .hlpbox.tx.text -side left -expand yes -fill both
	pack .hlpbox.tx -side top  -expand yes -fill both

	focus .hlpbox.tx.text

	frame .hlpbox.bt
	button .hlpbox.bt.button1 -text "Close" -command "destroy $hlp"
	pack .hlpbox.bt   -padx 5 -pady 5
	pack .hlpbox.bt.button1

	.hlpbox.tx.text insert insert "          AUGUST HELP\n"
	.hlpbox.tx.text insert insert {

Get the latest version of August from:
http://www.lls.se/~johanb/august/
Please send bug reports etc. to:
johanb@lls.se

         PROBLEMS THAT MAY OCCUR

1. Netscape preview doesn't work

Solution 1: Set correct path to the browser executable in
"Edit" --> "August options".

Solution 2: If Netscape is closed after the first preview
it won't start again when you press the preview button.
If you do this you will have to start Netscape manually to
make it work again. There is no reason to close Netscape
after a preview, the changed page will appear in the old
Netscape window!

2. Lynx preview doesn't work.

Solution: Try and change the the "Lynx terminal"
setting in  "Edit" --> "August options".

3. The automatic setting of width and height in the
"Insert image" dialog doesn't work.

Solution: The Image Magick program must be installed
on your system for this to work. This function uses the
Image Magick command "identify" to get the width & height of
the image. If Image Magick is installed and it's still not
working, the problem is probably that the "identify" command
is not in your path. If that is the case, set the correct path in
"Edit" --> "August options".

4. A user in Japan reported that August has trouble displaying
double-byte characters (Japanese).

Solution: Go to the options dialog and switch font to "misc".

5. Syntax checking doesn't work.

Solution: Is weblint installed and
in your path?

                AUGUST DIRECTORY

When started for the first time, August will create
a hidden sub directory called .August in your home
directory. August will store buffer files, user
options and create a template directory there. 
If you are doing a backup of your system remember
to save the contents of the templates directory if
you have created any templates you want to keep.

               AUGUST OPTIONS

From the "Edit" menu you can bring up the options
dialog that allows you to customize some of August's
behaviour. You can set document path, path to the
netscape executable and some other things.

                   TOOLBAR

To see what the buttons in the toolbar can do for you,
hold the mouse pointer over them and a message will be
displayed in the status bar. Note that you can use the 
right mouse button on some buttons.

                  TEMPLATES

You can create templates of commonly used code with 
the "Create template" command in the "Tools" menu.
The "Use template" dialog will be shown automatically
every time you create a new file. This behaviour can be 
turned off in the August options dialog.

	COMMAND LINE OPTIONS

You can start August from the command line:

august foo.htm

You can also start August with the -all flag, this means
that all *.htm, *.html, *.css and *.txt files in the current
directory will be opened in August:

august -all

Display help message about command line options:

august -hlp


                   BUTTONS

}
	.hlpbox.tx.text image create insert -image fexit
	.hlpbox.tx.text insert insert "Exit editor and close all files.\n"
	.hlpbox.tx.text image create insert -image cls
	.hlpbox.tx.text insert insert "Close file.\n"
	.hlpbox.tx.text image create insert -image filenew
	.hlpbox.tx.text insert insert "Create new file.\n"
	.hlpbox.tx.text image create insert -image fopen
	.hlpbox.tx.text insert insert "Open a file.\n"
	.hlpbox.tx.text image create insert -image fsave
	.hlpbox.tx.text insert insert "Save file.\n"
	.hlpbox.tx.text image create insert -image fsaveas
	.hlpbox.tx.text insert insert "Save file as...\n"
	.hlpbox.tx.text image create insert -image cut
	.hlpbox.tx.text insert insert "Cut out text to clipboard.\n"
	.hlpbox.tx.text image create insert -image copy
	.hlpbox.tx.text insert insert "Copy text to clipboard.\n"
	.hlpbox.tx.text image create insert -image paste
	.hlpbox.tx.text insert insert "Paste text into editor.\n"
	.hlpbox.tx.text image create insert -image bold
	.hlpbox.tx.text insert insert "Wrap text with tags for bold text.\n"
	.hlpbox.tx.text image create insert -image italics
	.hlpbox.tx.text insert insert "Wrap text with tags for italic text.\n"
	.hlpbox.tx.text image create insert -image underlin
	.hlpbox.tx.text insert insert "Wrap text with tags for underlined\
	  text.\n"
	.hlpbox.tx.text image create insert -image tt
	.hlpbox.tx.text insert insert "Wrap text with tags for typewriter\
	  text.\n"
	.hlpbox.tx.text image create insert -image pre
	.hlpbox.tx.text insert insert "Wrap text with tags for preformated\
	  text.\n"
	.hlpbox.tx.text image create insert -image p
	.hlpbox.tx.text insert insert "Start a new paragraph.\n
Right mouse button: Container style.\n"
	.hlpbox.tx.text image create insert -image br
	.hlpbox.tx.text insert insert "Insert a linebreak.\n"
	.hlpbox.tx.text image create insert -image comment
	.hlpbox.tx.text insert insert "Insert a comment in your code.\n"
	.hlpbox.tx.text image create insert -image help
	.hlpbox.tx.text insert insert "Read this help file.\n"
	.hlpbox.tx.text insert insert "\n"
	.hlpbox.tx.text image create insert -image color
	.hlpbox.tx.text insert insert "Insert RGB color value.\n"
	.hlpbox.tx.text image create insert -image fontc
	.hlpbox.tx.text insert insert "Set font size and color.\n"
	.hlpbox.tx.text image create insert -image pict
	.hlpbox.tx.text insert insert "Image dialog.\n"
	.hlpbox.tx.text image create insert -image link
	.hlpbox.tx.text insert insert "Create WWW link. \n
Right mouse button: Create anchor. 3rd button: Create a local link.\n"
	.hlpbox.tx.text image create insert -image mailsend
	.hlpbox.tx.text insert insert "Create link for sending mail.\n"
	.hlpbox.tx.text image create insert -image numlist
	.hlpbox.tx.text insert insert "Create a numbered list.\n"
	.hlpbox.tx.text image create insert -image bulllist
	.hlpbox.tx.text insert insert "Create a bullet list.\n"
	.hlpbox.tx.text image create insert -image deflist
	.hlpbox.tx.text insert insert "Create a definition list.\n"
	.hlpbox.tx.text image create insert -image ins
	.hlpbox.tx.text insert insert "Insert list item. \n 
Right mouse button: Create entries in definition list.\n"
	.hlpbox.tx.text image create insert -image left
	.hlpbox.tx.text insert insert "Align text to the left.\n"
	.hlpbox.tx.text image create insert -image center
	.hlpbox.tx.text insert insert "Center text.\n"
	.hlpbox.tx.text image create insert -image right
	.hlpbox.tx.text insert insert "Align text to the right \n"
	.hlpbox.tx.text image create insert -image justify
	.hlpbox.tx.text insert insert "Justify text.\n"
	.hlpbox.tx.text image create insert -image table
	.hlpbox.tx.text insert insert "Create table dialog.\n
Right mouse button: Create table cells. \n
3rd mouse button: Create table rows. \n"
	.hlpbox.tx.text image create insert -image rowspan
	.hlpbox.tx.text insert insert "Span table cells in a row.\n"
	.hlpbox.tx.text image create insert -image colspan
	.hlpbox.tx.text insert insert "Span table cells in a column.\n"
	.hlpbox.tx.text image create insert -image tablec
	.hlpbox.tx.text insert insert "Insert bgcolor tag .\n"
	.hlpbox.tx.text image create insert -image tpl
	.hlpbox.tx.text insert insert "Use template .\n"
	.hlpbox.tx.text insert insert {

            KEY BINDINGS IN THE EDITOR

Double-clicking  with  mouse  button  1 selects the
word under the mouse and  positions  the  insertion
cursor  at  the  beginning  of  the word.  Dragging
after a double click will stroke  out  a  selection
consisting of whole words.
Triple-clicking  with  mouse  button  1 selects the
line under the mouse and  positions  the  insertion
cursor  at  the  beginning  of  the line.  Dragging
after a triple click will stroke  out  a  selection
consisting of whole lines.
The  ends of the selection can be adjusted by drag-
ging with mouse button 1 while  the  Shift  key  is
down;   this  will  adjust the end of the selection
that was nearest to the mouse cursor when button  1
was  pressed.   If  the  button  is  double-clicked
before dragging then the selection will be adjusted
in  units  of whole words;  if it is triple-clicked
then the selection will be  adjusted  in  units  of
whole lines.
Clicking  mouse  button 1 with the Control key down
will  reposition  the  insertion   cursor   without
affecting the selection.
The  view in the widget can be adjusted by dragging
with mouse button 2.  If mouse button 2 is  clicked
without  moving  the mouse, the selection is copied
into the text at the position of the mouse  cursor.
The  Insert  key also inserts the selection, but at
the position of the insertion cursor.
If the mouse is dragged out  of  the  widget  while
button  1  is pressed, the entry will automatically
scroll to make more text visible (if there is  more
text  off-screen  on  the side where the mouse left
              the window).
The Left and Right keys move the  insertion  cursor
one  character  to  the  left  or right;  they also
clear any selection in the text.  If Left or  Right
is  typed  with the Shift key down, then the inser-
tion cursor moves and the selection is extended  to
include  the  new character.  Control-Left and Con-
trol-Right move the insertion cursor by words,  and
Control-Shift-Left and Control-Shift-Right move the
insertion cursor  by  words  and  also  extend  the
selection. Meta-b and Meta-f behave  the same as
Control-Left and Control-Right, respectively.
The Up and Down keys move the insertion cursor  one
line  up  or  down  and  clear any selection in the
text.  If Up or Right is typed with the  Shift  key
down,  then  the  insertion  cursor  moves  and the
selection is extended to include the new character.
Control-Up and Control-Down move the insertion cur-
sor by paragraphs (groups  of  lines  separated  by
blank  lines),  and  Control-Shift-Up  and Control-
Shift-Down move the insertion cursor by  paragraphs
and  also extend the selection.  Control-p and Con-
trol-n behave the same  as  Up  and  Down,  respec-
tively.
The  Next  and Prior keys move the insertion cursor
forward or backwards by one screenful and clear any
selection  in  the  text.  If the Shift key is held
down while Next or Prior is typed, then the  selec-
tion  is  extended  to  include  the new character.
              
Home and Control-a move the insertion cursor to the
beginning  of  its  line and clear any selection in
the widget.  Shift-Home moves the insertion  cursor
to  the  beginning of the line and also extends the
              selection to that point.
End and Control-e move the insertion cursor to  the
end of the line and clear any selection in the wid-
get.  Shift-End moves the cursor to the end of  the
line and extends the selection to that point.
Control-Home  and  Meta-< move the insertion cursor
to the beginning of the text and clear  any  selec-
tion  in  the widget.  Control-Shift-Home moves the
insertion cursor to the beginning of the  text  and
also extends the selection to that point.
Control-End and Meta-> move the insertion cursor to
the end of the text and clear any selection in  the
widget.   Control-Shift-End moves the cursor to the
end of the text and extends the selection  to  that
point.
Control-/  selects  the entire contents of the wid-
              get.
Control-\ clears any selection in the widget.
The F16 key (labelled Copy  on  many  Sun  worksta-
tions) or Meta-w copies the selection in the widget
to the clipboard, if there is a selection.
The  Delete  key deletes the selection, if there is
one in the widget.  If there is  no  selection,  it
deletes the character to the right of the insertion
cursor.
Backspace and Control-h delete  the  selection,  if
there  is one in the widget.  If there is no selec-
tion, they delete the character to the left of  the
insertion cursor.
Control-d deletes the character to the right of the
insertion cursor.
Meta-d deletes the word to the right of the  inser-
tion cursor.
Control-k deletes from the insertion cursor to the
end of its line; if the insertion cursor is already
at  the  end  of a line, then Control-k deletes the
newline character.
Meta-backspace and Meta-Delete deletes the word to
the left of the insertion cursor.
Control-x  deletes whatever is selected in the text
widget.
Control-t reverses the order of the two characters
to the right of the insertion cursor.}

	.hlpbox.tx.text configure -state disabled
    }
}

# License information box.

proc about_lic  {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .licbox] == 1 } then {
	wm deiconify .licbox
	return
	}
    catch {
	set lic .licbox
	toplevel $lic
	dialog_position $lic
	wm protocol $lic WM_DELETE_WINDOW "destroy $lic"
	wm title $lic {LICENSE INFORMATION}
	frame .licbox.tx
	scrollbar .licbox.tx.scroll -relief sunken -command\
	  ".licbox.tx.text yview"
	text .licbox.tx.text -yscroll ".licbox.tx.scroll set"
	.licbox.tx.text configure -height 15 -width 40 -background white\
	-exportselection true -wrap word

	pack .licbox.tx.scroll -side right -fill y
	pack .licbox.tx.text -side left -expand yes -fill both
	pack .licbox.tx -side top  -expand yes -fill both

	focus .licbox.tx.text

	frame .licbox.bt
	button .licbox.bt.button1 -text "Close" -command "destroy $lic"
	pack .licbox.bt
	pack .licbox.bt.button1

   .licbox.tx.text insert insert {
   August - HTML Editor for UNIX by Johan Bengtsson
   Copyright (C) 1999 2000 Johan Bengtsson
   E-mail: johanb@lls.se
   Snail mail: Johan Bengtsson, Fangdammsvagen 10,
   433 43 Partille, Sweden.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                   }
                  .licbox.tx.text configure -state disabled
    }

}


# About box.

proc about_box  {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .aboutbox] == 1 } then {
	wm deiconify .aboutbox
	return
	}
    catch {
	set about .aboutbox
	toplevel $about
	dialog_position $about
	wm protocol $about WM_DELETE_WINDOW "destroy $about"
	wm title $about {ABOUT AUGUST}
	frame .aboutbox.tx
	scrollbar .aboutbox.tx.scroll -relief sunken -command\
	  ".aboutbox.tx.text yview"
	text .aboutbox.tx.text -yscroll ".aboutbox.tx.scroll set"
	.aboutbox.tx.text configure -height 15 -width 40 -background white\
	  -exportselection true -wrap word

	pack .aboutbox.tx.scroll -side right -fill y
	pack .aboutbox.tx.text -side left -expand yes -fill both
	pack .aboutbox.tx -side top  -expand yes -fill both

	focus .aboutbox.tx.text

	frame .aboutbox.bt
	button .aboutbox.bt.button1 -text "Close" -command "destroy $about"
	pack .aboutbox.bt
	pack .aboutbox.bt.button1


                .aboutbox.tx.text insert insert  "AUGUST 0.63B"
     .aboutbox.tx.text insert insert {
                                                          Copyright (C) 1999-2001 Johan Bengtsson johanb@lls.se
                                }
                .aboutbox.tx.text insert insert   {
  This program is distributed under the terms of the GNU\
  general public license. See license.txt for more information.

  Homepage: http://www.lls.se/~johanb/august/

  Contributors:

  Charles Vidal
  David L. Moore
  Giancarlo Cappella
  Syntax highlighting is based on code by:
  George P. Staplin.
                               }
                  .aboutbox.tx.text tag add center 1.0 end
                  .aboutbox.tx.text tag configure center -justify center
                  .aboutbox.tx.text tag add green  1.0 2.0
                  .aboutbox.tx.text tag configure green -foreground  #047034
                  .aboutbox.tx.text configure -state disabled
    }

}

# Weblint check

proc weblint_check {} {
        # Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .wlc] == 1 } then {
	wm deiconify .wlc
        wl_check
	return
	}

        global weblintversion
        if {$weblintversion == ""} then {
        catch {exec weblint -v} weblintversion
        set weblintversion [format %33.33s $weblintversion]
        }

        catch {
	toplevel .wlc
	dialog_position .wlc
	wm protocol .wlc WM_DELETE_WINDOW "destroy .wlc"
	wm title .wlc {WEBLINT CHECK}
	frame .wlc.tx
	scrollbar .wlc.tx.scroll -relief sunken -command\
	  ".wlc.tx.text yview"
	text .wlc.tx.text -yscroll ".wlc.tx.scroll set"
	.wlc.tx.text configure -height 30 -width 60 -background white\
	  -exportselection true -wrap word

	pack .wlc.tx.scroll -side right -fill y
	pack .wlc.tx.text -side left -expand yes -fill both
	pack .wlc.tx -side top  -expand yes -fill both

	focus .wlc.tx.text

	frame .wlc.bt
	button .wlc.bt.button1 -text "Check again" -command "wl_check"
        button .wlc.bt.button2 -text "Close" -command {destroy .wlc}
	pack .wlc.bt   -padx 5 -pady 5
	pack .wlc.bt.button1
        pack .wlc.bt.button2

	.wlc.tx.text insert insert "                            W E B L I N T   C H E C K \n"
        .wlc.tx.text insert insert "\n"
    }

proc wl_check {} {
global filename weblintversion
.wlc.tx.text configure -state normal
.wlc.tx.text delete 3.0 end
catch {exec weblint $filename} output
if {$output != ""} then {
.wlc.tx.text insert 2.0 "\n"
.wlc.tx.text insert 3.0 "$weblintversion \n"
.wlc.tx.text insert 4.0 "\n"
.wlc.tx.text insert 5.0 $output
.wlc.tx.text delete "end - 35 chars" end
.wlc.tx.text configure -state disabled
update
   } else {
.wlc.tx.text insert 2.0 "\n"
.wlc.tx.text insert 3.0 "$weblintversion \n"
.wlc.tx.text insert 4.0 "\n"
.wlc.tx.text insert 5.0 "No problems with this code it seems!:-)\n"
.wlc.tx.text configure -state disabled
    }
 }
  wl_check
}

# Insert date.

proc insert_date_time { args } {
set foo [clock seconds]

if {$args == "date"} then {
set time [clock format $foo -format "%Y-%m-%d"]
.ed.te.edit1  insert insert $time
     }

if {$args == "time"} then {
set time [clock format $foo -format "%H:%M"]
.ed.te.edit1  insert insert $time
     }

if {$args == "date_time"} then {
set time [clock format $foo -format "%Y-%m-%d %H:%M"]
.ed.te.edit1  insert insert $time
    }

}


# Create/manage tags ("User" menu).

proc manage_tags { } {
global August arritem
  # Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .manage] == 1 } then {
	wm deiconify  .manage
	return
	}
	toplevel .manage
	dialog_position .manage
	wm title .manage "Manage User menu"
	wm protocol .manage WM_DELETE_WINDOW {destroy_manage}
        wm resizable .manage  0 0

frame .manage.fr
frame .manage.fr1
frame .manage.fr2

label .manage.fr.labtn -text "Tag name:"
entry .manage.fr.enttn -textvariable tagname -background white -width 20

label .manage.fr.labft -text "Start tag:"
entry .manage.fr.entft -textvariable firsttag -background white  -width 20

label .manage.fr.labct -text "End tag:(*)"
entry .manage.fr.entct -textvariable closingtag -background white   -width 20

listbox .manage.fr1.bx1 -height 5  -selectmode single -background white  \
-yscrollcommand ".manage.fr1.scr1 set" -xscrollcommand ".manage.fr1.scr2 set" -exportselection 0
scrollbar .manage.fr1.scr1 -command ".manage.fr1.bx1 yview"
scrollbar .manage.fr1.scr2 -command ".manage.fr1.bx1 xview" -orient horizontal

label   .manage.fr1.labinf -text "(*) This field is not obligatory."

button .manage.fr2.addbtn -text "Add" -command {add_tag}
button .manage.fr2.clearbtn -text "Clear" -command {clear}
button .manage.fr2.deletebtn -text "Delete"  -command  {delete_tag}
button .manage.fr2.closebtn -text "Close" -command {destroy_manage}

grid config   .manage.fr.labtn -column 0 -row 0 -padx 5 -pady 5 -sticky es
grid config   .manage.fr.enttn -column 1 -row 0 -padx 5 -pady 5  -sticky ws

grid config   .manage.fr.labft -column 0 -row 1 -padx 5 -pady 5  -sticky es
grid config   .manage.fr.entft -column 1 -row 1 -padx 5 -pady 5    -sticky ws

grid config   .manage.fr.labct -column 0 -row 2 -padx 5 -pady 5  -sticky es
grid config   .manage.fr.entct -column 1 -row 2 -padx 5 -pady 5   -sticky ws

grid config .manage.fr1.bx1 -column 0 -row 0  -sticky e
grid config .manage.fr1.scr1 -column 1 -row 0  -sticky w  -ipady 25
grid config .manage.fr1.scr2  -column 0 -row 1  -sticky e -ipadx 53

grid config   .manage.fr1.labinf -column 0 -row 2 -padx 5 -pady 10 -sticky w

grid config   .manage.fr2.addbtn -column 0 -row 0 -padx 5 -pady 10 -sticky w
grid config   .manage.fr2.clearbtn -column 1 -row 0 -padx 5 -pady 10 -sticky w
grid config   .manage.fr2.deletebtn -column 2 -row 0 -padx 5 -pady 10  -sticky w
grid config   .manage.fr2.closebtn -column 3 -row 0 -padx 5 -pady 10 -sticky w

pack .manage.fr2  -side bottom  -anchor n -pady 3 -padx 8
pack .manage.fr1 -side bottom  -anchor e  -pady 5 -padx 8
pack .manage.fr  -side bottom  -anchor s  -pady 8 -padx 8

# Fetch tagnames from options array and insert them into the listbox.

        for {set m 1} {$m < 100} {incr m} {
        set mvar [array get August u$m]
       if {$mvar != ""} then {
        .manage.fr1.bx1 insert end "[lindex $August(u$m) 0]"
      } else {
#       break
          }
      }

      focus  .manage.fr.enttn

# Procedure for adding new tags.

      proc add_tag {} {
      global August Augustdir tagname firsttag closingtag

     if {$tagname == "" || $firsttag == ""} then {
      notice_box "The first two fields are obligatory!"
      return
        }
# Check how many entries there are currently in the user menu.
      set userentries [.ed.mb.buttonu.m index end]
# Make sure that the tag the user wants to add is already in the menu.
      for {set e 1} {$e <= $userentries} {incr e} {
      set taginfo [.ed.mb.buttonu.m entrycget $e -command]
      set tags "[lindex $taginfo 1] [lindex $taginfo 2]"
      set entrytags "$firsttag $closingtag"
     if {$tags == $entrytags} then {
       notice_box "This tag is already present in the menu!"
      .manage.fr.enttn delete 0 end
      .manage.fr.entft delete 0 end
      .manage.fr.entct delete 0 end
      focus  .manage.fr.enttn
      return
       }
  }

# This part is for container style tags...

     if {$closingtag != ""} then {
      for {set m 1} {$m < 100} {incr m} {
      set mvar [array get August u$m]
     if {$mvar == ""} then {
# Curly braces are important here...
      set August(u$m) "{$tagname} {$firsttag} {$closingtag}"
      .ed.mb.buttonu.m add command -label "[lindex $August(u$m) 0]" -command "formating {[lindex $August(u$m) 1]} {[lindex $August(u$m) 2]}"
      .manage.fr1.bx1 insert end "[lindex $August(u$m) 0]"
      .manage.fr1.bx1 see end
      set file [file join $Augustdir Augustoptions.tcl]
      UserPrefSave $file {August}
      .manage.fr.enttn delete 0 end
      .manage.fr.entft delete 0 end
      .manage.fr.entct delete 0 end
      focus  .manage.fr.enttn
      break
      }
  }
# ...and this part is for non container tags.
     } else {
      for {set m 1} {$m < 100} {incr m} {
      set mvar [array get August u$m]
     if {$mvar == ""} then {
      set August(u$m) "{$tagname} {$firsttag}"
      .ed.mb.buttonu.m add command -label "[lindex $August(u$m) 0]" -command "insert_code {[lindex $August(u$m) 1]}"
      .manage.fr1.bx1 insert end "[lindex $August(u$m) 0]"
      .manage.fr1.bx1 see end
      set file [file join $Augustdir Augustoptions.tcl]
      UserPrefSave $file {August}
      .manage.fr.enttn delete 0 end
      .manage.fr.entft delete 0 end
      .manage.fr.entct delete 0 end
      focus  .manage.fr.enttn
      break
     }
   }
 }
}

# Remove tags from list.

  proc delete_tag {} {
         global August Augustdir arritem
         set index [.manage.fr1.bx1 curselection]
       if {$index != ""} then {
        set lab [.manage.fr1.bx1 get $index]
        .manage.fr1.bx1 delete $index
                     } else {
        notice_box "You must select a tag in the listbox to remove it."
        return
      }
# Get info about the tag that is about to be removed.
        set taginfo [.ed.mb.buttonu.m entrycget [incr index] -command]
        set arrlist [array get August]
       if {[lindex $taginfo 0] == "insert_code"} then {
         set cmd "\{{$lab} {[lindex $taginfo 1]}\}"
         } else {
         set cmd "\{{$lab} {[lindex $taginfo 1]} {[lindex $taginfo 2]}\}"
              }
# I have to use the string command because for some reason lsearch can't find all tags...
         set status [string last $cmd $arrlist]
# ..and I have to find out the number of the tag this way.
       if {$status != "-1"} then {
         set items [llength $arrlist]

         for {set i 0} {$i < $items} {incr i} {
         set listitem [lindex $arrlist $i]

             if {"{$listitem}" == $cmd} then {
                 break
                }
          }

        set arritem [lindex $arrlist [incr i -1]]
# Remove tag from array.
        unset August($arritem)
    }
        set file [file join $Augustdir Augustoptions.tcl]
        UserPrefSave $file {August}
        .ed.mb.buttonu.m delete $index
	}

   proc clear {} {
        .manage.fr.enttn delete 0 end
        .manage.fr.entft delete 0 end
        .manage.fr.entct delete 0 end
         focus  .manage.fr.enttn
        }

   proc destroy_manage {} {
        .manage.fr.enttn delete 0 end
        .manage.fr.entft delete 0 end
        .manage.fr.entct delete 0 end
        destroy .manage
        }
}

# Use template.

proc use_template {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .template] == 1 } then {
	wm deiconify .template
	return
	}
    global Augustdir
    cd $Augustdir/templates
    set templates [glob -nocomplain *]
    set tpl .template
    toplevel $tpl
    dialog_position $tpl
    wm protocol $tpl WM_DELETE_WINDOW "destroy $tpl"
    wm title $tpl {TEMPLATE}
    wm resizable $tpl 0 0

    listbox $tpl.lbox -background white -selectmode single -yscrollcommand\
      "$tpl.scrl set" -width 30

    $tpl.lbox insert 0 "Basic structure"
    $tpl.lbox selection set 0
    foreach tplname $templates {
	regsub -all {([\.])([a-z]+)} $tplname "" new
	$tpl.lbox insert end $new
    }

    scrollbar $tpl.scrl -command "$tpl.lbox yview"

    pack $tpl.scrl -side right -fill y
    pack $tpl.lbox -side top

    frame $tpl.bframe
    button $tpl.bframe.delbutton -text "Remove" -command {remove_template}
    button $tpl.bframe.okbutton -text "Use" -command {insert_template}
    button $tpl.bframe.cancelbutton -text "Close" -command "destroy $tpl"

    pack $tpl.bframe -side bottom
    grid config $tpl.bframe.delbutton -column 1 -row 1 -pady 3 -padx 3
    grid config $tpl.bframe.okbutton -column 2 -row 1 -pady 3 -padx 3
    grid config $tpl.bframe.cancelbutton -column 3 -row 1 -pady 3 -padx 3

    focus $tpl.lbox

    proc insert_template {} {
	global textname Augustdir
	set chtpl [selection get]
	if {$chtpl == "Empty"} then {
	    destroy .template
	}\
	elseif {$chtpl == "Basic structure"} then {
	    insert_basic
	    destroy .template
	    focus $textname
            } else {
            set fid [open $Augustdir/templates/$chtpl.tpl]
            set tplcon [read $fid]
            close $fid
            $textname insert insert $tplcon
            after idle run_tags
            destroy .template
            focus $textname
 	}
    }

    proc remove_template {} {
	global Augustdir
	set chtpl [selection get]
	file delete $Augustdir/templates/$chtpl.tpl
	.template.lbox delete active
	.template.lbox selection set 0
    }
}

# Create template dialog.

proc create_template {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .templname] == 1 } then {
	wm deiconify  .templname
	return
	}
    global textname Augustdir
    set tn .templname
    toplevel $tn
    dialog_position $tn
    wm title $tn "Template name"
    wm protocol $tn WM_DELETE_WINDOW {destroy_tn}
    wm resizable $tn 0 0

    label $tn.namelab -text "Template name?:"
    entry $tn.nameent -textvariable tplname -background white -width 15

    button $tn.nameok -text "OK" -command {write_template}
    button $tn.namecancel -text "Cancel" -command {destroy .templname
	    selection clear}

    grid configure $tn.namelab -column 1 -row 1 -pady 5 -padx 5
    grid configure $tn.nameent -column 2 -row 1 -pady 5 -padx 5

    grid configure $tn.nameok -column 1 -row 2 -pady 5 -padx 5
    grid configure $tn.namecancel -column 2 -row 2 -pady 5 -padx 5

    .templname.nameent delete 0 end
    focus .templname.nameent

# Create template.

    proc write_template {} {
	global tplname Augustdir textname
	if {[selection own] != ""} then {
	    set template [selection get]
	    set fileid [open "$Augustdir/templates/$tplname.tpl" "w+"]
            puts -nonewline $fileid $template
            close $fileid
	    selection clear
	
	    set selstat ""
	    destroy .templname
	} else {
	    set selstat [tk_messageBox -title "Create template" -message\
	      "No code is selected, use all the code in this file as\
	      template?" -type yesno]
	}
	if {$selstat == "yes"} then {
	    set template [$textname get 1.0 end]
	    set fileid [open $Augustdir/templates/$tplname.tpl "w+"]
            puts -nonewline $fileid $template
            close $fileid
	    destroy .templname
	}
    }

}

# Inserts basic html structure in file.

proc insert_basic {} {
    insert_code [set c {<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD><TITLE> </TITLE></HEAD>
<BODY BACKGROUND="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF"\
      ALINK="#0000FF" VLINK="#808080">


</BODY>
</HTML>
}]
set_cur "insert-18c"
}

# Go to line dialog.

proc go_to {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .gt] == 1 } then {
	wm deiconify  .gt
	return
	}
    global textname
    toplevel .gt
    dialog_position .gt
    wm protocol .gt WM_DELETE_WINDOW "destroy_goto"
    wm title .gt "Go to line"
    wm resizable .gt 0 0

    label .gt.lab1 -text "Go to line:"
    entry .gt.ent1 -textvariable gtline -background white

    button .gt.okbutton -text "OK" -command {go_to_line}
    button .gt.cancelbutton -text "Cancel" -command {destroy_goto}

    grid configure .gt.lab1 -column 0 -row 0 -padx 3 -pady 3
    grid configure .gt.ent1 -column 1 -row 0 -padx 3 -pady 3

    grid configure .gt.okbutton -column 0 -row 1 -padx 3 -pady 3
    grid configure .gt.cancelbutton -column 1 -row 1 -padx 3 -pady 3

    focus .gt.ent1

    proc go_to_line {} {
	global textname gtline
	catch {
	    if {$gtline != ""} then {
		$textname see $gtline.0
                after idle run_tags
		$textname mark set insert $gtline.0
		destroy_goto
	    } else {
		notice_box "Fill in a line number!"
	    }
	}
    }

    proc destroy_goto {} {
	.gt.ent1 delete 0 end
	destroy .gt
    }
}

# Get local filename

proc get_local {} {
global August lastdir textname
	    set file_types {
       { "All Files"        *  }
     }


    if {$August(openlastdir) == "yes" && $lastdir == "none"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "no"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "yes" && $lastdir != "none"} then {
    set opendir $lastdir
    }

    set filename [tk_getOpenFile -filetypes $file_types -initialdir $opendir]

    set shortname [file tail $filename]

    $textname insert insert "<A HREF=\"$shortname\"></A>"

    set_cur "insert-4c"

}

# Insert image dialog.

proc get_pict {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .pict] == 1 } then {
	wm deiconify  .pict
	return
	}
    catch {
	global align
	toplevel .pict
	dialog_position .pict
	wm title .pict "Insert picture"
	set align "---"
        wm protocol .pict WM_DELETE_WINDOW {destroy_pict}
        wm resizable .pict 0 0

        label .pict.lab1 -text "Get filename:"
	checkbutton .pict.check2 -text "Low resolution proxy:" -variable lrp\
	  -command {on_off $lrp .pict.ent2}
	label .pict.lab3 -text "Align"
	checkbutton .pict.check4 -text "Alternative text:" -variable txt\
	  -command {on_off $txt .pict.ent4}
	checkbutton .pict.check5 -text "Border*:" -variable brd -command\
	  {on_off $brd .pict.ent5}
	label .pict.check6 -text "Width*:"
	label .pict.check7 -text "Height*:"
	checkbutton .pict.check8 -text "Hspace*:" -variable hsp -command\
	  {on_off $hsp .pict.ent8}
	checkbutton .pict.check9 -text "Vspace*:" -variable vsp -command\
	  {on_off $vsp .pict.ent9}
	label .pict.lab4 -text "(*)In pixels."

	entry .pict.ent1 -width 20 -background white -textvariable pictfile
	entry .pict.ent2 -width 20 -background grey -textvariable lowresfile\
	  -state disabled
	tk_optionMenu .pict.ent3 align TOP BOTTOM MIDDLE LEFT RIGHT ---
	entry .pict.ent4 -width 20 -background white -textvariable alt\
	  -state normal
	entry .pict.ent5 -width 20 -background grey -textvariable border\
	  -state disabled
	entry .pict.ent6 -width 20 -background white -textvariable width
	entry .pict.ent7 -width 20 -background white -textvariable height
	entry .pict.ent8 -width 20 -background grey -textvariable hspace\
	  -state disabled
	entry .pict.ent9 -width 20 -background grey -textvariable vspace\
	  -state disabled

	button .pict.filebutton1 -text "Browse" -command {get_file .pict.ent1}
	button .pict.filebutton2 -text "Browse" -command {get_file .pict.ent2}
	button .pict.cancelbutton -text "Cancel" -command {destroy_pict}
	button .pict.okbutton -text "OK" -command {insert_img_code}

	grid configure .pict.lab1 -column 0 -row 1 -sticky "e" -padx 3 -pady 2
	grid configure .pict.check2 -column 0 -row 2 -sticky "e" -padx 3 -pady 2
	grid configure .pict.lab3 -column 0 -row 3 -sticky "e" -padx 3 -pady 1
	grid configure .pict.check4 -column 0 -row 4 -sticky "e" -padx 3 -pady 2
	grid configure .pict.check5 -column 0 -row 5 -sticky "e" -padx 3 -pady 2
	grid configure .pict.check6 -column 0 -row 6 -sticky "e" -padx 3 -pady 2
	grid configure .pict.check7 -column 0 -row 7 -sticky "e" -padx 3 -pady 2
	grid configure .pict.check8 -column 0 -row 8 -sticky "e" -padx 3 -pady 2
	grid configure .pict.check9 -column 0 -row 9 -sticky "e" -padx 3 -pady 2
	grid configure .pict.lab4 -column 0 -row 10 -sticky "e" -padx 3 -pady 1

	grid configure .pict.ent1 -column 1 -row 1 -sticky "snwe" -padx 3\
	  -pady 2
	grid configure .pict.ent2 -column 1 -row 2 -sticky "snwe" -padx 3\
	  -pady 2
	grid configure .pict.ent3 -column 1 -row 3 -sticky "snwe" -padx 3\
	  -pady 1
	grid configure .pict.ent4 -column 1 -row 4 -sticky "snwe" -padx 3\
	  -pady 2
	grid configure .pict.ent5 -column 1 -row 5 -sticky "snwe" -padx 3\
	  -pady 2
	grid configure .pict.ent6 -column 1 -row 6 -sticky "snwe" -padx 3\
	  -pady 2
	grid configure .pict.ent7 -column 1 -row 7 -sticky "snwe" -padx 3\
	  -pady 2
	grid configure .pict.ent8 -column 1 -row 8 -sticky "snwe" -padx 3\
	  -pady 2
	grid configure .pict.ent9 -column 1 -row 9 -sticky "snwe" -padx 3\
	  -pady 2

	grid configure .pict.filebutton1 -column 2 -row 1 -sticky "w" -padx 3\
	  -pady 2
	grid configure .pict.filebutton2 -column 2 -row 2 -sticky "w" -padx 3\
	  -pady 2
	grid configure .pict.cancelbutton -column 1 -row 11 -sticky "snew"\
	  -padx 3 -pady 2
	grid configure .pict.okbutton -column 0 -row 11 -sticky "snew" -padx 3\
	  -pady 2

	focus .pict.ent1

	.pict.check4 select

	proc get_file {entry} {
                global imagename August lastdir
	    set file_types {
       { "JPEG Files"        { .jpg .jpeg .JPG .JPEG } }
       { "PNG Files"        { .png  .PNG  } }
       { "GIF Files"        { .gif  .GIF  } }
       { "All Files"        *  }
     }


    if {$August(openlastdir) == "yes" && $lastdir == "none"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "no"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "yes" && $lastdir != "none"} then {
    set opendir $lastdir
    }

	    set imagename [tk_getOpenFile -filetypes $file_types -initialdir $opendir]
	    regsub -all {^/.*/} $imagename "" target
	    $entry insert end $target
                    catch {
                    set identifyoutput [exec $August(identifypath) $imagename]
                    regexp {[0-9]+x[0-9]+} $identifyoutput imvar
                    regexp {^[0-9]+} $imvar wi
                    regexp {[0-9]+$} $imvar he
                    .pict.ent6 delete 0 end
	            .pict.ent7 delete 0 end
                    .pict.ent6 insert end   $wi
                    .pict.ent7 insert end   $he
                   }
            if {$imagename != ""} then {
            set lastdir [file dirname $imagename]
             }

	}

	global pictfile alt

	proc insert_img_code {} {
	    global pictfile alt align lowresfile width height hspace vspace\
	      border
	    set code ""
	    if {$pictfile != ""} then {
		set code1 [subst {"$pictfile"}]
		set code [list $code1]
	    }
	    if {$alt != ""} then {
		set code2 [subst {ALT="$alt"}]
		set code [linsert $code end $code2]
	    }
	    if {$align != "---"} then {
		set code3 [subst {ALIGN="$align"}]
		set code [linsert $code end $code3]
	    }
	    if {$lowresfile != ""} then {
		set code4 [subst {LOWSRC="$lowresfile"}]
		set code [linsert $code end $code4]
	    }
	    if {$border != ""} then {
		set code5 [subst {BORDER="$border"}]
		set code [linsert $code end $code5]
	    }
	    if {$width != ""} then {
		set code6 [subst {WIDTH="$width"}]
		set code [linsert $code end $code6]
	    }
	    if {$height != ""} then {
		set code7 [subst {HEIGHT="$height"}]
		set code [linsert $code end $code7]
	    }
	    if {$hspace != ""} then {
		set code8 [subst {HSPACE="$hspace"}]
		set code [linsert $code end $code8]
	    }
	    if {$vspace != ""} then {
		set code9 [subst {VSPACE="$vspace"}]
		set code [linsert $code end $code9]
	    }
	    if {$code == ""} then {
		notice_box "You haven't filled in the necessary data!"
		return
	    }
	    set code [subst $code]
	    regsub -all "{" "$code" "" var
	    regsub -all "}" "$var" "" html
	    .ed.te.edit1 insert insert "<IMG SRC=$html>"
            after idle run_tags
	    destroy_pict
	    focus .ed.te.edit1
	}

	proc destroy_pict {} {
	    .pict.check2 deselect
	    .pict.check4 deselect
	    .pict.check5 deselect
	    .pict.check8 deselect
	    .pict.check9 deselect
	    .pict.ent1 delete 0 end
	    .pict.ent2 delete 0 end
	    .pict.ent4 delete 0 end
	    .pict.ent5 delete 0 end
	    .pict.ent6 delete 0 end
	    .pict.ent7 delete 0 end
	    .pict.ent8 delete 0 end
	    .pict.ent9 delete 0 end
	    destroy .pict
	}
    }
}

# Insert table dialog.

proc build_table {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .table] == 1 } then {
	wm deiconify  .table
	return
	}
    catch {
	toplevel .table
	dialog_position .table
	wm title .table "Build table"
        wm resizable .table  0 0

	label .table.lab1 -text "Columns:"
	label .table.lab2 -text "Rows:"
	checkbutton .table.check3 -text "Caption:" -variable capt -command\
	  {on_off $capt .table.ent3}
	checkbutton .table.check4 -text "Width**:" -variable wid -command\
	  {on_off $wid .table.ent4}
	checkbutton .table.check5 -text "Border*:" -variable bord -command\
	  {on_off $bord .table.ent5}
	checkbutton .table.check6 -text "Cellpadding*:" -variable cellp\
	  -command {on_off $cellp .table.ent6}
	checkbutton .table.check7 -text "Cellspacing*:" -variable cells\
	  -command {on_off $cells .table.ent7}
	label .table.lab3 -text "(*)In pixels."
	label .table.lab4 -text "(**)In pixels or %."

	entry .table.ent1 -width 15 -background white -textvariable columns
	entry .table.ent2 -width 15 -background white -textvariable rows
	entry .table.ent3 -width 15 -background grey -textvariable caption\
	  -state disabled
	entry .table.ent4 -width 15 -background grey -textvariable tablew\
	  -state disabled
	entry .table.ent5 -width 15 -background grey -textvariable border\
	  -state disabled
	entry .table.ent6 -width 15 -background grey -textvariable cellpadd\
	  -state disabled
	entry .table.ent7 -width 15 -background grey -textvariable cellspace\
	  -state disabled

	button .table.button1 -text "OK" -command {create_table_code}
	button .table.button2 -text "Cancel" -command {destroy_table}

	grid configure .table.lab1 -row 1 -column 0 -sticky "w" -padx 3 -pady 3
	grid configure .table.lab2 -row 2 -column 0 -sticky "w" -padx 3 -pady 3
	grid configure .table.check3 -row 3 -column 0 -sticky "w" -padx 3\
	  -pady 3
	grid configure .table.check4 -row 4 -column 0 -sticky "w" -padx 3\
	  -pady 3
	grid configure .table.check5 -row 5 -column 0 -sticky "w" -padx 3\
	  -pady 3
	grid configure .table.check6 -row 6 -column 0 -sticky "w" -padx 3\
	  -pady 3
	grid configure .table.check7 -row 7 -column 0 -sticky "w" -padx 3\
	  -pady 3
	grid configure .table.lab3 -row 8 -column 0 -sticky "w" -padx 3 -pady 3
	grid configure .table.lab4 -row 8 -column 1 -sticky "w" -padx 3 -pady 3

	grid configure .table.ent1 -row 1 -column 1 -sticky "w" -padx 3 -pady 3
	grid configure .table.ent2 -row 2 -column 1 -sticky "w" -padx 3 -pady 3
	grid configure .table.ent3 -row 3 -column 1 -sticky "w" -padx 3 -pady 3
	grid configure .table.ent4 -row 4 -column 1 -sticky "w" -padx 3 -pady 3
	grid configure .table.ent5 -row 5 -column 1 -sticky "w" -padx 3 -pady 3
	grid configure .table.ent6 -row 6 -column 1 -sticky "w" -padx 3 -pady 3
	grid configure .table.ent7 -row 7 -column 1 -sticky "w" -padx 3 -pady 3

	grid configure .table.button1 -row 10 -column 0 -sticky "snew" -padx 3\
	  -pady 3
	grid configure .table.button2 -row 10 -column 1 -sticky "snew" -padx 3\
	  -pady 3

	focus .table.ent1

	proc create_table_code {} {
	    global columns rows caption tablew border cellpadd cellspace
	    set code ""
	    if {$tablew != ""} then {
		set tcode1 [subst {WIDTH="$tablew"}]
		set code [linsert $code end $tcode1]
	    }

	    if {$border != ""} then {
		set tcode2 [subst {BORDER="$border"}]
		set code [linsert $code end $tcode2]
	    }

	    if {$cellpadd != ""} then {
		set tcode3 [subst {CELLPADDING="$cellpadd"}]
		set code [linsert $code end $tcode3]
	    }

	    if {$cellspace != ""} then {
		set tcode4 [subst {CELLSPACING="$cellspace"}]
		set code [linsert $code end $tcode4]
	    }

	    set cell "<TD></TD>"
	    set ccode [list $cell]
	    for {set c 1} {$c < $columns} {incr c} { set ccode [linsert $ccode\
	      end $cell] }

	    set row "<TR>$ccode</TR> \n"
	    set rcode [list $row]
	    for {set r 1} {$r < $rows} {incr r} { set rcode [linsert $rcode\
	      end $row] }

	    if {$caption != ""} then {
		set caption "<CAPTION>$caption</CAPTION>"
	    }

	    set end "</TABLE>"

	    set code [subst $code]
	    regsub -all "{" "$code" "" var
	    regsub -all "}" "$var" "" html
	    regsub -all "{" "$rcode" "" vvar
	    regsub -all "}" "$vvar" "" hhtml
	    .ed.te.edit1 insert insert [subst {<TABLE $html>
$caption
$hhtml
$end}]
            after idle run_tags
	    destroy_table
	    focus .ed.te.edit1
	}

	proc destroy_table {} {
	    .table.check3 deselect
	    .table.check4 deselect
	    .table.check5 deselect
	    .table.check6 deselect
	    .table.check7 deselect
	    .table.ent1 delete 0 end
	    .table.ent2 delete 0 end
	    .table.ent3 delete 0 end
	    .table.ent4 delete 0 end
	    .table.ent5 delete 0 end
	    .table.ent6 delete 0 end
	    .table.ent7 delete 0 end
	    destroy .table
	}
    }
}

# Create table rows.

proc table_row {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .trow] == 1 } then {
	wm deiconify  .trow
	return
	}
    global textname tralign trvalign
    toplevel .trow
    dialog_position .trow
    wm title .trow "Create table rows"
    wm protocol .trow WM_DELETE_WINDOW {destroy_trow}
    wm resizable .trow  0 0
    set tralign "---"
    set trvalign "---"

    label .trow.lab1 -text "Align"
    label .trow.lab2 -text "Valign"
    checkbutton .trow.check5 -text "Bg color:" -variable settrcol -command\
      {on_off $settrcol .trow.ent5}
    label .trow.lab3 -text "Number of rows"

    tk_optionMenu .trow.opt1 tralign --- LEFT RIGHT CENTER JUSTIFY
    tk_optionMenu .trow.opt2 trvalign --- TOP BOTTOM MIDDLE BASELINE
    entry .trow.ent5 -width 20 -background grey -textvariable trcolor\
      -state disabled
    button .trow.colorbtn -image color -command {color_code_insert .trow.ent5}
    entry .trow.ent7 -width 20 -background white -textvariable trnumber

    button .trow.button1 -text "OK" -command {ins_trow}
    button .trow.button2 -text "Cancel" -command {destroy_trow}

    grid configure .trow.lab1 -row 2 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .trow.lab2 -row 3 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .trow.lab3 -row 10 -column 1 -sticky "w" -padx 3 -pady 2

    grid configure .trow.opt1 -row 2 -column 2 -sticky "w" -padx 3 -pady 2
    grid configure .trow.opt2 -row 3 -column 2 -sticky "w" -padx 3 -pady 2
    grid configure .trow.ent5 -row 6 -column 2 -sticky "snew" -padx 3 -pady 2
    grid configure .trow.check5 -row 6 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .trow.colorbtn -row 7 -column 2 -sticky "snew" -padx 3\
      -pady 2
    grid configure .trow.ent7 -row 10 -column 2 -sticky "snew" -padx 3 -pady 2

    grid configure .trow.button1 -row 11 -column 1 -sticky "snew" -padx 3\
      -pady 2
    grid configure .trow.button2 -row 11 -column 2 -sticky "snew" -padx 3\
      -pady 2

    .trow.ent7 insert end "1"

    proc ins_trow {} {
	global tralign trvalign trcolor\
	  trnumber textname
	set var1 ""
	set 2 "</TR>"
	if {$tralign != "---"} then {
	    set tra [subst {ALIGN="$tralign"}]
	    set var1 [linsert $var1 end $tra]
	}
	if {$trvalign != "---"} then {
	    set trb [subst {VALIGN="$trvalign"}]
	    set var1 [linsert $var1 end $trb]
	}
	if {$trcolor != ""} then {
	    set tre [subst {BGCOLOR="$trcolor"}]
	    set var1 [linsert $var1 end $tre]
	}
	set var1 [subst $var1]
	regsub -all "{" "$var1" "" var2
	regsub -all "}" "$var2" "" 1
	set 1 [format "<TR %s>" $1]
	for {set trn 0} {$trn < $trnumber} {incr trn} {
	    insert_code "$1 $2 \n"
           }
        destroy_trow
	focus $textname
    }

    proc destroy_trow {} {
	.trow.ent5 delete 0 end
	.trow.ent7 delete 0 end
                .trow.check5 deselect
	set tralign "---"
	set trvalign "---"
	destroy .trow
    }
}


# Create table cells.

proc table_cell {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .tcell] == 1 } then {
	wm deiconify  .tcell
	return
	}
    global textname tcalign tcvalign
    toplevel .tcell
    dialog_position .tcell
    wm title .tcell "Create table cells"
    wm protocol .tcell WM_DELETE_WINDOW {destroy_tcell}
    wm resizable .tcell  0 0
    set tcalign "---"
    set tcvalign "---"

    label .tcell.lab1 -text "Align"
    label .tcell.lab2 -text "Valign"
    checkbutton .tcell.check3 -text "Rowspan:" -variable setrow -command\
      {on_off $setrow .tcell.ent3}
    checkbutton .tcell.check4 -text "Colspan:" -variable setcol -command\
      {on_off $setcol .tcell.ent4}
    checkbutton .tcell.check5 -text "Bg color:" -variable settcol -command\
      {on_off $settcol .tcell.ent5}
    checkbutton .tcell.check6 -text "Cell width:" -variable setwidth -command\
      {on_off $setwidth .tcell.ent6}
    checkbutton .tcell.check7 -text "Nowrap" -variable tcsetwrap -onvalue\
      "yes" -offvalue "no"
    label .tcell.lab3 -text "Number of cells"

    tk_optionMenu .tcell.opt1 tcalign --- LEFT RIGHT CENTER
    tk_optionMenu .tcell.opt2 tcvalign --- TOP BOTTOM MIDDLE
    entry .tcell.ent3 -width 20 -background grey -textvariable tcrowspan\
      -state disabled
    entry .tcell.ent4 -width 20 -background grey -textvariable tccolspan\
      -state disabled
    entry .tcell.ent5 -width 20 -background grey -textvariable tccolor\
      -state disabled
    button .tcell.colorbtn -image color -command {color_code_insert .tcell.ent5}
    entry .tcell.ent6 -width 20 -background grey -textvariable tcwidth\
      -state disabled
    entry .tcell.ent7 -width 20 -background white -textvariable tcnumber

    button .tcell.button1 -text "OK" -command {ins_tcell}
    button .tcell.button2 -text "Cancel" -command {destroy_tcell}

    grid configure .tcell.lab1 -row 2 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.lab2 -row 3 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.check3 -row 4 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.check4 -row 5 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.check5 -row 6 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.check6 -row 8 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.check7 -row 9 -column 1 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.lab3 -row 10 -column 1 -sticky "w" -padx 3 -pady 2

    grid configure .tcell.opt1 -row 2 -column 2 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.opt2 -row 3 -column 2 -sticky "w" -padx 3 -pady 2
    grid configure .tcell.ent3 -row 4 -column 2 -sticky "snew" -padx 3 -pady 2
    grid configure .tcell.ent4 -row 5 -column 2 -sticky "snew" -padx 3 -pady 2
    grid configure .tcell.ent5 -row 6 -column 2 -sticky "snew" -padx 3 -pady 2
    grid configure .tcell.colorbtn -row 7 -column 2 -sticky "snew" -padx 3\
      -pady 2
    grid configure .tcell.ent6 -row 8 -column 2 -sticky "snew" -padx 3 -pady 2
    grid configure .tcell.ent7 -row 10 -column 2 -sticky "snew" -padx 3 -pady 2

    grid configure .tcell.button1 -row 11 -column 1 -sticky "snew" -padx 3\
      -pady 2
    grid configure .tcell.button2 -row 11 -column 2 -sticky "snew" -padx 3\
      -pady 2

    .tcell.ent7 insert end "1"

    proc ins_tcell {} {
	global tcsetwrap tcalign tcvalign tcrowspan tccolspan tccolor tcwidth\
	  tcnumber textname
	set var1 ""
	set 2 "</TD>"
	if {$tcalign != "---"} then {
	    set tca [subst {ALIGN="$tcalign"}]
	    set var1 [linsert $var1 end $tca]
	}
	if {$tcvalign != "---"} then {
	    set tcb [subst {VALIGN="$tcvalign"}]
	    set var1 [linsert $var1 end $tcb]
	}
	if {$tcrowspan != ""} then {
	    set tcc [subst {ROWSPAN="$tcrowspan"}]
	    set var1 [linsert $var1 end $tcc]
	}
	if {$tccolspan != ""} then {
	    set tcd [subst {ROWSPAN="$tccolspan"}]
	    set var1 [linsert $var1 end $tcd]
	}
	if {$tccolor != ""} then {
	    set tce [subst {BGCOLOR="$tccolor"}]
	    set var1 [linsert $var1 end $tce]
	}
	if {$tcwidth != ""} then {
	    set tcf [subst {WIDTH="$tcwidth"}]
	    set var1 [linsert $var1 end $tcf]
	}
	if {$tcsetwrap != "no"} then {
	    set tcg "NOWRAP"
	    set var1 [linsert $var1 end $tcg]
	}
	set var1 [subst $var1]
	regsub -all "{" "$var1" "" var2
	regsub -all "}" "$var2" "" 1
	set 1 [format "<TD %s>" $1]
	for {set tcn 0} {$tcn < $tcnumber} {incr tcn} {
	    insert_code "$1 $2 \n"
	}
        destroy_tcell
	focus $textname
    }

    proc destroy_tcell {} {
	.tcell.ent3 delete 0 end
	.tcell.ent4 delete 0 end
	.tcell.ent5 delete 0 end
	.tcell.ent6 delete 0 end
	.tcell.ent7 delete 0 end
	.tcell.check3 deselect
	.tcell.check4 deselect
	.tcell.check5 deselect
	.tcell.check6 deselect
	.tcell.check7 deselect
	set tcalign "---"
	set tcvalign "---"
	destroy .tcell
    }
}

# Change font size and/or color dialog.

proc font_style {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .font] == 1 } then {
	wm deiconify  .font
	return
	}
    catch {
	global fsize fsizerel textname
	set fsize "---"
        set fsizerel "---"
	toplevel .font
	dialog_position .font
	wm title .font "Set font size and color"
	wm protocol .font WM_DELETE_WINDOW {destroy_font}
        wm resizable .font  0 0

	label .font.label1 -text "Set fontsize:"
        label .font.labelrel -text "Set fontsize (relative):"
	checkbutton .font.check1 -text "Set color:" -variable setcol -command\
	  {on_off $setcol .font.ent2}
	checkbutton .font.check2 -text "Set font:" -variable setfont -command\
	  {on_off_font $setfont}
	label .font.label2 -text "1"
	label .font.label3 -text "2"
	label .font.label4 -text "3"
	label .font.label5 -text "4"

	tk_optionMenu .font.ent1 fsize 1 2 3 4 5 6 7 ---

        tk_optionMenu .font.entrel fsizerel -2 -1 +1 +2 +3 +4 ---

	entry .font.ent2 -width 20 -background grey -textvariable colorcode\
	  -state disabled
	
	entry .font.ent3 -width 20 -background grey -textvariable fontone\
	  -state disabled
	entry .font.ent4 -width 20 -background grey -textvariable fonttwo\
	  -state disabled
	entry .font.ent5 -width 20 -background grey -textvariable fontthree\
	  -state disabled
	entry .font.ent6 -width 20 -background grey -textvariable fontfour\
	  -state disabled

	button .font.colorbutton -image color -command\
	  {color_code_insert .font.ent2}

	button .font.button1 -text "OK" -command {ins_style}
	button .font.button2 -text "Cancel" -command {destroy_font}

	grid configure .font.label1 -row 0 -column 1 -sticky "e" -padx 3 -pady 2
        grid configure .font.labelrel -row 1 -column 1 -sticky "e" -padx 3 -pady 2
	grid configure .font.check1 -row 2 -column 1 -sticky "e" -padx 3 -pady 2

	grid configure .font.check2 -row 4 -column 1 -sticky "w" -padx 3 -pady 2

	grid configure .font.ent1 -row 0 -column 2 -sticky "snew" -padx 3\
	  -pady 2

        grid configure .font.entrel -row 1 -column 2 -sticky "snew" -padx 3\
	  -pady 2

	grid configure .font.ent2 -row 2 -column 2 -sticky "snew" -padx 3\
	  -pady 2

	grid configure .font.colorbutton -row 3 -column 2 -sticky "n" -padx 3\
	  -pady 2

	grid configure .font.label2 -row 4 -column 1 -sticky "e" -padx 3 -pady 2
	grid configure .font.label3 -row 5 -column 1 -sticky "e" -padx 3 -pady 2
	grid configure .font.label4 -row 6 -column 1 -sticky "e" -padx 3 -pady 2
	grid configure .font.label5 -row 7 -column 1 -sticky "e" -padx 3 -pady 2

	grid configure .font.ent3 -row 4 -column 2 -sticky "snew" -padx 3\
	  -pady 2
	grid configure .font.ent4 -row 5 -column 2 -sticky "snew" -padx 3\
	  -pady 2
	grid configure .font.ent5 -row 6 -column 2 -sticky "snew" -padx 3\
	  -pady 2
	grid configure .font.ent6 -row 7 -column 2 -sticky "snew" -padx 3\
	  -pady 2

	grid configure .font.button1 -row 8 -column 1 -sticky "snew" -padx 3\
	  -pady 2
	grid configure .font.button2 -row 8 -column 2 -sticky "snew" -padx 3\
	  -pady 2

	proc ins_style {} {
	    global fsize fsizerel colorcode fontone fonttwo fontthree fontfour

            if {$fsize != "---" && $fsizerel != "---"} then {
            notice_box "You cannot use two ways of setting the font size at once..."
            return
            }

	    set var1 ""
	    set 2 "</FONT>"
	    if {$fsize != "---" && $fsizerel == "---"} then {
		set sz [subst {SIZE="$fsize"}]
		set var1 [linsert $var1 end $sz]
	    }

            if {$fsizerel != "---" && $fsize == "---"} then {
		set szr [subst {SIZE="$fsizerel"}]
		set var1 [linsert $var1 end $szr]
	    }

	    if {$colorcode != ""} then {
		set co [subst {COLOR="$colorcode"}]
		set var1 [linsert $var1 end $co]
	    }
	    if {$fontone != ""} then {
		set fo [subst {FACE="$fontone"}]
		set var1 [linsert $var1 end $fo]
	    }
	    if {$fonttwo != ""} then {
		set fo [subst {FACE="$fontone, $fonttwo"}]
		set var1 [lreplace $var1 end end]
		set var1 [linsert $var1 end $fo]
	    }
	    if {$fontthree != ""} then {
		set fo [subst {FACE="$fontone, $fonttwo, $fontthree"}]
		set var1 [lreplace $var1 end end]
		set var1 [linsert $var1 end $fo]
	    }
	    if {$fontfour != ""} then {
		set fo [subst {FACE="$fontone, $fonttwo, $fontthree,\
		  $fontfour"}]
		set var1 [lreplace $var1 end end]
		set var1 [linsert $var1 end $fo]
	    }
	    set var1 [subst $var1]
	    regsub -all "{" "$var1" "" var2
	    regsub -all "}" "$var2" "" 1
	    set 1 [format "<FONT %s>" $1]
	    set fsize "---"
            set fsizerel "---"
	    .font.ent2 delete 0 end
	    formating $1 $2
	    destroy_font
	}

	proc destroy_font {} {
	    set fsize "---"
            set fsizerel "---"
	    .font.ent2 delete 0 end
	    .font.ent3 delete 0 end
	    .font.ent4 delete 0 end
	    .font.ent5 delete 0 end
	    .font.ent6 delete 0 end
	    .font.check1 deselect
	    .font.check2 deselect
	    destroy .font
	}
    }

    proc on_off_font {optvar} {
	if {$optvar == 1} then {
	    .font.ent3 configure -state normal -background white
	    .font.ent4 configure -state normal -background white
	    .font.ent5 configure -state normal -background white
	    .font.ent6 configure -state normal -background white
	    focus .font.ent3
	} else {
	    .font.ent3 delete 0 end
	    .font.ent4 delete 0 end
	    .font.ent5 delete 0 end
	    .font.ent6 delete 0 end
	    .font.ent3 configure -state disabled -background grey
	    .font.ent4 configure -state disabled -background grey
	    .font.ent5 configure -state disabled -background grey
	    .font.ent6 configure -state disabled -background grey
	}
    }

}

# Read file.

proc file_read {filename} {
    set filename [file join $filename]
    # Default value
    global data
    set data ""
    if {[file readable $filename]} then {
        set fd [open $filename "r"]
# I18N experiment
#        fconfigure $fd -encoding big5
#         fconfigure $fd -encoding shiftjis
        set data [read $fd]
        close $fd
    }

    return $data

}

# Saves data to disk

proc file_write {filename data} {
    set filename [file join $filename]
    return [catch {

	set fileid [open $filename "w"]

	puts -nonewline $fileid $data

	close $fileid
    }]
}

# Loads a file into text widget.

proc file_load {toplevel textwidget filename} {
    set filename [file join $filename]
    set data [file_read $filename]
    file_clear $toplevel $textwidget $filename
    $textwidget insert end $data
}

# Deletes all text in text widget, sets toplevel to have given
# title.

proc file_clear {toplevel textwidget title} {
    $textwidget delete 1.0 end
    wm title $toplevel $title
    focus $textwidget
}

# Updates content in editor from original file.

proc file_reload { } {
      global filename textname
      set result [tk_messageBox -parent .ed -title {Reload File?} -type yesnocancel \
      -icon warning -message "Are you sure you want to reload this file?"]
      if {$result == "yes"} then {
      set data [file_read $filename]
      $textname delete 1.0 end
      $textname insert end $data
     }
      if {$result == "no"} then {
      return
     }
 }

# This proc is run every time the editor is started.
# Slightly modified version of file_new.

proc file_first {toplevel textwidget name} {
    global textname data filelist filesel filename filebuffer temp
    set filename [file join $filename]
    set content [$textname get 1.0 {end -1c}]
    set filebuffer($filelist) "$filelist"
    set fileid [open $temp/$filebuffer($filelist)[pid].bf "w+"]
    puts -nonewline $fileid $content
    close $fileid
    set filename Untitled
    $filesel add command -label "$filename" -command\
      "load_buffer $temp/$filebuffer($filelist)[pid].bf $filelist Untitled"
    incr filelist
    $textwidget delete 1.0 end
    wm title .ed "August ($name)"
    focus $textwidget
    $textwidget mark set insert 1.0
}

# Edit a new file.

proc file_new {toplevel textwidget name tpldialog} {
    global textname data filelist filesel filesave filename filebuffer current temp\
      August
    set content [$textname get 1.0 {end -1c}]
    set filebuffer($filelist) "$filelist"
    set fileid [open $temp/$filebuffer($current)[pid].bf "w+"]
    puts -nonewline $fileid $content
    close $fileid
    set current $filelist
    if {$name == "Untitled"} then {
    set filename Untitled
  } else {
    set filename [file join $name]
  }
    set shortname [file tail $filename]
    set filesave($filename) $filename
    $filesel add command -label "$shortname" -command\
      "load_buffer $temp/$filebuffer($filelist)[pid].bf $filelist $filename"
    incr filelist
    $textwidget delete 1.0 end
    wm title $toplevel "August ($filename)"
    if {$tpldialog == "yes"} then {
	use_template
	.template.lbox insert 0 "Empty"
	.template.lbox selection clear 1
	.template.lbox selection set 0
    }
    focus $textwidget
    $textwidget mark set insert 1.0
}

# Proc used by file_open.

proc file_open_get {} {
global textedit August lastdir
    set file_types {
       { "Html Files"        { .htm .html .HTM .HTML } }
       { "Stylesheet"        { .css .CSS } }
       { "PHP"        { .php .php3 .PHP .PHP3 } }
       { "Text Files"        { .txt  .TXT  } }
       { "All Files"        *  }
         }

    if {$August(openlastdir) == "yes" && $lastdir == "none"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "no"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "yes" && $lastdir != "none"} then {
    set opendir $lastdir
    }

    set fname [tk_getOpenFile -initialdir $opendir \
      -filetypes $file_types -title "Select a file to load" -parent .]

    if {$fname != ""} then {
    set lastdir [file dirname $fname]
    }

    return $fname
}

# Asks user for filename, loads it.

proc file_open {toplevel textwidget cmdline cmdname} {
    global textname filename filesel filelist filebuffer filesave current\
      filenamelist temp actions
    set filename [file join $filename]
    set oldfile $filename
    set content [$textname get 1.0 {end -1c}]
    set filebuffer($filelist) "$filelist"
    set fileid [open $temp/$filebuffer($current)[pid].bf "w+"]
    puts -nonewline $fileid $content
    close $fileid
    set current $filelist
    if {$cmdline == "no"} then {
    set filename [file_open_get]
   } else {
    set filename $cmdname
   }
    set filestatus [lsearch -exact $filenamelist $filename]
    if {$filename == ""} then {
	set filename $oldfile
	return
    }
    if {$filename == "Untitled"} then {
	set filestatus -1
    }
    if {$filestatus == -1} then {
    } else {
	notice_box "This file is already open!"
	return
    }
    set filenamelist [linsert $filenamelist end $filename]
    if {$filename != ""} then {
	file_load $toplevel $textwidget $filename
        after idle run_tags
	focus $textwidget
	$textwidget mark set insert 1.0
	set filesave($filename) [file join $filename]
	set longname $filename
	set shortname [file tail $longname]
	$filesel add command -label "$shortname" -command\
	  "load_buffer $temp/$filebuffer($filelist)[pid].bf $filelist\
	  {$filesave($filename)}"
	incr filelist
        set actions [lreplace $actions end end]
        set actions [lreplace $actions end end]
	wm title .ed "August ($filename)"
    }
}

# Loads in a file and inserts data at cursor. Does
# not delete old data.

proc file_insert {toplevel textwidget} {
    set insfname [file_open_get]
    if {$insfname != ""} then {
	set data [file_read $insfname]
	if {$data != ""} then {
	    $textwidget insert insert $data
	    focus $textwidget
	    $textwidget mark set insert 1.0
            update
            run_tags
	}
    }
}

# Save file.

proc file_save {textwidget} {
    global textedit data filesel filename filelist current filesave filebuffer\
    filenamelist temp August lastdir
    set filename [file join $filename]
    set data [$textwidget get 1.0 {end -1c}]
    if {$filename == "Untitled"} then {
	set file_types {
       { "Html Files"        { .htm .html .HTM .HTML } }
       { "Stylesheet"        { .css .CSS } }
       { "PHP"        { .php .php3 .PHP .PHP3 } }
       { "Text Files"        { .txt  .TXT  } }
       { "All Files"        *  }
         }

    if {$August(openlastdir) == "yes" && $lastdir == "none"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "no"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "yes" && $lastdir != "none"} then {
    set opendir $lastdir
    }

	set filename [tk_getSaveFile -initialdir $opendir \
	  -filetypes $file_types -title "Select file name to save" -parent .]
	if {$filename != ""} then {
	    set text [string trimright $data]
	    set filesave($filename) $filename
	    set longname $filename
	    set filenamelist [linsert $filenamelist end $filename]
	    set shortname [file tail $longname]
	    $filesel entryconfigure $current -label "$shortname" -command\
	      "load_buffer $temp/$filebuffer($current)[pid].bf $current\
	      {$filesave($filename)}"
	    wm title .ed "August ($filename)"
            set lastdir [file dirname $filename]
	    return [file_write $filesave($filename) $data]
# This prevents the fileneame becoming ""  if the user hits cancel in the file save dialog.
	} else {
	    set filename "Untitled"
	    return $filename
	}
    } else {
	set data [$textwidget get 1.0 {end -1c}]
	set text [string trimright $data]
	wm title .ed "August ($filename)"
	return [file_write $filesave($filename) $data]
    }
}

# Save all files.

proc save_all_files { } {
global textname filesel current  wcontent
         set openfile $current
         set savefiles [$filesel index end]
        for {set f 1} {$f <= $savefiles} {incr f} {
         set fileinfo [$filesel entrycget $f -command]
         set fpath [lindex $fileinfo 3]
         set bpath [lindex $fileinfo 1]
# If the first file to save is loaded into the text widget, run regular file_save.
      if {$openfile == {$current}} then {
           check_text
        } elseif {$fpath == "Untitled"} then {
# If the filename is Untitled then load it into textwidget and run regular file_save.
         $filesel invoke $f
          check_text
        }  else {
# Read buffert file.
         set ntext [file_read $bpath]
# Write the contents of the buffer file to a filename.
         file_write $fpath $ntext
      }
   }
# Load the last edited file.
        $filesel invoke $openfile
}


proc check_text { } {
      global  textname
      set wcontent [$textname get 1.0 "end -1c"]
    if {$wcontent != ""} then {
      file_save $textname
      return
     }
}

# Close file.

proc file_close { textwidget status} {
        global textname filesel current filename filenamelist temp
        set filename [file join $filename]
        if [file exists $temp/$current[pid].bf] then {
    } else {
        set fake [open $temp/$current[pid].bf "w+"]
        close $fake
     }
        if {$filename == "Untitled"} then {
        set buffer [open $temp/$current[pid].bf "r"]
        set old [read $buffer]
        close $buffer
    } else {
        set filestatus [file readable $filename]
        if {$filestatus == "1"} then {
        set file [open $filename "r"]
        set old [read $file]
        close $file
      } else {
        set new ""
        set old "deleted"
        notice_box "This file has been deleted from disk. You can still save the contents of the editor if you want to."
       }
     }
        set new [$textname get 1.0 {end -1c}]

        if {$new == ""} then {
      } elseif {$filename == "Untitled"} then {
         set result [tk_messageBox -parent .ed -title {Save File?} -type yesnocancel \
         -icon warning -message "Do you want to save this file?"]

          if {$result == "yes"} then { file_save $textwidget                  
             }         
         } elseif {$old != $new} then {
           set result [tk_messageBox -parent .ed -title {Save File?} -type yesnocancel \
           -icon warning -message "Do you want to save this file?"]
           if {$result == "yes"} then { file_save $textwidget
           } 
       }               
              set var [lsearch $filenamelist $filename]
              if {$var != "-1"} then {
             set filenamelist [lreplace $filenamelist  $var $var]
      }

         set fileselentries [$filesel index end]
        for {set fe 1} {$fe <= $fileselentries} {incr fe} {
         set result [$filesel entrycget $fe \-command]
         set buffer [lindex $result 2]
        if {$buffer == $current} then {
         $filesel delete $fe
         break
      }
  }

       $textwidget delete 1.0 end
       set latest $current
       $filesel configure -tearoff 0
       wm title .ed "August (Untitled)"

     if {$fe > 1} then {
      $filesel invoke [incr fe -1]
      $filesel configure -tearoff 1
       } elseif {$fe == 1} then {
     file_new .ed $textname Untitled no
     $filesel configure -tearoff 1
      }

  }


# Save file as...

proc file_save_as {textwidget} {
    global textedit data filesel filename filelist current filesave filebuffer\
    temp August textname actions filenamelist lastdir
    set filename [file join $filename]
    set oldfilename $filename
    set data [$textwidget get 1.0 {end -1c}]
    set file_types {
{ "Html Files"        { .htm .html .HTM .HTML } }
       { "Stylesheet"        { .css .CSS } }
       { "PHP"        { .php .php3 .PHP .PHP3 } }
       { "Text Files"        { .txt  .TXT  } }
       { "All Files"        *  }
         }


     if {$August(openlastdir) == "yes" && $lastdir == "none"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "no"} then {
    set opendir $August(docpath)
    }

    if {$August(openlastdir) == "yes" && $lastdir != "none"} then {
    set opendir $lastdir
    }

    set filename [tk_getSaveFile -initialdir $opendir \
      -filetypes $file_types -title "Select file name to save" -parent .]

      # Saving a new file...

    if {$oldfilename == "Untitled"} then {
	set filesave($filename) $filename
	set longname $filename
	set shortname [file tail $longname]
	$filesel entryconfigure $current -label "$shortname" -command\
	"load_buffer $temp/$filebuffer($current)[pid].bf $current\
	{$filesave($filename)}"
	wm title .ed "August ($filename)"
                set lastdir [file dirname $filename]
	return [file_write $filesave($filename) $data]

        # When saving an already existing file under a different name...:
                 }  elseif {$filename != ""} then {
                set filebuffer($filelist) "$filelist"
                set fileid [open $temp/$filebuffer($current)[pid].bf "w+"]
                puts -nonewline $fileid $data
                close $fileid
                set current $filelist
	set filesave($filename) $filename
	set longname $filename
                set filenamelist [linsert $filenamelist end $filename]
	set shortname [file tail $longname]
	$filesel add command -label "$shortname" -command\
	  "load_buffer $temp/$filebuffer($filelist)[pid].bf $filelist\
	  {$filesave($filename)}"
	incr filelist
                set actions [lreplace $actions end end]
                set actions [lreplace $actions end end]
	wm title .ed "August ($filename)"
                set lastdir [file dirname $filename]
	return [file_write $filesave($filename) $data]
        # If user cancels out of the "Save file as..." dialog make sure filename variable is reset.
                } else {
	set filename $oldfilename
	return $filename
    }
}

# Called to exit editor/close all files.

proc exit_files {exitfiles} {
    global filesel textname filebuffer Augustdir August

    for {set arraysize [array size filebuffer]} {$arraysize > 0}\
      {incr arraysize -1} {
	file_close $textname no
    }

    if {$exitfiles == "yes"} then {
        eval file delete [glob $Augustdir/*[pid].bf]
	exit
    }

    if {$exitfiles == "no"} then {

	# file_new .ed $textname Untitled $August(tpldialog)
    }
}

# Handles window manager Close choice.

proc prompt_close {widgetname} {
    if {$widgetname == ".ed"} then {
	exit_files yes
    } else {
	destroy $widgetname
    }
}

# Find & replace dialog.

proc SearchDialog { textwidget } {
# Create find dialog.
	set dlg .finddialog
# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists $dlg] == 1 } then {
	wm deiconify $dlg
	return
	}
    global find_case find_regexp find_last_indx textname filesel files sfiles sstatus mode no_prompt oldpattern find_stat replace_stat version newtext npstat indxbtn indxstat
    # Don't require exact case match.
    set find_case 0
    # Don't search all open files.
    set mode 0
    # Don't use regexp-style searches.
    set find_regexp 0
    # Last place searched, line 1 column 0 (start).
    set find_last_indx 1.0
    # Check number of entries in window menu
      set files [$filesel index end]
    # Set startindex for multiple file search
      set sfiles 1
    # Set var for helping start search with the right file
      set sstatus 0
    # Don't replace without prompting
      set no_prompt 0
    # Set variable that contains previously used search pattern
      set oldpattern ""
    # Set variable that keeps track of the number of matches found.
      set find_stat 0
    # Set variable that keeps track of the number of replacements.
      set replace_stat 0
    # Set status for "From cursor" button.
      set indxbtn 0
     # Set control variable for "From cursor" button.
      set indxstat  1

    toplevel $dlg
    dialog_position $dlg
    wm protocol $dlg WM_DELETE_WINDOW "destroy_findrep"
    wm title $dlg Find
    wm resizable $dlg 0 0

    label $dlg.l_findwhat -text "Find what:" -anchor w
    label $dlg.l_replacewhat -text "Replace with:" -anchor w

    entry $dlg.findwhat -background white -width 30

    if {$version == "replace"} then {
	entry $dlg.replacewhat -background white -textvariable newtext -width 30
    }

    grid config $dlg.l_findwhat -column 0 -row 0 -sticky "w" -pady 8
    grid config $dlg.findwhat -column 1 -row 0 -sticky "snew" -pady 8

    if {$version == "replace"} then {
	grid config $dlg.l_replacewhat -column 0 -row 1 -sticky "w" -pady 8
	grid config $dlg.replacewhat -column 1 -row 1 -sticky "snew" -pady 8
    }

    checkbutton $dlg.mode -text "All open files" -variable mode
    if {$version == "replace"} then {
    checkbutton $dlg.prompt -text "Replace without prompting" -variable no_prompt -command {set npstat 1; dis_able $no_prompt}
    }

     proc dis_able { status } {
     if {[list $status] == 1} then {
       .finddialog.buttons.replace configure -state disabled -disabledforeground ""
         } else {
       .finddialog.buttons.replace configure -state normal -disabledforeground black
         }
     }

     checkbutton $dlg.matchcase -text "Match case" -variable find_case
     checkbutton $dlg.regexp -text "Regexp search" -variable find_regexp
     checkbutton $dlg.cursor -text "From cursor" -variable indxbtn

    grid config $dlg.mode -column 1 -row 2 -sticky "ws"
    if {$version == "replace"} then {
    grid config $dlg.prompt -column 1 -row 3 -sticky "ws"
    }
    grid config $dlg.matchcase -column 1 -row 4 -sticky "ws"
    grid config $dlg.regexp -column 1 -row 5 -sticky "ws"
    grid config $dlg.cursor -column 1 -row 6 -sticky "ws"

    set fr $dlg.buttons
    frame $fr -bd 0

    button $fr.findnext -text "Find" -command {FindText .finddialog.findwhat $textname $mode $version}
    bind $dlg.findwhat <Key-Return> {FindText $dlg.findwhat $textwidget $mode $version}

    if {$version == "replace"} then {
	button $fr.replace -text "Replace" -command {replace_text $newtext}
    }
    button $fr.cancel -text "Close" -command "destroy_findrep $version"

    pack $fr.findnext -side top -fill x -pady 6

    if {$version == "replace"} then {
	pack $fr.replace -side top -fill x -pady 6

    }

    pack $fr.cancel -side top -fill x -pady 6
    grid config $fr -column 2 -row 0 -rowspan 4 -padx 5 -pady 1

    focus $dlg.findwhat

    proc destroy_findrep {ver} {
	if {$ver == "replace"} then {
	    .finddialog.replacewhat delete 0 end
	}
	destroy .finddialog
    }
}

# Called by Find dialog to search textwidget.
# entrywidget has the text to search for.

proc FindText {entrywidget textwidget mode dlgmode} {
global find_case find_last_indx find_regexp textname filesel sstatus sfiles oldpattern find_stat replace_stat globmode no_prompt npstat indx indxbtn indxstat

    if { $indxbtn == 1 && $indxstat == 1 } then {
    set find_last_indx [$textname index insert]
    set indxstat 0
    }

     if { $mode == 0 } then {
    set globmode 0
    }  else {
    set globmode 1
    }

      if { $no_prompt == 1 } then {
    if {$npstat == 1} then {
    replace_noprompt
    return
        }
    }

    if { $mode == 0 } then {
    set sstatus 1
    }

    if { $sstatus == 0 } then {
    $filesel invoke  1
    }

    # Get pattern to search for.
    set pattern [$entrywidget get]
    # Check if search pattern has changed
    if { $pattern == $oldpattern } then {
     # do nothing...
            } else {
     if { $oldpattern == "" } then {
        set oldpattern $pattern
            } else {
        set sfiles 1

# Don't load the first file in the window menu if in single file mode.

        if { $mode == 0 } then {
        set sstatus 1
    }

# But if we're in "all open files" mode go ahead...

        if { $sstatus == 0 } then {
        $filesel invoke  1
    }
        set find_last_indx 1.0
        notice_box "Search pattern has changed. Beginning search from the start again."
        set find_stat 0
        set indxstat 1
        set replace_stat 0
                }
   }

# Update oldpattern variable.
     set oldpattern $pattern

# Get length of pattern.
    set length [string length $pattern]

# Set various options.

    set options "-forward"
    if {$find_case == 0} then {
	append options " -nocase"
    }

    if {$find_regexp == 1} then {
	append options " -regexp"
    }

# Search the text widget...
   
	set indx [eval $textwidget search $options -- {$pattern} {$find_last_indx} end] 

# Set status variable that is used below.

	set status $mode
	if {$indx == ""} then {
	append status 1
	}

# Move find index etc.

              if {$indx != ""} then {
	catch {
	    $textwidget tag remove sel sel.first sel.last
	}
	$textwidget tag add sel $indx "$indx + $length chars"
	$textwidget mark set insert $indx
	$textwidget see $indx
        after idle run_tags
	focus $textwidget
	set find_last_indx "$indx + 1 char"
                incr find_stat
    }

# When using "all open files" this proc is used.

 if {$status == "11"} then {
                 set nextfile [searchfiles]
                if {$nextfile == ""} then {
                  set no_prompt 0
                  notice_box "[get_stats $dlgmode] Search completed!"
                  set sfiles 1
                  set find_stat 0
                  set replace_stat 0
	  set indxstat 1
                  set find_last_indx "1.0"
                  return
                }
                 $filesel invoke $nextfile
                 set find_last_indx "1.0"
                 set sstatus 1
                 set status $mode
                 FindText .finddialog.findwhat $textname $mode $dlgmode
                 return
                }

# When searching a single file, this proc gives a search report and resets variables.

 if { $indx == "" } then {
                   set no_prompt 0
                   notice_box "[get_stats $dlgmode] Search completed!"
                   set sfiles 1
                   set find_stat 0
                   set replace_stat 0
	   set indxstat 1
                   set find_last_indx "1.0"
                   return
          }

}

# When searching all open files this proc pulls up the next file to search in. \
Returns an empty string if there's no more files to search in.

proc searchfiles {} {
        global files sfiles
       if {$sfiles >  $files} then {
        return
      }
        set value $sfiles
        incr sfiles
        return "$value"
 }

# Keeps track of the number of matches and replacements.

proc get_stats { mode } {
        global find_stat replace_stat
     if {$mode == "find"} then {
        return "$find_stat matches found."
      } else {
        return "$find_stat matches found. [list $replace_stat] were replaced."
      }
}

# Proc that takes care of replacing all matching text without prompting.

proc replace_noprompt {} {
	global no_prompt globmode version newtext textname npstat
	set npstat 0
	while {$no_prompt == 1} {
	FindText .finddialog.findwhat $textname "$globmode" $version
	catch {
	replace_text $newtext
	}
        }
}

# Proc for Find - Replace.

proc replace_text {replacetext} {
    global textname find_last_indx replace_stat
    catch {
    $textname delete sel.first sel.last
    $textname insert insert $replacetext
    set find_last_indx [$textname index insert]
    incr replace_stat
      }
}

# Proc to enclose text with HTML tags.

proc formating {f1 f2} {
    global textname
    focus $textname
    set format ""

    catch {
                set format  [$textname get sel.first sel.last]
 }

    catch {
	set bformat [format "$f1%s$f2" $format]
	$textname delete sel.first sel.last
	$textname insert insert $bformat
      if {$f2 == "\"></A>"} then {
        set_cur "insert-4c"
        }
      }
             if {$format == ""} then {
    catch {
                    $textname insert insert "$f1$f2"
                    set curpos [string length $f2]
                    set c c
                    set_cur "insert-$curpos$c"
              }
      }
   selection clear
   after idle run_tags
   update
}

# Proc for removing tags.

proc remove_tags {} {
    global textname
    if {[selection own] != ""} then {
	set tags [selection get]
	regsub -all {<[^>]*>} $tags "" notags
	$textname delete sel.first sel.last
	$textname insert insert $notags
	selection clear
	set selstat ""
    } else {
	set selstat [tk_messageBox -title "Remove tags" -message "No text is\
	  selected, remove all tags?" -type yesno]
    }

    if {$selstat == "yes"} then {
	set tags [$textname get 1.0 end]
	regsub -all {<[^>]*>} $tags "" notags
	$textname delete 1.0 end
	$textname insert 1.0 $notags
    }
}

# Proc for removing tabs.

proc remove_tabs {keepformat} {
    global textname
    if {[selection own] != ""} then {
	set tabs [selection get]
                if {$keepformat == "yes"} then {
	set notabs [untab $tabs]
      } else {
                regsub -all "\t" $tabs "" notabs
             }
	$textname delete sel.first sel.last
	$textname insert insert $notabs
	selection clear
	set selstat ""
    } else {
	set selstat [tk_messageBox -title "Remove tabs" -message "No text is\
	  selected, remove all tabs?" -type yesno]
    }

    if {$selstat == "yes"} then {
	set tabs [$textname get 1.0 end]
	if {$keepformat == "yes"} then {
	set notabs [untab $tabs]
      } else {
                regsub -all "\t" $tabs "" notabs
             }
	$textname delete 1.0 end
	$textname insert 1.0 $notabs
    }
}

# Remove tabs without changing format.

proc untab {str {tablen 8}} {
                set a 0
                set i [string first "\t" $str]
                while {$i != -1} {
                set m { }
                set j $i
                while {[incr j]%$tablen} { append m { } }
                set str [string range $str $a [expr {$i-1}]]$m[string range $str [incr i] end]
                set  i [string first "\t" $str]
                          }
                          return $str
       }

# Proc for changing case.

proc change_case {case} {
    global textname
    set astring [selection get]
    if {$case != ""} then {
	set anewstring [string $case $astring]
	$textname delete sel.first sel.last
	$textname insert insert $anewstring
    }
}


# Proc for inserting blocks of code.

proc insert_code {c} {
    global textname
    $textname insert insert $c
    update
    run_tags
}

# Preview with Lynx.

proc prev_lynx { } {
          global filename August
          exec $August(lynxterm) -e lynx $filename &
           }

# Preview with Opera

proc prev_opera {} {
# Opera experiment...
exec opera file://$filename &
}

# Preview with Konqueror (Alpha!)
# Doesn't work on my system...maybe if you have newer KDE;-)

proc prev_konqueror { } {
global konqwin  filename fooid

if {$konqwin == "0"} then {
exec kfmclient openURL  $filename &
set konqwin "1"
return
}

if {$konqwin == "1"} then {
set fooid [eval exec dcop konqueror qt find mainwindow | grep mainwindow | head -n1 ]
puts $fooid
exec dcop konqueror "$fooid" openURL $filename &
 }
}


# Preview with Kdehelp.

proc prev_kdehelp { } {
          global filename August
          exec kdehelp $filename &
  }

# Preview with Linux & Windows.

proc prev_multi {} {
    global filename netwin August tcl_platform

    if {$filename == "Untitled"} then {
    notice_box "You have to save this file before you can preview it!"
    return
	}

# Windows NT
      if {$tcl_platform(os) == "Windows NT"} then {
      exec $env(COMSPEC) /c start $filename &
      return
}

# Windows 95/98
      if { $tcl_platform(os) == "Windows 95" || $tcl_platform(os) == "Windows 98" } then {
      exec start iexplore $filename &
      return
}

# Linux

      if { $tcl_platform(platform) == "unix" && $netwin == "0"} then {
      exec $August(netscapepath) $filename &
      set netwin "1"
      return
      }

      if { $tcl_platform(platform) == "unix" && $netwin == "1"} then {
      exec $August(netscapepath) -remote openFile($filename) &
      }

  }

# Proc for inserting RGB color values.

proc color_code_insert {widget} {
    global textname
    set colorcode [tk_chooseColor -initialcolor white -title "Color"]
    $widget insert insert $colorcode
}

# Switching on and off entry widget.

proc on_off {optvar optwidg} {
    if {$optvar == 1} then {
	$optwidg configure -state normal -background white
	focus $optwidg
    } else {
	$optwidg delete 0 end
	$optwidg configure -state disabled -background grey
    }
}

# Positioning of toplevel windows.

proc dialog_position {dlg} {
    set width [winfo screenwidth .ed]
    set height [winfo screenheight .ed]
    set x [expr ($width/2) -200]
    set y [expr ($height/2) -200]
    wm geometry $dlg +$x+$y
}

# Load buffered file, write content of current file to buffer, update variables.

proc load_buffer {file buffer id} {
    global textname current filebuffer filelist filename temp actions
    set filename [file join $filename]
    set file [file join $file]
    set id [file join $id]
    set content [$textname get 1.0 {end -1c}]
    set fid [open $temp/$filebuffer($current)[pid].bf "w+"]
    puts -nonewline $fid $content
    close $fid
    set fileid [open $file "r+"]
    set data [read $fileid]
    close $fileid
    set current $buffer
    set filename $id
    $textname delete 1.0 end
    $textname insert {end -1c} $data
    set actions [lreplace $actions 0 end]
    wm title .ed "August ($filename)"
    update
    run_tags
}

# Proc for printing.

proc print_doc {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .prdlg] == 1 } then {
	wm deiconify .prdlg
	return
	}
    global textname August
    toplevel .prdlg
    dialog_position .prdlg
    wm resizable .prdlg  0 0

    tk_optionMenu .prdlg.prcomsel prcomm lpr lp

    set prcomm "$August(prcomm)"

    label .prdlg.prsellab -text "Printer:"
    label .prdlg.prcoplab -text "Copies:"

    entry .prdlg.prsel -textvariable prname -background white -width 15
    entry .prdlg.prcop -textvariable copies -background white -width 5

    grid configure .prdlg.prcomsel -column 1 -row 1 -pady 5 -padx 5
    grid configure .prdlg.prsellab -column 1 -row 2 -pady 5 -padx 5
    grid configure .prdlg.prcoplab -column 1 -row 3 -pady 5 -padx 5
    grid configure .prdlg.prsel -column 2 -row 2 -pady 5 -padx 5 -sticky "w"
    grid configure .prdlg.prcop -column 2 -row 3 -pady 5 -padx 5 -sticky "w"

    button .prdlg.prok -text "OK" -command {pr}
    button .prdlg.prcancel -text "Cancel" -command {destroy_pr}

    grid configure .prdlg.prok -column 1 -row 4 -pady 5 -padx 5
    grid configure .prdlg.prcancel -column 2 -row 4 -pady 5 -padx 5

    .prdlg.prsel delete 0 end
    .prdlg.prsel insert end $August(prname)

    .prdlg.prcop delete 0 end
    .prdlg.prcop insert end $August(copies)

    proc pr {} {
	global prcomm textname Augustdir prname copies
	if {$prcomm == "lpr"} then {
	    set cpopt "-#"
	    set propt "-P"
	} else {
	    set cpopt "-n"
	    set propt "-d"
	}
	if {$prname == ""} then {
	    set prn ""
	} else {
	    set prn "$propt$prname"
	}
	if {$copies == ""} then {
	    set cps ""
	} else {
	    set cps "$cpopt$copies"
	}
	set printer [open "| $prcomm $prn $cps" w]
	puts $printer [$textname get 1.0 end]
	close $printer
	destroy_pr
	update_printbox
    }

    proc destroy_pr {} {
	destroy .prdlg
    }

}

proc update_printbox {} {
    global prcomm copies prname August Augustdir
    set August(prcomm) $prcomm
    set August(prname) $prname
    set August(copies) $copies
    set file [file join $Augustdir Augustoptions.tcl]
    UserPrefSave $file August
}

# Save user preferences.

proc UserPrefSave {filename arrayname} {
    upvar #0 $arrayname array_link
    set fileid [open $filename "w"]
    set names [array names array_link]
    puts $fileid "# PROGRAM OPTIONS. DO NOT EDIT."
    foreach name $names {
	set var [format "set %s(%s)" $arrayname $name]
        puts $fileid "$var \{$array_link($name)\}"
    }
    puts $fileid "global $arrayname"
    close $fileid
}

# Loading user preferences.

proc UserPrefLoad {filename} {
    catch {
	source $filename
    }
}

# Set program options.

proc set_options {} {
	# Check if the dialog already exists, and if it does, raise it.
	if { [winfo exists .options] == 1 } then {
	wm deiconify .options
	return
	}

    catch {

	global August

# Keep track of old value for special characters.

set oldchars $August(specchars)

	toplevel .options
	dialog_position .options
	wm title .options "August options"
	wm protocol .options WM_DELETE_WINDOW {destroy_options}
                wm resizable .options  0 0

	label .options.lab1 -text "Document path:"
                checkbutton .options.check1 -text "Open/Save to last directory visited" -variable opendirstatus\
	  -onvalue "yes" -offvalue "no"
	checkbutton .options.check2 -text "Use STRONG for BOLD" -variable bold\
	  -onvalue "STRONG" -offvalue "B"
	checkbutton .options.check3 -text "Use EMPHASIS for ITALICS"\
	  -variable ital -onvalue "EM" -offvalue "I"
	checkbutton .options.check4 -text {Show template dialog when choosing "New file"} -variable tpldlg\
	  -onvalue "yes" -offvalue "no"
                checkbutton .options.check5 -text {Syntax coloring} -variable syncolor\
	  -onvalue "yes" -offvalue "no"
	label .options.lab2 -text "Netscape path:"

	entry .options.ent1 -textvariable docpath -background white -width 30
	entry .options.ent2 -textvariable August(netscapepath)\
	  -background white -width 30

               label .options.lab3 -text "Lynx terminal:"
              tk_optionMenu .options.lynxt  August(lynxterm) rxvt xterm konsole gnome-terminal

              label .options.lab4 -text "Special characters:"
              tk_optionMenu .options.spech  August(specchars) none swedish italian spanish

              label .options.lab5 -text "Identify path:"
              entry .options.ent3 -textvariable August(identifypath)\
	  -background white -width 30

	label .options.lab6 -text "Editor font:"
                tk_optionMenu .options.font  August(font) times courier helvetica misc
	label .options.lab7 -text "Editor font size:"
                tk_optionMenu .options.fontsize  August(fontsize) 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
	label .options.lab8 -text "Editor line wrap:"
                tk_optionMenu .options.wrap  August(wrap) none word char
	global docpath bold italics

	button .options.button1 -text "OK" -command "write_prefs $oldchars"
	button .options.button2 -text "Cancel" -command {destroy_options}

	grid configure .options.lab1 -column 0 -row 1 -padx 3 -pady 3
	grid configure .options.lab2 -column 0 -row 8 -padx 3 -pady 3
	grid configure .options.ent1 -column 1 -row 1 -padx 3 -pady 3
	grid configure .options.ent2 -column 1 -row 8 -padx 3 -pady 3
                grid configure .options.lab3 -column 0 -row 9 -padx 3 -pady 3
                grid configure .options.lynxt -column 1 -row 9 -padx 3 -pady 3
                grid configure .options.lab4 -column 0 -row 10 -padx 3 -pady 3
                grid configure .options.spech -column 1 -row 10 -padx 3 -pady 3
                grid configure .options.lab5 -column 0 -row 11 -padx 3 -pady 3
                grid configure .options.ent3 -column 1 -row 11 -padx 3 -pady 3
	grid configure .options.lab6 -column 0 -row 12 -padx 3 -pady 3
                grid configure .options.font -column 1 -row 12 -padx 3 -pady 3
	grid configure .options.lab7 -column 0 -row 13 -padx 3 -pady 3
	grid configure .options.fontsize -column 1 -row 13 -padx 3 -pady 3
	grid configure .options.lab8 -column 0 -row 14 -padx 3 -pady 3
	grid configure .options.wrap -column 1 -row 14 -padx 3 -pady 3
                grid configure .options.check1 -column 1 -row 3 -padx 3 -pady 3\
	  -sticky "w"
	grid configure .options.check2 -column 1 -row 4 -padx 3 -pady 3\
	  -sticky "w"
	grid configure .options.check3 -column 1 -row 5 -padx 3 -pady 3\
	  -sticky "w"
	grid configure .options.check4 -column 1 -row 6 -padx 3 -pady 3\
	  -sticky "w"
                grid configure .options.check5 -column 1 -row 7 -padx 3 -pady 3\
	  -sticky "w"
 	grid configure .options.button1 -column 0 -row 15
	grid configure .options.button2 -column 1 -row 15


        if {$August(openlastdir) == "no"} then {
	    .options.check1 deselect
	} else {
	    .options.check1 select
	}

	if {$August(bold) == "B"} then {
	    .options.check2 deselect
	} else {
	    .options.check2 select
	}

	if {$August(ital) == "I"} then {
	    .options.check3 deselect
	} else {
	    .options.check3 select
	}

	if {$August(tpldialog) == "no"} then {
	    .options.check4 deselect
	} else {
	    .options.check4 select
	}

                if {$August(syncolor) == "yes"} then {
	    .options.check5 select
	} else {
	    .options.check5 deselect
	}

	if {$docpath == ""} then {
	    .options.ent1 insert end $August(docpath)
	}

                   proc write_prefs { ochars } {
	    global Augustdir textname August docpath bold ital tpldlg\
                    opendirstatus  syncolor
	    set docpath [file join $docpath]
	    set checkpath [file isdirectory $docpath]

	    if {$checkpath == 0} then {
		notice_box "The choosen document path is not valid!"
		.options.ent1 selection range 0 end
		return
	    }

	$textname configure -font "$August(font) $August(fontsize)"
	$textname configure -wrap "$August(wrap)"

# Tell user to re-start August if special character settings have changed.

if {$August(specchars) != $ochars} then {
notice_box "Please re-start August to enable special character settings!"
}

	    if {$August(netscapepath) == "netscape"} then {
	    } else {
		if {[file exists $August(netscapepath)] == "0"} then {
		    notice_box "Not the correct path...!"
		    .options.ent2 selection range 0 end
		    return
		}
	    }

                     if {$August(identifypath) == "identify"} then {
	    } else {
		if {[file exists $August(identifypath)] == "0"} then {
		    notice_box "Not the correct path...!"
		    .options.ent3 selection range 0 end
		    return
		}
	    }

                if {$syncolor == "no"} then {
                .ed.te.edit1 tag remove alltags  1.0 end
                .ed.te.edit1 tag remove conftags  1.0 end
                 .ed.te.edit1 tag remove imgtags  1.0 end
                 .ed.te.edit1 tag remove linktags  1.0 end
                .ed.te.edit1 tag remove tabletags  1.0 end
                } elseif {$syncolor == "yes"} then {
                 after idle  run_tags
                 }

	    set August(docpath) $docpath
                    set August(openlastdir) $opendirstatus
	    set August(bold) $bold
	    set August(ital) $ital
	    set August(tpldialog) $tpldlg
                    set August(syncolor) $syncolor
	    set file [file join $Augustdir Augustoptions.tcl]
	    UserPrefSave $file August
	    destroy_options
	}

	proc destroy_options {} {
	    destroy .options
	}
    }
}

# Syntax highlighting

proc search_text {string tagname fstindex endindex} {
global textname

#_.ed.te.edit1_ tag remove search $fstindex $endindex

if {$string == ""} {
return
    }

while 1 {
set fstindex [_.ed.te.edit1_ search -regexp -nocase -count length $string $fstindex $endindex]

if {$fstindex == ""} {
break
   }

_.ed.te.edit1_ tag add $tagname $fstindex "$fstindex + $length char"

set fstindex [_.ed.te.edit1_ index "$fstindex + $length char"]
   }

}

proc run_tags {} {
global August

if {$August(syncolor) == "no"} then {
return
}

global textname

set startindex [get_start]
set stopindex  [get_end]

search_text {(<[^>]*>)} alltags $startindex $stopindex
update
search_text {(<[^>]*$)} alltags $startindex $stopindex
update
search_text {(^[^<]*>)} alltags  $startindex $stopindex
update
search_text {("[^"]*")} conftags $startindex $stopindex
update
search_text  "<img src" imgtags  $startindex $stopindex
update
search_text  "<a href" linktags  $startindex $stopindex
update
search_text  "<table" tabletags  $startindex $stopindex
update
}

proc get_start {} {
global numlines
set vertpos [.ed.te.edit1 yview]
set data [.ed.te.edit1 get 1.0 end]
set numlines [regsub -all \n $data {} ignore]
set start [lindex $vertpos 0]
set sidx [expr $start * $numlines]
set startpos [expr ceil($sidx)]
}

proc get_end {} {
global numlines
set vertpos [.ed.te.edit1 yview]
set end [lindex $vertpos 1]
set eidx [expr $end * $numlines]
set endpos [expr ceil($eidx) + 2]
}

# Create notice box.

proc notice_box {message} {
    tk_messageBox -icon info -title "Info" -message "$message"
}

# Set cursor in the right position when inserting code.

proc set_cur {pos} {
global textname
$textname mark set insert $pos
}

# Undo - create actions list and rename text widget.

set actions [list ""]
global actions
set actions [lreplace $actions end end]
rename  .ed.te.edit1  _.ed.te.edit1_

# Proc to collect actions from text widget.

proc  .ed.te.edit1 {command args} {
              global actions August
              if {$command == "insert"} then {
              set startindex [_.ed.te.edit1_ index insert]
              set dtext [lindex $args end]
              set txtlngt [string length $dtext]
              set insind [subst {$startindex "$startindex +$txtlngt chars"}]
              set actions [linsert $actions end  $insind]
              set actions [linsert $actions end "$command"]
           } elseif {$command == "delete"} then {
              set indstatus $args
             if {$indstatus == "sel.first sel.last"} then {
              set selindex [_.ed.te.edit1_ tag nextrange sel sel.first sel.last]
              set firstind [lindex $selindex 0]
              set itext [_.ed.te.edit1_  get  sel.first sel.last]
              regexp {[0-9]*\.[0-9]*} $firstind firstind
              set insargs [subst {$firstind {$itext}}]
           } else {
              set startindex [_.ed.te.edit1_ index insert]
              set getitext [lindex $args end]
              set itext [_.ed.te.edit1_ get $getitext]
              regexp {[0-9]*\.[0-9]*} $startindex startindex
              regexp {^[0-9]*} $startindex findex
              regexp {[0-9]*$} $startindex sindex
             if {$args == "insert-1c"} then {
              set stindex [incr sindex -1]
           } else {
              set stindex $sindex
           }
              set insargs [subst {"$findex.$stindex" "$itext"}]
           }
              set actions [linsert $actions end "$insargs"]
              set actions [linsert $actions end "$command"]
        }

# Let the real text widget do its work.
              set result [eval  _.ed.te.edit1_  $command $args]
# Update statusbar
	set lcindex [ _.ed.te.edit1_ index insert]
	regexp {^[0-9]*} $lcindex lineindex
	regexp {[0-9]*$} $lcindex charindex
	.ed.sa.status2 configure -text "Line: $lineindex"
	.ed.sa.status3 configure -text "Char: $charindex"
	return $result
   }


# Undo command.

proc undo { }   {
     catch {
              global actions
              set last_action [lindex $actions end]
              set number [llength $actions]
              set actind [incr number -2]
             if {$last_action == "delete"} {
              set action [lindex $actions $actind]
              set actions [lreplace $actions end end]
              set actions [lreplace $actions end end]
              eval _.ed.te.edit1_ insert $action
           } elseif {$last_action == "insert"} {
              set delindex  [lindex $actions $actind]
              set actions [lreplace $actions end end]
              set actions [lreplace $actions end end]
              eval _.ed.te.edit1_  delete "$delindex"
          }
     }
 }

# Configure tags for syntax highlighting.

_.ed.te.edit1_ tag configure alltags -foreground #fe0c20
_.ed.te.edit1_ tag configure conftags -foreground black
_.ed.te.edit1_ tag configure imgtags -foreground #604cee
_.ed.te.edit1_ tag configure linktags -foreground darkgreen
_.ed.te.edit1_ tag configure tabletags -foreground #ff980e

# Run file_first proc.

file_first .ed $textname Untitled

# Load file or filename from command line.

       if { $argc > 0 } then {
        set path [pwd]
        set fnm [lindex $argv 0]
        set filetypes [list .htm .html .css .php .php3 .txt]
       if { $fnm ==  "-all" } then {
        set dirfiles [glob -nocomplain *]
        foreach dirfile $dirfiles {
           set fileext [file extension $dirfile]
           set filetypestatus [lsearch -exact $filetypes $fileext]
         if { $filetypestatus != "-1" } then {
            set filetypestatus 1
                    }
           set fileopenstatus [file isdirectory $dirfile]
           incr fileopenstatus $filetypestatus
         if { $fileopenstatus == 1 } then {
        file_open .ed $textname yes "[pwd]/$dirfile"
                       }
                 }
              return
          }
        set filestatusa [file exists $fnm]
        set filestatusb [file dirname $fnm]
        if {$filestatusb == "."} then {
        set filepath "$path/$fnm"
    } else { set filepath "$fnm"
           }
        if { $filestatusa == "1" } then {
        file_open .ed $textname yes $filepath
    } else {
        tkwait visibility $textname
        file_new .ed $textname $filepath $August(tpldialog)
        set fileid [open $filepath "w+"]
        close $fileid
      }

 }

focus $textname









