def matrix_config_init(config_file): look_options = [ Option("redactions", "integer", "strikethrough|notice|delete", 0, 0, "strikethrough", ("Only notice redactions, strike through or delete " "redacted messages")), Option("server_buffer", "integer", "merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core", "Merge server buffers") ] network_options = [ Option("max_initial_sync_events", "integer", "", 1, 10000, "30", ("How many events to fetch during the initial sync")), Option("max_backlog_sync_events", "integer", "", 1, 100, "10", ("How many events to fetch during backlog fetching")), Option("fetch_backlog_on_pgup", "boolean", "", 0, 0, "on", ("Fetch messages in the backlog on a window page up event")) ] def add_global_options(section, options): for option in options: OPTIONS.options[option.name] = W.config_new_option( config_file, section, option.name, option.type, option.description, option.string_values, option.min, option.max, option.value, option.value, 0, "", "", "matrix_config_change_cb", "", "", "") section = W.config_new_section(config_file, "color", 0, 0, "", "", "", "", "", "", "", "", "", "") # TODO color options section = W.config_new_section(config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "") add_global_options(section, look_options) section = W.config_new_section(config_file, "network", 0, 0, "", "", "", "", "", "", "", "", "", "") add_global_options(section, network_options) W.config_new_section( config_file, "server", 0, 0, "matrix_config_server_read_cb", "", "matrix_config_server_write_cb", "", "", "", "", "", "", "") return config_file
def constructor(self, name, config_ptr, options): self._ptr = W.config_new_section(config_ptr, name, 0, 0, "", "", "", "", "", "", "", "", "", "") self._config_ptr = config_ptr self._option_ptrs = {} for option in options: self._add_option(option)
def __init__(self): self.debug_buffer = "" self.upload_buffer = "" self.debug_category = "all" self.page_up_hook = None self.human_buffer_names = None look_options = [ Option( "redactions", "integer", "strikethrough|notice|delete", 0, 0, "strikethrough", ( "Only notice redactions, strike through or delete " "redacted messages" ), RedactType, ), Option( "server_buffer", "integer", "merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core", "Merge server buffers", ServerBufferType, config_server_buffer_cb, ), Option( "new_channel_position", "integer", "none|next|near_server", min(NewChannelPosition), max(NewChannelPosition), "none", "force position of new channel in list of buffers " "(none = default position (should be last buffer), " "next = current buffer + 1, near_server = after last " "channel/pv of server)", NewChannelPosition, ), Option( "max_typing_notice_item_length", "integer", "", 10, 1000, "50", ("Limit the length of the typing notice bar item."), ), Option( "bar_item_typing_notice_prefix", "string", "", 0, 0, "Typing: ", ("Prefix for the typing notice bar item."), ), Option( "encryption_warning_sign", "string", "", 0, 0, "⚠️ ", ("A sign that is used to signal trust issues in encrypted " "rooms (note: content is evaluated, see /help eval)"), eval_cast, ), Option( "busy_sign", "string", "", 0, 0, "⏳", ("A sign that is used to signal that the client is busy e.g. " "when the room backlog is fetching" " (note: content is evaluated, see /help eval)"), eval_cast, ), Option( "encrypted_room_sign", "string", "", 0, 0, "🔐", ("A sign that is used to show that the current room is " "encrypted " "(note: content is evaluated, see /help eval)"), eval_cast, ), Option( "disconnect_sign", "string", "", 0, 0, "❌", ("A sign that is used to show that the server is disconnected " "(note: content is evaluated, see /help eval)"), eval_cast, ), Option( "pygments_style", "string", "", 0, 0, "native", "Pygments style to use for highlighting source code blocks", ), Option( "code_blocks", "boolean", "", 0, 0, "on", ("Display preformatted code blocks as rectangular areas by " "padding them with whitespace up to the length of the longest" " line (with optional margin)"), ), Option( "code_block_margin", "integer", "", 0, 100, "2", ("Number of spaces to add as a margin around around a code " "block"), ), Option( "quote_wrap", "integer", "", -1, 1000, "67", ("After how many characters to soft-wrap lines in a quote " "block (reply message). Set to -1 to disable soft-wrapping."), ), 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 Matrix room ID. Note, " "this requires a change to the logger.file.mask setting " "since conflicts can happen otherwise " "(requires a script reload)."), ), Option( "markdown_input", "boolean", "", 0, 0, "on", ("If turned on, markdown usage in messages will be converted " "to actual markup (**bold**, *italic*, _italic_, `code`)."), ), ] network_options = [ Option( "max_initial_sync_events", "integer", "", 1, 10000, "30", ("How many events to fetch during the initial sync"), ), Option( "max_backlog_sync_events", "integer", "", 1, 100, "10", ("How many events to fetch during backlog fetching"), ), Option( "fetch_backlog_on_pgup", "boolean", "", 0, 0, "on", ("Fetch messages in the backlog on a window page up event"), None, config_pgup_cb, ), Option( "debug_level", "integer", "error|warn|info|debug", 0, 0, "error", "Enable network protocol debugging.", level_to_logbook, config_log_level_cb, ), Option( "debug_category", "integer", "all|http|client|events|responses|encryption", 0, 0, "all", "Debugging category", logbook_category, config_log_category_cb, ), Option( "debug_buffer", "boolean", "", 0, 0, "off", ("Use a separate buffer for debug logs."), ), Option( "lazy_load_room_users", "boolean", "", 0, 0, "off", ("If on, room users won't be loaded in the background " "proactively, they will be loaded when the user switches to " "the room buffer. This only affects non-encrypted rooms."), ), Option( "max_nicklist_users", "integer", "", 100, 20000, "5000", ("Limit the number of users that are added to the nicklist. " "Active users and users with a higher power level are always." " Inactive users will be removed from the nicklist after a " "day of inactivity."), ), Option( "lag_reconnect", "integer", "", 5, 604800, "90", ("Reconnect to the server if the lag is greater than this " "value (in seconds)"), ), Option( "autoreconnect_delay_growing", "integer", "", 1, 100, "2", ("growing factor for autoreconnect delay to server " "(1 = always same delay, 2 = delay*2 for each retry, etc.)"), ), Option( "autoreconnect_delay_max", "integer", "", 0, 604800, "600", ("maximum autoreconnect delay to server " "(in seconds, 0 = no maximum)"), ), Option( "print_unconfirmed_messages", "boolean", "", 0, 0, "on", ("If off, messages are only printed after the server confirms " "their receival. If on, messages are immediately printed but " "colored differently until receival is confirmed."), ), Option( "lag_min_show", "integer", "", 1, 604800, "500", ("minimum lag to show (in milliseconds)"), ), Option( "typing_notice_conditions", "string", "", 0, 0, "${typing_enabled}", ("conditions to send typing notifications (note: content is " "evaluated, see /help eval); besides the buffer and window " "variables the typing_enabled variable is also expanded; " "the typing_enabled variable can be manipulated with the " "/room command, see /help room"), ), Option( "read_markers_conditions", "string", "", 0, 0, "${markers_enabled}", ("conditions to send read markers (note: content is " "evaluated, see /help eval); besides the buffer and window " "variables the markers_enabled variable is also expanded; " "the markers_enabled variable can be manipulated with the " "/room command, see /help room"), ), Option( "resending_ignores_devices", "boolean", "", 0, 0, "on", ("If on resending the same message to a room that contains " "unverified devices will mark the devices as ignored and " "continue sending the message. If off resending the message " "will again fail and devices need to be marked as verified " "one by one or the /send-anyways command needs to be used to " "ignore them."), ), ] color_options = [ Option( "quote_fg", "color", "", 0, 0, "lightgreen", "Foreground color for matrix style blockquotes", ), Option( "quote_bg", "color", "", 0, 0, "default", "Background counterpart of quote_fg", ), Option( "error_message_fg", "color", "", 0, 0, "darkgray", ("Foreground color for error messages that appear inside a " "room buffer (e.g. when a message errors out when sending or " "when a message is redacted)"), ), Option( "error_message_bg", "color", "", 0, 0, "default", "Background counterpart of error_message_fg.", ), Option( "unconfirmed_message_fg", "color", "", 0, 0, "darkgray", ("Foreground color for messages that are printed out but the " "server hasn't confirmed the that he received them."), ), Option( "unconfirmed_message_bg", "color", "", 0, 0, "default", "Background counterpart of unconfirmed_message_fg." ), Option( "untagged_code_fg", "color", "", 0, 0, "blue", ("Foreground color for code without a language specifier. " "Also used for `inline code`."), ), Option( "untagged_code_bg", "color", "", 0, 0, "default", "Background counterpart of untagged_code_fg", ), Option( "nick_prefixes", "string", "", 0, 0, "admin=lightgreen;mod=lightgreen;power=yellow", ('Colors for nick prefixes indicating power level. ' 'Format is "admin:color1;mod:color2;power:color3", ' 'where "admin" stands for admins (power level = 100), ' '"mod" stands for moderators (power level >= 50) and ' '"power" for any other power user (power level > 0). ' 'Requires restart to apply changes.'), parse_nick_prefix_colors, ), ] sections = [ ("network", network_options), ("look", look_options), ("color", color_options), ] super().__init__(sections) # The server section is essentially a section with subsections and no # options, handle that case independently. W.config_new_section( self._ptr, "server", 0, 0, "matrix_config_server_read_cb", "", "matrix_config_server_write_cb", "", "", "", "", "", "", "", )
def __init__(self): self.debug_buffer = "" self.upload_buffer = "" self.debug_category = "all" self.page_up_hook = None look_options = [ Option( "redactions", "integer", "strikethrough|notice|delete", 0, 0, "strikethrough", ("Only notice redactions, strike through or delete " "redacted messages"), RedactType, ), Option( "server_buffer", "integer", "merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core", "Merge server buffers", ServerBufferType, config_server_buffer_cb, ), Option( "max_typing_notice_item_length", "integer", "", 10, 1000, "50", ("Limit the length of the typing notice bar item."), ), Option( "bar_item_typing_notice_prefix", "string", "", 0, 0, "Typing: ", ("Prefix for the typing notice bar item."), ), Option( "encryption_warning_sign", "string", "", 0, 0, "⚠️ ", ("A sign that is used to signal trust issues in encrypted " "rooms (note: content is evaluated, see /help eval)"), eval_cast, ), Option( "busy_sign", "string", "", 0, 0, "⏳", ("A sign that is used to signal that the client is busy e.g. " "when the room backlog is fetching" " (note: content is evaluated, see /help eval)"), eval_cast, ), Option( "encrypted_room_sign", "string", "", 0, 0, "🔐", ("A sign that is used to show that the current room is " "encrypted " "(note: content is evaluated, see /help eval)"), eval_cast, ), Option( "disconnect_sign", "string", "", 0, 0, "❌", ("A sign that is used to show that the server is disconnected " "(note: content is evaluated, see /help eval)"), eval_cast, ), Option( "pygments_style", "string", "", 0, 0, "native", "Pygments style to use for highlighting source code blocks", ), Option( "code_blocks", "boolean", "", 0, 0, "on", ("Display preformatted code blocks as rectangular areas by " "padding them with whitespace up to the length of the longest" " line (with optional margin)"), ), Option( "code_block_margin", "integer", "", 0, 100, "2", ("Number of spaces to add as a margin around around a code " "block"), ), ] network_options = [ Option( "max_initial_sync_events", "integer", "", 1, 10000, "30", ("How many events to fetch during the initial sync"), ), Option( "max_backlog_sync_events", "integer", "", 1, 100, "10", ("How many events to fetch during backlog fetching"), ), Option( "fetch_backlog_on_pgup", "boolean", "", 0, 0, "on", ("Fetch messages in the backlog on a window page up event"), None, config_pgup_cb, ), Option( "debug_level", "integer", "error|warn|info|debug", 0, 0, "error", "Enable network protocol debugging.", level_to_logbook, config_log_level_cb, ), Option( "debug_category", "integer", "all|http|client|events|responses|encryption", 0, 0, "all", "Debugging category", logbook_category, config_log_category_cb, ), Option( "debug_buffer", "boolean", "", 0, 0, "off", ("Use a separate buffer for debug logs."), ), Option( "lazy_load_room_users", "boolean", "", 0, 0, "off", ("If on, room users won't be loaded in the background " "proactively, they will be loaded when the user switches to " "the room buffer. This only affects non-encrypted rooms."), ), Option( "max_nicklist_users", "integer", "", 100, 20000, "5000", ("Limit the number of users that are added to the nicklist. " "Active users and users with a higher power level are always." " Inactive users will be removed from the nicklist after a " "day of inactivity."), ), Option( "lag_reconnect", "integer", "", 5, 604800, "90", ("Reconnect to the server if the lag is greater than this " "value (in seconds)"), ), Option( "print_unconfirmed_messages", "boolean", "", 0, 0, "on", ("If off, messages are only printed after the server confirms " "their receival. If on, messages are immediately printed but " "colored differently until receival is confirmed."), ), Option( "lag_min_show", "integer", "", 1, 604800, "500", ("minimum lag to show (in milliseconds)"), ), Option( "typing_notice_conditions", "string", "", 0, 0, "${typing_enabled}", ("conditions to send typing notifications (note: content is " "evaluated, see /help eval); besides the buffer and window " "variables the typing_enabled variable is also expanded; " "the typing_enabled variable can be manipulated with the " "/room command, see /help room"), ), Option( "read_markers_conditions", "string", "", 0, 0, "${markers_enabled}", ("conditions to send read markers (note: content is " "evaluated, see /help eval); besides the buffer and window " "variables the markers_enabled variable is also expanded; " "the markers_enabled variable can be manipulated with the " "/room command, see /help room"), ), ] color_options = [ Option( "quote_fg", "color", "", 0, 0, "lightgreen", "Foreground color for matrix style blockquotes", ), Option( "quote_bg", "color", "", 0, 0, "default", "Background counterpart of quote_fg", ), Option( "error_message_fg", "color", "", 0, 0, "darkgray", ("Foreground color for error messages that appear inside a " "room buffer (e.g. when a message errors out when sending or " "when a message is redacted)"), ), Option( "error_message_bg", "color", "", 0, 0, "default", "Background counterpart of error_message_fg.", ), Option( "unconfirmed_message_fg", "color", "", 0, 0, "darkgray", ("Foreground color for messages that are printed out but the " "server hasn't confirmed the that he received them."), ), Option("unconfirmed_message_bg", "color", "", 0, 0, "default", "Background counterpart of unconfirmed_message_fg."), Option( "untagged_code_fg", "color", "", 0, 0, "blue", ("Foreground color for code without a language specifier. " "Also used for `inline code`."), ), Option( "untagged_code_bg", "color", "", 0, 0, "default", "Background counterpart of untagged_code_fg", ), ] sections = [ ("network", network_options), ("look", look_options), ("color", color_options), ] super().__init__(sections) # The server section is essentially a section with subsections and no # options, handle that case independently. W.config_new_section( self._ptr, "server", 0, 0, "matrix_config_server_read_cb", "", "matrix_config_server_write_cb", "", "", "", "", "", "", "", )