From 210a27d4cc7abe4bbfeba51e290866636b6e86c4 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Fri, 19 Oct 2007 17:20:54 -0500 Subject: modify the rl test to clean up when it gets a signal --- test/rl.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/rl.lua b/test/rl.lua index 712f571..1fd35b2 100644 --- a/test/rl.lua +++ b/test/rl.lua @@ -1,4 +1,5 @@ require 'curses' +require 'signal' -- globals {{{ local map, rows, cols @@ -20,6 +21,15 @@ local function botl(str) curses.addstr({y = rows - 1, x = 0}, str) curses.clrtoeol() end + +local function cleanup(sig) + curses.clear() + curses.endwin() + if sig then + signal.signal(sig, "default") + signal.raise(sig) + end +end -- }}} -- curses initialization {{{ @@ -31,6 +41,11 @@ for _, color in ipairs(colors) do end -- }}} +-- cleanup on signals {{{ +signal.signal("TERM", cleanup) +signal.signal("INT", cleanup) +-- }}} + -- get the term size and the size of the map we want to draw {{{ rows, cols = curses.getmaxyx() map = {ul = {x = 0, y = 1}, lr = {x = cols - 1, y = rows - 3}} @@ -107,6 +122,5 @@ end -- }}} -- cleanup {{{ -curses.clear() -curses.endwin() +cleanup() -- }}} -- cgit v1.2.3-54-g00ecf