Esempio n. 1
0
def drawRoomWindow():

	"""
	Draws the room names of as many connected rooms as will fit in the window
	designated for the roster of room names.
	"""

	# Print the room names to the room window
	
	rooms = sorted(rm.getRoomNames())
	
	for index, room in enumerate(rooms):
		if index >= RCH:
			break
		style = ATTR_PLAIN
		if room == activeRoom.getName():
			style |= curses.A_REVERSE
		roomWindow.addstr(index, 0, stralign.alignL(room, RCW), style)
		
	# Print the blank lines to overwrite any existing (outdated) text
	
	if (RCH - len(rooms)) > 0:
		for index in range(len(rooms), RCH):
			printEmptyLine(roomWindow, index, 0)
			
	roomWindow.refresh()
Esempio n. 2
0
def drawChatWindow():
	
	"""
	Draws as many messages or lines of information as will fit in the window
	designated for the chat.
	
	@type vPad:
		int
	@param vPad:
		The amount of space to leave between the lowest possible line and the
		bottom of the window.  This is the vertical padding.
	
	@type hPad:
		int
	@param hPad:
		The amount of space to leave between the end of a string and the right
		side of the window.  This is the horizontal padding.
	"""
	
	chatBuffer = generalBuffer
	
	if activeRoom:
		chatBuffer = activeRoom.chatBuffer
	for index, message in enumerate(chatBuffer):
		if index >= CCH:
			break
		msg = chatBuffer[index]
		chatWindow.addstr(index, 0, stralign.alignL(msg[0], CCW), msg[1])
	
	if (CCH - len(chatBuffer)) > 0:
		for index in range(len(chatBuffer), CCH):
			printEmptyLine(chatWindow, index, 0)
			
	chatWindow.refresh()
Esempio n. 3
0
def printEmptyLine(window, y, x, style = ATTR_PLAIN):
	
	"""
	Draws an empty line.  This will generally be used to overwrite old
	information on a window.
	
	@type window:
		curses.Window
	@param window:
		The window whose contents are to be overwritten with a blank line.
	
	@type y:
		int
	@param y:
		The row in which to write the blank line.
	
	@type x:
		int
	@param x:
		The column in which to begin the empty line.
	
	@type style:
		curses.Attribute
	@param style:
		The color pair with which to style the line.
		
		This is not useless:  the background color of the color pair will be
		the color of the line.
	"""
	
	window.addstr(y, x, stralign.alignL("", width(window) - 1), style)
Esempio n. 4
0
def drawUserWindow():
	
	"""
	Draws the names of as many online users as will fit in the window
	designated for the chat.
	
	@type vPad:
		int
	@param vPad:
		The amount of space to leave between the lowest possible line and the
		bottom of the window.  This is the vertical padding.
	
	@type hPad:
		int
	@param hPad:
		The amount of space to leave between the end of a string and the right
		side of the window.  This is the horizontal padding.
	"""
	
	users = []
	
	if activeRoom:
		users = sorted([name.lower() for name in activeRoom.getUserNames()])
		for index, user in enumerate(users):
			if index >= UCH:
				break
			style = colorCode(activeRoom, user)
			if user == activeRoom.activeUser:
				style |= curses.A_REVERSE
			
			userWindow.addstr(index, 0, stralign.alignL(user, UCW), style)
	
	if (UCH - len(users)) > 0:
		for index in range(len(users), UCH):
			printEmptyLine(userWindow, index, 0)
			
	userWindow.refresh()