mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Hopefully non-breaking change to allow custom line separators on server output buffer
This commit is contained in:
parent
2a6c0ca751
commit
87a59b29c2
@ -88,10 +88,11 @@ def callback(called_func):
|
||||
class ServerOutBuf:
|
||||
lines = {}
|
||||
|
||||
def __init__(self, helper, proc, server_id):
|
||||
def __init__(self, helper, proc, server_id, newline=os.linesep):
|
||||
self.helper = helper
|
||||
self.proc = proc
|
||||
self.server_id = str(server_id)
|
||||
self.newline = newline
|
||||
# Buffers text for virtual_terminal_lines config number of lines
|
||||
self.max_lines = self.helper.get_setting("virtual_terminal_lines")
|
||||
self.line_buffer = ""
|
||||
@ -99,13 +100,13 @@ class ServerOutBuf:
|
||||
self.lsi = 0
|
||||
|
||||
def process_byte(self, char):
|
||||
if char == os.linesep[self.lsi]:
|
||||
if char == self.newline[self.lsi]:
|
||||
self.lsi += 1
|
||||
else:
|
||||
self.lsi = 0
|
||||
self.line_buffer += char
|
||||
|
||||
if self.lsi >= len(os.linesep):
|
||||
if self.lsi >= len(self.newline):
|
||||
self.lsi = 0
|
||||
ServerOutBuf.lines[self.server_id].append(self.line_buffer)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user