Index: tools/xtui.py
===================================================================
--- tools/xtui.py	(revision 99d8c820b9a2c619890648a6d6abbee2086b659a)
+++ tools/xtui.py	(revision 34e1206ec4dc79f0592077e3ee270fba91d1eb9d)
@@ -35,5 +35,5 @@
 def call_dlg(dlgcmd, *args, **kw):
 	"Wrapper for calling 'dialog' program"
-	
+
 	indesc, outdesc = os.pipe()
 	pid = os.fork()
@@ -41,15 +41,15 @@
 		os.dup2(outdesc, 2)
 		os.close(indesc)
-		
+
 		dlgargs = [dlgcmd]
 		for key, val in kw.items():
 			dlgargs.append('--' + key)
 			dlgargs.append(val)
-		
+
 		dlgargs += args
 		os.execlp(dlgcmd, *dlgargs)
-	
+
 	os.close(outdesc)
-	
+
 	try:
 		errout = os.fdopen(indesc, 'r')
@@ -61,14 +61,14 @@
 		os.system('reset')
 		raise
-	
+
 	if (not os.WIFEXITED(status)):
 		# Reset terminal
 		os.system('reset')
 		raise EOFError
-	
+
 	status = os.WEXITSTATUS(status)
 	if (status == 255):
 		raise EOFError
-	
+
 	return (status, data)
 
@@ -79,5 +79,5 @@
 except ImportError:
 	newt = False
-	
+
 	dlgcmd = os.environ.get('DIALOG', 'dialog')
 	if (call_dlg(dlgcmd, '--print-maxsize')[0] != 0):
@@ -91,35 +91,35 @@
 def width_fix(screen, width):
 	"Correct width to screen size"
-	
+
 	if (width + width_extra > screen.width):
 		width = screen.width - width_extra
-	
+
 	if (width <= 0):
 		width = screen.width
-	
+
 	return width
 
 def height_fix(screen, height):
 	"Correct height to screen size"
-	
+
 	if (height + height_extra > screen.height):
 		height = screen.height - height_extra
-	
+
 	if (height <= 0):
 		height = screen.height
-	
+
 	return height
 
 def screen_init():
 	"Initialize the screen"
-	
+
 	if (newt):
 		return snack.SnackScreen()
-	
+
 	return None
 
 def screen_done(screen):
 	"Cleanup the screen"
-	
+
 	if (newt):
 		screen.finish()
@@ -127,5 +127,5 @@
 def choice_window(screen, title, text, options, position):
 	"Create options menu"
-	
+
 	maxopt = 0
 	for option in options:
@@ -133,41 +133,41 @@
 		if (length > maxopt):
 			maxopt = length
-	
+
 	width = maxopt
 	height = len(options)
-	
+
 	if (newt):
 		width = width_fix(screen, width + width_extra)
 		height = height_fix(screen, height)
-		
+
 		if (height > 3):
 			large = True
 		else:
 			large = False
-		
+
 		buttonbar = snack.ButtonBar(screen, ('Done', 'Cancel'))
 		textbox = snack.TextboxReflowed(width, text)
 		listbox = snack.Listbox(height, scroll = large, returnExit = 1)
-		
+
 		cnt = 0
 		for option in options:
 			listbox.append(option, cnt)
 			cnt += 1
-		
+
 		if (position != None):
 			listbox.setCurrent(position)
-		
+
 		grid = snack.GridForm(screen, title, 1, 3)
 		grid.add(textbox, 0, 0)
 		grid.add(listbox, 0, 1, padding = (0, 1, 0, 1))
 		grid.add(buttonbar, 0, 2, growx = 1)
-		
+
 		retval = grid.runOnce()
-		
+
 		return (buttonbar.buttonPressed(retval), listbox.current())
 	elif (dialog):
 		if (width < 35):
 			width = 35
-		
+
 		args = []
 		cnt = 0
@@ -175,28 +175,28 @@
 			args.append(str(cnt + 1))
 			args.append(option)
-			
+
 			cnt += 1
-		
+
 		kw = {}
 		if (position != None):
 			kw['default-item'] = str(position + 1)
-		
+
 		status, data = call_dlg(dlgcmd, '--title', title, '--extra-button', '--extra-label', 'Done', '--menu', text, str(height + height_extra), str(width + width_extra), str(cnt), *args, **kw)
-		
+
 		if (status == 1):
 			return ('cancel', None)
-		
+
 		try:
 			choice = int(data) - 1
 		except ValueError:
 			return ('cancel', None)
-		
+
 		if (status == 0):
 			return (None, choice)
-		
+
 		return ('done', choice)
-	
+
 	sys.stdout.write("\n *** %s *** \n%s\n\n" % (title, text))
-	
+
 	maxcnt = len(str(len(options)))
 	cnt = 0
@@ -204,8 +204,8 @@
 		sys.stdout.write("%*s. %s\n" % (maxcnt, cnt + 1, option))
 		cnt += 1
-	
+
 	sys.stdout.write("\n%*s. Done\n" % (maxcnt, '0'))
 	sys.stdout.write("%*s. Quit\n\n" % (maxcnt, 'q'))
-	
+
 	while True:
 		if (position != None):
@@ -217,8 +217,8 @@
 				sys.stdout.write("Selection[0]: ")
 		inp = sys.stdin.readline()
-		
+
 		if (not inp):
 			raise EOFError
-		
+
 		if (not inp.strip()):
 			if (position != None):
@@ -229,32 +229,32 @@
 				else:
 					inp = '0'
-		
+
 		if (inp.strip() == 'q'):
 			return ('cancel', None)
-		
+
 		try:
 			choice = int(inp.strip())
 		except ValueError:
 			continue
-		
+
 		if (choice == 0):
 			return ('done', 0)
-		
+
 		if (choice < 1) or (choice > len(options)):
 			continue
-		
+
 		return (None, choice - 1)
 
 def error_dialog(screen, title, msg):
 	"Print error dialog"
-	
+
 	width = len(msg)
-	
+
 	if (newt):
 		width = width_fix(screen, width)
-		
+
 		buttonbar = snack.ButtonBar(screen, ['Ok'])
 		textbox = snack.TextboxReflowed(width, msg)
-		
+
 		grid = snack.GridForm(screen, title, 1, 2)
 		grid.add(textbox, 0, 0, padding = (0, 0, 0, 1))
