buffer: Allow the buffer name to be human readable.
This commit is contained in:
parent
01b5d5c1c5
commit
ef51c95a08
2 changed files with 34 additions and 4 deletions
|
@ -803,15 +803,23 @@ class WeechatChannelBuffer(object):
|
||||||
def short_name(self):
|
def short_name(self):
|
||||||
return W.buffer_get_string(self._ptr, "short_name")
|
return W.buffer_get_string(self._ptr, "short_name")
|
||||||
|
|
||||||
|
@short_name.setter
|
||||||
|
def short_name(self, name):
|
||||||
|
W.buffer_set(self._ptr, "short_name", name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return W.buffer_get_string(self._ptr, "name")
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, name):
|
||||||
|
W.buffer_set(self._ptr, "name", name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def number(self):
|
def number(self):
|
||||||
"""Get the buffer number, starts at 1."""
|
"""Get the buffer number, starts at 1."""
|
||||||
return int(W.buffer_get_integer(self._ptr, "number"))
|
return int(W.buffer_get_integer(self._ptr, "number"))
|
||||||
|
|
||||||
@short_name.setter
|
|
||||||
def short_name(self, name):
|
|
||||||
W.buffer_set(self._ptr, "short_name", name)
|
|
||||||
|
|
||||||
def find_lines(self, predicate, max_lines=None):
|
def find_lines(self, predicate, max_lines=None):
|
||||||
lines = []
|
lines = []
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -846,6 +854,7 @@ class RoomBuffer(object):
|
||||||
|
|
||||||
self.last_read_event = None
|
self.last_read_event = None
|
||||||
self._read_markers_enabled = True
|
self._read_markers_enabled = True
|
||||||
|
self.server_name = server_name
|
||||||
|
|
||||||
buffer_name = "{}.{}".format(server_name, room.room_id)
|
buffer_name = "{}.{}".format(server_name, room.room_id)
|
||||||
|
|
||||||
|
@ -1073,6 +1082,10 @@ class RoomBuffer(object):
|
||||||
room_name = self.room.display_name
|
room_name = self.room.display_name
|
||||||
self.weechat_buffer.short_name = room_name
|
self.weechat_buffer.short_name = room_name
|
||||||
|
|
||||||
|
if G.CONFIG.human_buffer_names:
|
||||||
|
buffer_name = "{}.{}".format(self.server_name, room_name)
|
||||||
|
self.weechat_buffer.name = buffer_name
|
||||||
|
|
||||||
def _redact_line(self, event):
|
def _redact_line(self, event):
|
||||||
def predicate(event_id, line):
|
def predicate(event_id, line):
|
||||||
def already_redacted(tags):
|
def already_redacted(tags):
|
||||||
|
|
|
@ -399,6 +399,7 @@ class MatrixConfig(WeechatConfig):
|
||||||
self.upload_buffer = ""
|
self.upload_buffer = ""
|
||||||
self.debug_category = "all"
|
self.debug_category = "all"
|
||||||
self.page_up_hook = None
|
self.page_up_hook = None
|
||||||
|
self.human_buffer_names = None
|
||||||
|
|
||||||
look_options = [
|
look_options = [
|
||||||
Option(
|
Option(
|
||||||
|
@ -519,6 +520,18 @@ class MatrixConfig(WeechatConfig):
|
||||||
("Number of spaces to add as a margin around around a code "
|
("Number of spaces to add as a margin around around a code "
|
||||||
"block"),
|
"block"),
|
||||||
),
|
),
|
||||||
|
Option(
|
||||||
|
"human_buffer_names",
|
||||||
|
"boolean",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
"off",
|
||||||
|
("If turned on the buffer name will consist of the server "
|
||||||
|
"name and the room name instead of the room_id. Note, this "
|
||||||
|
"requires a change to the logger.file.mask setting since "
|
||||||
|
"conflicts can happen otherwise."),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
network_options = [
|
network_options = [
|
||||||
|
@ -769,6 +782,10 @@ class MatrixConfig(WeechatConfig):
|
||||||
"",
|
"",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def read(self):
|
||||||
|
super().read()
|
||||||
|
self.human_buffer_names = self.look.human_buffer_names
|
||||||
|
|
||||||
def free(self):
|
def free(self):
|
||||||
section_ptr = W.config_search_section(self._ptr, "server")
|
section_ptr = W.config_search_section(self._ptr, "server")
|
||||||
W.config_section_free(section_ptr)
|
W.config_section_free(section_ptr)
|
||||||
|
|
Loading…
Reference in a new issue