File:
[LON-CAPA] /
doc /
help /
simpleEdit.py
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Fri Jul 5 16:12:30 2002 UTC (22 years, 4 months ago) by
bowersj2
Branches:
MAIN
CVS tags:
version_2_9_X,
version_2_9_99_0,
version_2_9_1,
version_2_9_0,
version_2_8_X,
version_2_8_99_1,
version_2_8_99_0,
version_2_8_2,
version_2_8_1,
version_2_8_0,
version_2_7_X,
version_2_7_99_1,
version_2_7_99_0,
version_2_7_1,
version_2_7_0,
version_2_6_X,
version_2_6_99_1,
version_2_6_99_0,
version_2_6_3,
version_2_6_2,
version_2_6_1,
version_2_6_0,
version_2_5_X,
version_2_5_99_1,
version_2_5_99_0,
version_2_5_2,
version_2_5_1,
version_2_5_0,
version_2_4_X,
version_2_4_99_0,
version_2_4_2,
version_2_4_1,
version_2_4_0,
version_2_3_X,
version_2_3_99_0,
version_2_3_2,
version_2_3_1,
version_2_3_0,
version_2_2_X,
version_2_2_99_1,
version_2_2_99_0,
version_2_2_2,
version_2_2_1,
version_2_2_0,
version_2_1_X,
version_2_1_99_3,
version_2_1_99_2,
version_2_1_99_1,
version_2_1_99_0,
version_2_1_3,
version_2_1_2,
version_2_1_1,
version_2_1_0,
version_2_12_X,
version_2_11_X,
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0,
version_2_10_X,
version_2_10_1,
version_2_10_0_RC2,
version_2_10_0_RC1,
version_2_10_0,
version_2_0_X,
version_2_0_99_1,
version_2_0_2,
version_2_0_1,
version_2_0_0,
version_1_99_3,
version_1_99_2,
version_1_99_1_tmcc,
version_1_99_1,
version_1_99_0_tmcc,
version_1_99_0,
version_1_3_X,
version_1_3_3,
version_1_3_2,
version_1_3_1,
version_1_3_0,
version_1_2_X,
version_1_2_99_1,
version_1_2_99_0,
version_1_2_1,
version_1_2_0,
version_1_1_X,
version_1_1_99_5,
version_1_1_99_4,
version_1_1_99_3,
version_1_1_99_2,
version_1_1_99_1,
version_1_1_99_0,
version_1_1_3,
version_1_1_2,
version_1_1_1,
version_1_1_0,
version_1_0_99_3,
version_1_0_99_2,
version_1_0_99_1,
version_1_0_99,
version_1_0_3,
version_1_0_2,
version_1_0_1,
version_1_0_0,
version_0_99_5,
version_0_99_4,
version_0_99_3,
version_0_99_2,
version_0_99_1,
version_0_99_0,
version_0_6_2,
version_0_6,
version_0_5_1,
version_0_5,
loncapaMITrelate_1,
language_hyphenation_merge,
language_hyphenation,
conference_2003,
bz6209-base,
bz6209,
HEAD,
GCI_3,
GCI_2,
GCI_1,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse,
BZ4492-feature_Support_horizontal_radioresponse,
BZ4492-Support_horizontal_radioresponse
This commit implements the .tex-based online help system in LON-CAPA. It
may be necessary to manually run loncom/build/help_graphics_converter.pl
and doc/help/rebuildLabelHash.pl after a cvs update, and
loncapa_apache.conf may need to be manually copied to /etc. (The
loncapafiles.lpml has been updated.)
After merging this, the URL http://[loncapahost]/adm/help/Foils.hlp
should display a help file.
Also, some *very* out-of-date files have been removed from the /doc
directory.
"""simpleEdit can be used to edit the tex fragments in context
determined by a texxml file.
Use:
python simpleEdit.py [name of texxml file]
simpleEdit will read the texxml file, and present the referenced tex
fragments in order determined by the file. When you save (CTRL-S),
simpleEdit will save all the tex fragments back to their little
files.
Very, very simple.
"""
import sys
if len(sys.argv) < 2:
print "Usage: python simpleEdit.py [name of texxml file]"
print "See top of source code for usage."
print "To save files, press CTRL-s in the editor."
sys.exit()
import xml.parsers.expat
dirprefix = "/home/httpd/html/adm/help/tex/"
fileList = []
def startElement(name, attrs):
if name == "file":
fileList.append(str(attrs["name"]))
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = startElement
f = file(sys.argv[1], 'r')
p.Parse(f.read())
from Tkinter import *
from ScrolledText import *
import string
import os
class simpleEditor:
def __init__(self, master):
self.frame = Frame(master)
self.frame.pack()
self.label = Label(self.frame, text = "For documentation on"
"this program, consult the source code.")
self.label.pack()
self.text = ScrolledText(self.frame, width=120, height = 40);
self.text.pack(fill = BOTH, expand = 1)
self.searchText = Text(self.frame, width = 40, height = 1);
self.searchText.pack()
self.searchButton = Button(self.frame, text = "Search",
command = self.search)
self.searchButton.pack()
self.button = Button(self.frame, text = "Save", \
command = self.save)
self.button.pack()
def search(self):
searchText = self.searchText.get("1.0", END)
searchText = searchText.strip()
print self.text.index(INSERT + "+%ic" % len(searchText))
pos = self.text.search(searchText,
self.searchText.index(INSERT) +
"+%ic" % (len(searchText) + 1))
self.text.see(pos)
self.text.tag_add(SEL, pos, pos + "+%ic" % len(searchText))
self.text.mark_set(INSERT, pos)
def load(self):
"""Loads in all the tex files."""
colors = ["#FFFFFF", "#CCCCCC"]
c = 0
for f in fileList:
f = file(dirprefix + f, 'r')
tex = f.read()
f.close()
self.text.tag_config("texfile%i" % c,
background = colors[c%len(colors)])
self.text.insert(END, tex, "texfile%i" % c)
self.text.insert(END, "\n\n") # prettier
c += 1
def save(self):
c = 0
for f in fileList:
tex = self.text.get("texfile%i.first" % c,
"texfile%i.last" % c)
os.rename ( dirprefix + f, dirprefix + f + "~" )
f = file(dirprefix + f, 'w')
f.write(tex)
f.close()
c += 1
root = Tk()
app = simpleEditor(root)
app.load()
root.mainloop()
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>