Add no double space option

This commit is contained in:
ebolam
2022-10-26 20:53:47 -04:00
parent 09683052f1
commit 147b9be9e5
2 changed files with 23 additions and 0 deletions

View File

@@ -481,6 +481,22 @@ gensettingstf = [
"name": "singleline"
},
{
"UI_V2_Only": True,
"uitype": "toggle",
"unit": "bool",
"label": "No Double Spaces",
"id": "remove_double_space",
"min": 0,
"max": 1,
"step": 1,
"default": 0,
"tooltip": "Remove any double spaces in the game text.",
"menu_path": "Interface",
"sub_path": "Formatting",
"classname": "user",
"name": "remove_double_space"
},
{
"UI_V2_Only": True,
"uitype": "slider",
"unit": "int",

View File

@@ -956,6 +956,7 @@ class user_settings(settings):
self.frmtrmspch = False
self.frmtadsnsp = False
self.singleline = False
self.remove_double_space = True
self.importnum = -1 # Selection on import popup list
self.importjs = {} # Temporary storage for import data
self.loadselect = "" # Temporary storage for story filename to load
@@ -1221,6 +1222,9 @@ class KoboldStoryRegister(object):
return self.actions[i]["Selected Text"]
def __setitem__(self, i, text):
if self.koboldai_vars.remove_double_space:
while " " in text:
text = text.replace(" ", " ")
if i in self.actions:
old = self.actions[i]
old_text = self.actions[i]["Selected Text"]
@@ -1289,6 +1293,9 @@ class KoboldStoryRegister(object):
self.set_game_saved()
def append(self, text, action_id_offset=0, recalc=True):
if self.koboldai_vars.remove_double_space:
while " " in text:
text = text.replace(" ", " ")
self.clear_unused_options()
self.action_count+=1
action_id = self.action_count + action_id_offset