mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
Add partition function
Added the partition function to 'PluginWindow' class. This function inserts new line breaks, for a specific character offset count.
This commit is contained in:
parent
d04635c284
commit
7a8e9d3155
1 changed files with 17 additions and 0 deletions
|
|
@ -787,6 +787,23 @@ class PluginWindow(popup.PopupWindow):
|
||||||
self.scale_origin = origin_widget.get_screen_space_center()
|
self.scale_origin = origin_widget.get_screen_space_center()
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.create_task(self.draw_ui())
|
loop.create_task(self.draw_ui())
|
||||||
|
|
||||||
|
def partition(string, minimum_character_offset=40):
|
||||||
|
string_length = len(string)
|
||||||
|
|
||||||
|
partitioned_string = ""
|
||||||
|
partitioned_string_length = len(partitioned_string)
|
||||||
|
|
||||||
|
while partitioned_string_length != string_length:
|
||||||
|
next_empty_space = string[partitioned_string_length + minimum_character_offset:].find(" ")
|
||||||
|
next_word_end_position = partitioned_string_length + minimum_character_offset + max(0, next_empty_space)
|
||||||
|
partitioned_string += string[partitioned_string_length:next_word_end_position]
|
||||||
|
if next_empty_space != -1:
|
||||||
|
# Insert a line break here, there's still more partitioning to do.
|
||||||
|
partitioned_string += "\n"
|
||||||
|
partitioned_string_length = len(partitioned_string)
|
||||||
|
|
||||||
|
return partitioned_string
|
||||||
|
|
||||||
async def draw_ui(self):
|
async def draw_ui(self):
|
||||||
# print(ba.app.plugins.active_plugins)
|
# print(ba.app.plugins.active_plugins)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue