Date: Sun, 20 Feb 2011 17:26:11 -0800 From: Chip Camden <sterling@camdensoftware.com> To: FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG> Subject: Re: revised pager..... Message-ID: <20110221012610.GC2220@libertas.local.camdensoftware.com> In-Reply-To: <20110221011755.GA16912@thought.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] Quoth Gary Kline on Sunday, 20 February 2011: > THis is to the entire list, mostly to Chip. It is o8.rb, my > very slightly tweaked version of what you ma/// rather, what i > found and began messing with a couple, three hours ago. > > I searched++ and could not find the C equivalent of > "if counter % N == 0" in ruby. For some reason, use of parens > in ruby seems to be discouraged. Anyway, I would have coded that > ruby line as > > if ( counter % 15) == 0 > > but didn't want to risk it since i don't know ruby. > > Anyway, o8.rb included. This version, using the "[][][][][]" to > emulate a bar, makes reading a reasonably-sized bunch of text > much easier. > > Thanks again for your help. > > -- > Gary Kline kline@thought.org http://www.thought.org Public Service Unix > Try this version instead. There's no need to find the % 15, we're already paging on the specified number. #!/usr/bin/env ruby require 'optparse' def banner print "\n[][][][][][][][][][][][][][][][][][][][]\n\n" end pagesize = 15 optparse = OptionParser.new do |opts| opts.banner = 'usage: npg [-n pagesize] file...' opts.on('-n', '--numlines pagesize', 'Specify page size in number of lines') do |n| pagesize = n.to_i end end begin optparse.parse! rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e puts e puts optparse exit 1 end banner loop do pagesize.times do if line = gets puts line else banner exit end end banner print "More..." system "stty raw" STDIN.getc system "stty -raw" banner end -- Sterling (Chip) Camden | sterling@camdensoftware.com | 2048D/3A978E4F http://chipsquips.com | http://camdensoftware.com | http://chipstips.com [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iQEcBAEBAgAGBQJNYb8yAAoJEIpckszW26+ROigH/2HXwm/KqHhSxLb11u8Lz4nZ 1lSfZAEhxnvWAsuDQgi6w0VDDq7+kX8J2fedIOTKippIL4wsIGj8ALVAZv2BF/rv PQzonva9zvrCztfLZ+IEzb5WHk+eqwet9XETuefQg5MKZgo4RMiVmwLWEKo9CHHh 9svgMo8E4+okqJDDarfhLuxmeVeUGA5jY4DklHuswdv2fL8R4KBHk7qGZLURZU/x kAZeOy1Fbuf9uFDNU9LuLQgPiJ0uv3ZmiUG4US0OlptLFi0O8n1LuZSgasghuxe7 XwSutDqLoc5eAWs/OLzdEN39rrclMqpd/7nLHotnJ0QAH0qEhKDL7dE/xdHj1p4= =/efy -----END PGP SIGNATURE-----home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110221012610.GC2220>
