fixez
This commit is contained in:
61
ui.py
61
ui.py
@ -96,10 +96,11 @@ class UIManager:
|
|||||||
curses.start_color()
|
curses.start_color()
|
||||||
curses.use_default_colors()
|
curses.use_default_colors()
|
||||||
curses.cbreak()
|
curses.cbreak()
|
||||||
curses.setsyx(-1, -1)
|
curses.curs_set(0)
|
||||||
|
#curses.setsyx(-1, -1)
|
||||||
|
|
||||||
self.screen.addstr(f"Quake Live PyCon: {self.host}")
|
self.screen.addstr(f"Quake Live PyCon: {self.host}")
|
||||||
self.screen.refresh()
|
self.screen.noutrefresh()
|
||||||
|
|
||||||
# Initialize color pairs
|
# Initialize color pairs
|
||||||
for i in range(1, 7):
|
for i in range(1, 7):
|
||||||
@ -123,7 +124,7 @@ class UIManager:
|
|||||||
self.info_window.scrollok(False)
|
self.info_window.scrollok(False)
|
||||||
self.info_window.idlok(False)
|
self.info_window.idlok(False)
|
||||||
self.info_window.leaveok(True)
|
self.info_window.leaveok(True)
|
||||||
self.info_window.refresh()
|
self.info_window.noutrefresh()
|
||||||
|
|
||||||
# Output window (middle - main display)
|
# Output window (middle - main display)
|
||||||
self.output_window = curses.newwin(
|
self.output_window = curses.newwin(
|
||||||
@ -133,9 +134,23 @@ class UIManager:
|
|||||||
2
|
2
|
||||||
)
|
)
|
||||||
self.output_window.scrollok(True)
|
self.output_window.scrollok(True)
|
||||||
self.output_window.idlok(True)
|
self.output_window.idlok(False)
|
||||||
|
self.output_window.idcok(False)
|
||||||
self.output_window.leaveok(True)
|
self.output_window.leaveok(True)
|
||||||
self.output_window.refresh()
|
self.output_window.noutrefresh()
|
||||||
|
|
||||||
|
# Divider line
|
||||||
|
self.divider_window = curses.newwin(
|
||||||
|
1,
|
||||||
|
maxx - 4,
|
||||||
|
maxy - 3,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
self.divider_window.hline(curses.ACS_HLINE, maxx - 4)
|
||||||
|
self.divider_window.scrollok(False)
|
||||||
|
self.divider_window.idlok(False)
|
||||||
|
self.divider_window.leaveok(True)
|
||||||
|
self.divider_window.noutrefresh()
|
||||||
|
|
||||||
# Input window (bottom)
|
# Input window (bottom)
|
||||||
self.input_window = curses.newwin(
|
self.input_window = curses.newwin(
|
||||||
@ -148,20 +163,12 @@ class UIManager:
|
|||||||
self.input_window.nodelay(False)
|
self.input_window.nodelay(False)
|
||||||
self.screen.addstr(maxy - 2, 2, '$ ')
|
self.screen.addstr(maxy - 2, 2, '$ ')
|
||||||
self.input_window.idlok(True)
|
self.input_window.idlok(True)
|
||||||
|
self.input_window.idcok(True)
|
||||||
self.input_window.leaveok(False)
|
self.input_window.leaveok(False)
|
||||||
self.input_window.refresh()
|
self.input_window.noutrefresh()
|
||||||
|
|
||||||
# Divider line
|
self.screen.noutrefresh()
|
||||||
self.divider_window = curses.newwin(
|
curses.doupdate()
|
||||||
1,
|
|
||||||
maxx - 4,
|
|
||||||
maxy - 3,
|
|
||||||
2
|
|
||||||
)
|
|
||||||
self.divider_window.hline(curses.ACS_HLINE, maxx - 4)
|
|
||||||
self.divider_window.refresh()
|
|
||||||
|
|
||||||
self.screen.refresh()
|
|
||||||
|
|
||||||
def setup_input_queue(self):
|
def setup_input_queue(self):
|
||||||
"""Setup threaded input queue with command history"""
|
"""Setup threaded input queue with command history"""
|
||||||
@ -192,7 +199,7 @@ class UIManager:
|
|||||||
cursor_pos = 0
|
cursor_pos = 0
|
||||||
temp_history_index = -1
|
temp_history_index = -1
|
||||||
temp_input = ""
|
temp_input = ""
|
||||||
window.clear()
|
window.erase()
|
||||||
window.noutrefresh()
|
window.noutrefresh()
|
||||||
|
|
||||||
# Arrow UP - previous command
|
# Arrow UP - previous command
|
||||||
@ -207,7 +214,7 @@ class UIManager:
|
|||||||
temp_history_index -= 1
|
temp_history_index -= 1
|
||||||
current_input = manager.command_history[temp_history_index]
|
current_input = manager.command_history[temp_history_index]
|
||||||
cursor_pos = len(current_input)
|
cursor_pos = len(current_input)
|
||||||
window.clear()
|
window.erase()
|
||||||
window.addstr(0, 0, current_input)
|
window.addstr(0, 0, current_input)
|
||||||
window.noutrefresh()
|
window.noutrefresh()
|
||||||
|
|
||||||
@ -224,7 +231,7 @@ class UIManager:
|
|||||||
current_input = manager.command_history[temp_history_index]
|
current_input = manager.command_history[temp_history_index]
|
||||||
|
|
||||||
cursor_pos = len(current_input)
|
cursor_pos = len(current_input)
|
||||||
window.clear()
|
window.erase()
|
||||||
window.addstr(0, 0, current_input)
|
window.addstr(0, 0, current_input)
|
||||||
window.noutrefresh()
|
window.noutrefresh()
|
||||||
|
|
||||||
@ -248,7 +255,7 @@ class UIManager:
|
|||||||
current_input = current_input[:cursor_pos-1] + current_input[cursor_pos:]
|
current_input = current_input[:cursor_pos-1] + current_input[cursor_pos:]
|
||||||
cursor_pos -= 1
|
cursor_pos -= 1
|
||||||
temp_history_index = -1 # Exit history mode
|
temp_history_index = -1 # Exit history mode
|
||||||
window.clear()
|
window.erase()
|
||||||
window.addstr(0, 0, current_input)
|
window.addstr(0, 0, current_input)
|
||||||
window.move(0, cursor_pos)
|
window.move(0, cursor_pos)
|
||||||
window.noutrefresh()
|
window.noutrefresh()
|
||||||
@ -259,17 +266,18 @@ class UIManager:
|
|||||||
current_input = current_input[:cursor_pos] + char + current_input[cursor_pos:]
|
current_input = current_input[:cursor_pos] + char + current_input[cursor_pos:]
|
||||||
cursor_pos += 1
|
cursor_pos += 1
|
||||||
temp_history_index = -1 # Exit history mode
|
temp_history_index = -1 # Exit history mode
|
||||||
window.clear()
|
window.erase()
|
||||||
window.addstr(0, 0, current_input)
|
window.addstr(0, 0, current_input)
|
||||||
window.move(0, cursor_pos)
|
window.move(0, cursor_pos)
|
||||||
window.noutrefresh()
|
window.noutrefresh()
|
||||||
|
|
||||||
curses.doupdate()
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import logging
|
import logging
|
||||||
logging.getLogger('ui').error(f'Input error: {e}')
|
logging.getLogger('ui').error(f'Input error: {e}')
|
||||||
|
|
||||||
|
window.move(0, cursor_pos)
|
||||||
|
curses.doupdate()
|
||||||
|
|
||||||
self.input_queue = queue.Queue()
|
self.input_queue = queue.Queue()
|
||||||
t = threading.Thread(target=wait_stdin, args=(self.input_queue, self.input_window, self))
|
t = threading.Thread(target=wait_stdin, args=(self.input_queue, self.input_window, self))
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
@ -286,15 +294,14 @@ class UIManager:
|
|||||||
|
|
||||||
def print_message(self, message, attributes=0):
|
def print_message(self, message, attributes=0):
|
||||||
"""Print formatted message to output window"""
|
"""Print formatted message to output window"""
|
||||||
y, x = curses.getsyx()
|
|
||||||
print_colored(self.output_window, message, attributes)
|
print_colored(self.output_window, message, attributes)
|
||||||
self.output_window.noutrefresh()
|
self.output_window.noutrefresh()
|
||||||
curses.setsyx(y, x)
|
self.input_window.move(0, 0)
|
||||||
curses.doupdate()
|
curses.doupdate()
|
||||||
|
|
||||||
def update_server_info(self, game_state):
|
def update_server_info(self, game_state):
|
||||||
"""Update server info window"""
|
"""Update server info window"""
|
||||||
self.info_window.clear()
|
self.info_window.erase()
|
||||||
|
|
||||||
max_y, max_x = self.info_window.getmaxyx()
|
max_y, max_x = self.info_window.getmaxyx()
|
||||||
server_info = game_state.server_info
|
server_info = game_state.server_info
|
||||||
|
|||||||
Reference in New Issue
Block a user