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> References: <20110221011755.GA16912@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--kVXhAStRUZ/+rrGn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Quoth Gary Kline on Sunday, 20 February 2011: > THis is to the entire list, mostly to Chip. It is o8.rb, my=20 > very slightly tweaked version of what you ma/// rather, what i > found and began messing with a couple, three hours ago. >=20 > I searched++ and could not find the C equivalent of > "if counter % N =3D=3D 0" in ruby. For some reason, use of parens > in ruby seems to be discouraged. Anyway, I would have coded that > ruby line as=20 >=20 > if ( counter % 15) =3D=3D 0 >=20 > but didn't want to risk it since i don't know ruby. >=20 > Anyway, o8.rb included. This version, using the "[][][][][]" to > emulate a bar, makes reading a reasonably-sized bunch of text > much easier. >=20 > Thanks again for your help. =20 >=20 > --=20 > Gary Kline kline@thought.org http://www.thought.org Public Service Un= ix >=20 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 =3D 15 optparse =3D OptionParser.new do |opts| opts.banner =3D 'usage: npg [-n pagesize] file...' opts.on('-n', '--numlines pagesize', 'Specify page size in number of line= s') do |n| pagesize =3D n.to_i end end begin optparse.parse! rescue OptionParser::InvalidOption, OptionParser::MissingArgument =3D> e puts e puts optparse exit 1 end banner loop do pagesize.times do if line =3D gets puts line else banner exit end end banner print "More..." system "stty raw" STDIN.getc system "stty -raw" banner end --=20 Sterling (Chip) Camden | sterling@camdensoftware.com | 2048D/3A978E4F http://chipsquips.com | http://camdensoftware.com | http://chipstips.com --kVXhAStRUZ/+rrGn Content-Type: application/pgp-signature Content-Disposition: inline -----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----- --kVXhAStRUZ/+rrGn--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110221012610.GC2220>