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, 2 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.
1: """simpleEdit can be used to edit the tex fragments in context
2: determined by a texxml file.
3:
4: Use:
5:
6: python simpleEdit.py [name of texxml file]
7:
8: simpleEdit will read the texxml file, and present the referenced tex
9: fragments in order determined by the file. When you save (CTRL-S),
10: simpleEdit will save all the tex fragments back to their little
11: files.
12:
13: Very, very simple.
14: """
15:
16: import sys
17: if len(sys.argv) < 2:
18: print "Usage: python simpleEdit.py [name of texxml file]"
19: print "See top of source code for usage."
20: print "To save files, press CTRL-s in the editor."
21: sys.exit()
22:
23: import xml.parsers.expat
24:
25: dirprefix = "/home/httpd/html/adm/help/tex/"
26:
27: fileList = []
28:
29: def startElement(name, attrs):
30: if name == "file":
31: fileList.append(str(attrs["name"]))
32:
33: p = xml.parsers.expat.ParserCreate()
34: p.StartElementHandler = startElement
35: f = file(sys.argv[1], 'r')
36: p.Parse(f.read())
37:
38:
39: from Tkinter import *
40: from ScrolledText import *
41: import string
42: import os
43:
44: class simpleEditor:
45: def __init__(self, master):
46: self.frame = Frame(master)
47: self.frame.pack()
48:
49: self.label = Label(self.frame, text = "For documentation on"
50: "this program, consult the source code.")
51: self.label.pack()
52:
53: self.text = ScrolledText(self.frame, width=120, height = 40);
54: self.text.pack(fill = BOTH, expand = 1)
55:
56: self.searchText = Text(self.frame, width = 40, height = 1);
57: self.searchText.pack()
58: self.searchButton = Button(self.frame, text = "Search",
59: command = self.search)
60: self.searchButton.pack()
61:
62: self.button = Button(self.frame, text = "Save", \
63: command = self.save)
64: self.button.pack()
65:
66: def search(self):
67: searchText = self.searchText.get("1.0", END)
68: searchText = searchText.strip()
69: print self.text.index(INSERT + "+%ic" % len(searchText))
70: pos = self.text.search(searchText,
71: self.searchText.index(INSERT) +
72: "+%ic" % (len(searchText) + 1))
73: self.text.see(pos)
74: self.text.tag_add(SEL, pos, pos + "+%ic" % len(searchText))
75: self.text.mark_set(INSERT, pos)
76:
77: def load(self):
78: """Loads in all the tex files."""
79:
80: colors = ["#FFFFFF", "#CCCCCC"]
81:
82: c = 0
83:
84: for f in fileList:
85: f = file(dirprefix + f, 'r')
86: tex = f.read()
87: f.close()
88: self.text.tag_config("texfile%i" % c,
89: background = colors[c%len(colors)])
90: self.text.insert(END, tex, "texfile%i" % c)
91: self.text.insert(END, "\n\n") # prettier
92: c += 1
93:
94: def save(self):
95: c = 0
96:
97: for f in fileList:
98: tex = self.text.get("texfile%i.first" % c,
99: "texfile%i.last" % c)
100: os.rename ( dirprefix + f, dirprefix + f + "~" )
101: f = file(dirprefix + f, 'w')
102: f.write(tex)
103: f.close()
104: c += 1
105:
106:
107:
108:
109: root = Tk()
110: app = simpleEditor(root)
111: app.load()
112: root.mainloop()
113:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>