Stringscan

Check-in [a650365576]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further refinements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a650365576bd3bde33399c5b19cf33de5f8b9e28e04630cb7e6a78055b572d07
User & Date: kevin 2017-06-24 22:41:12
Context
2017-06-25
02:51
Further tweaks of comments check-in: fadc0bf21b user: kevin tags: trunk
2017-06-24
22:41
Further refinements check-in: a650365576 user: kevin tags: trunk
20:21
Update help credits check-in: d62c1c6307 user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Deleted highlights.rb.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	# textLoadFile --
	# This method below loads a file into a text widget, discarding
	# the previous contents of the widget. Tags for the old widget are
	# not affected, however.
	#
	# Arguments:
	# w -           The window into which to load the file.  Must be a
	#               text widget.
	# file -        The name of the file to load.  Must be readable.
	def textLoadFile(w,file)
		w.delete('1.0', 'end')
		f = open(file, 'r')
		while(!f.eof?)
			w.insert('end', f.read(1000))
		end
		f.close
	end
	# textSearch --
	# Search for all instances of a given string in a text widget and
	# apply a given tag to each instance found.
	#
	# Arguments:
	# w -           The window in which to search.  Must be a text widget.
	# string -      The string to search for.  The search is done using
	#               exact matching only;  no special characters.
	# tag -         Tag to apply to each instance of a matching string.
	def textSearch(w, string, tag)
		tag.remove('0.0', 'end')
		return if string == ""
		cur = '1.0'
		loop {
			cur, len = w.search_with_length(string, cur, 'end')
			break if cur == ""
			tag.add(cur, "#{cur} + #{len} char")
			cur = w.index("#{cur} + #{len} char")
		}
	end
	# Set up display styles for text highlighting.
	if TkWinfo.depth($search_demo) > 1
		textToggle(proc{
			$search_Tag.configure('background'=>'#ce5555',
			'foreground'=>'white')
		},
		800,
		proc{
			$search_Tag.configure('background'=>'', 'foreground'=>'')
		},
	200 )
else
	textToggle(proc{
		$search_Tag.configure('background'=>'black',
		'foreground'=>'white')
	},
	800,
	proc{
		$search_Tag.configure('background'=>'', 'foreground'=>'')
	},
200 )
end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































Changes to stringscan.rb.

197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	$termlabel = Tk::Tile::Label.new($topframe) {text "Search Term:"}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$termentry = Tk::Tile::Entry.new($topframe) {textvariable $searchterm}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$termentry.bind('Return', proc {stringgrep})
	$nextsep = Tk::Tile::Separator.new($mainframe) {orient 'horizontal'}.pack('side'=>'top', 'fill'=>'both')
	
	#listbox, textbox, scrollbars
	$bottomframe = Tk::Frame.new($mainframe).pack('side'=>'bottom','fill' => 'both', 'expand' => 'yes')
	$bottomleftframe  =Tk::Tile::Frame.new($bottomframe).pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
	$listlabel = Tk::Tile::Label.new($bottomleftframe) {
		text 'File Name'
		style 'TablelistHeader.TLabel'
		padding 1
	}.pack('side'=>'top', 'fill'=>'both', 'expand' => 'no')
	$lbox = Tk::Listbox.new($bottomleftframe){
		width 50







|







197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	$termlabel = Tk::Tile::Label.new($topframe) {text "Search Term:"}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$termentry = Tk::Tile::Entry.new($topframe) {textvariable $searchterm}.pack('side' => 'left','fill' => 'both','expand' => 'no')
	$termentry.bind('Return', proc {stringgrep})
	$nextsep = Tk::Tile::Separator.new($mainframe) {orient 'horizontal'}.pack('side'=>'top', 'fill'=>'both')
	
	#listbox, textbox, scrollbars
	$bottomframe = Tk::Frame.new($mainframe).pack('side'=>'bottom','fill' => 'both', 'expand' => 'yes')
	$bottomleftframe = Tk::Tile::Frame.new($bottomframe).pack('side'=>'left','fill' => 'both', 'expand' => 'yes')
	$listlabel = Tk::Tile::Label.new($bottomleftframe) {
		text 'File Name'
		style 'TablelistHeader.TLabel'
		padding 1
	}.pack('side'=>'top', 'fill'=>'both', 'expand' => 'no')
	$lbox = Tk::Listbox.new($bottomleftframe){
		width 50