diff options
Diffstat (limited to 'content/posts/2005-03-04-profanity.html')
-rw-r--r-- | content/posts/2005-03-04-profanity.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/content/posts/2005-03-04-profanity.html b/content/posts/2005-03-04-profanity.html new file mode 100644 index 0000000..98c1074 --- /dev/null +++ b/content/posts/2005-03-04-profanity.html @@ -0,0 +1,74 @@ +--- +date: "2005-03-04T01:38:28Z" +title: Profanity! +--- + +<p> +The last week or so I've been working on <a href='http://cvs.pablotron.org/?m=profanity'>Profanity</a>, a <a href='http://ruby-lang.org/'>Ruby</a> windowing library for Curses. It's features include relative window geometry, a include an <acronym title='HyperText Markup Language'>HTML</acronym>-like markup for styled text, and proper terminal resizes support. I've whipped up a couple of example movies to demonstrate the geometry engine and styled text: +</p> + +<ul> +<li><a href='/download/profanity-20050228.mpg'><code>profanity-2050228.mpg</code></a>: An example of the geometry engine handling terminal resizes.</li> +<li><a href='/download/profanity-20050228.mpg'><code>profanity-2050228.mpg</code></a>: An example of window constraints, window gravity, and styled text (notice how styles can be applied to window titles as well as contents).</li> +</ul> + +<p> +By the way, if you're having trouble with these movies, try them in <a href='http://www.mplayerhq.hu/'>MPlayer</a> (I'm usually an <a href='http://xine.sf.net/'>Xine</a> guy myself, but it seems to mangle these too). In the interest of staving of the torch- and pitchfork-wielding mob of people who can't get either movie to play, here are a few still shots from each (click the thumbnails for the full image): +</p> + +<p> +<a href='/software/profanity/demos/20050228-shots/00.png'><img src='/software/profanity/demos/20050228-shots/thumb/00.png' width='160' height='164' title='profanity 20050228-00' alt='profanity 20050228-00' border='0' /></a> +<a href='/software/profanity/demos/20050228-shots/01.png'><img src='/software/profanity/demos/20050228-shots/thumb/01.png' width='160' height='164' title='profanity 20050228-01' alt='profanity 20050228-01' border='0' /></a> +<a href='/software/profanity/demos/20050228-shots/02.png'><img src='/software/profanity/demos/20050228-shots/thumb/02.png' width='160' height='164' title='profanity 20050228-02' alt='profanity 20050228-02' border='0' /></a> +<a href='/software/profanity/demos/20050228-shots/03.png'><img src='/software/profanity/demos/20050228-shots/thumb/03.png' width='160' height='164' title='profanity 20050228-03' alt='profanity 20050228-03' border='0' /></a> + +<a href='/software/profanity/demos/20050301-shots/00.png'><img src='/software/profanity/demos/20050301-shots/thumb/00.png' width='160' height='164' title='profanity 20050301-00' alt='profanity 20050301-00' border='0' /></a> +<a href='/software/profanity/demos/20050301-shots/01.png'><img src='/software/profanity/demos/20050301-shots/thumb/01.png' width='160' height='164' title='profanity 20050301-01' alt='profanity 20050301-01' border='0' /></a> +<a href='/software/profanity/demos/20050301-shots/02.png'><img src='/software/profanity/demos/20050301-shots/thumb/02.png' width='160' height='164' title='profanity 20050301-02' alt='profanity 20050301-02' border='0' /></a> +</p> + +<p> +Finally, here is a <a href='http://cvs.pablotron.org/cgi-bin/viewcvs.cgi/profanity/doc/examples/hello.rb?rev=1.1&view=auto'>simple example from <acronym title='Concurrent Versioning System'>CVS</acronym>)</a> which demonstrates what Profanity code looks like: +</p> + +<div style='font-size: 75%; background-color: #eee; padding: 10px; +margin: 10px 30px 10px 30px; border: 1px solid black;'> +<pre> +<code> +require 'profanity' + +# create a basic window class +class HelloWorldWindow < Profanity::Window + # contents of this window + LINES = [ + "<center>Welcome to <u>Profanity</u>!</center>", + '<center>Press <b>Q</b> or <b>ESC</b> to quit.</center>', + ] + + # override Window#draw_contents for our own devious purposes + def draw_contents + clear + puts LINES + end +end + +# create the profanity window manager +wm = Profanity::WindowManager.new + +# create geometry, and fix height to 4 lines +geom = Profanity::Geometry.new(0.5, 0.5, 0.7, 0.0) +geom.height_absolute = 4 + +# set gravity to center of the screen +geom.gravity.x = geom.gravity.y = 0.5 + +# create our window, show and refresh it +win = HelloWorldWindow.new(wm, geom, 'Hello World') +win.show; win.refresh + +# run until the user presses q, ctrl-c, or escape +wm.run { |key| break if [?q, 27, Curses::KEY_CTRL_C].include?(key) } +</code> +</pre> +</div> + |