Merge pull request #163 from VE-FORBRYDERNE/whitespace-cleanup

More story whitespace cleanup
This commit is contained in:
henk717 2022-06-26 19:50:28 +02:00 committed by GitHub
commit 8cea194809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 2 deletions

View File

@ -3495,6 +3495,7 @@ def actionsubmit(data, actionmode=0, force_submit=False, force_prompt_gen=False,
if(not vars.gamestarted):
vars.submission = data
execute_inmod()
vars.submission = re.sub(r"[^\S\r\n]*([\r\n]*)$", r"\1", vars.submission) # Remove trailing whitespace, excluding newlines
data = vars.submission
if(not force_submit and len(data.strip()) == 0):
assert False
@ -3553,6 +3554,7 @@ def actionsubmit(data, actionmode=0, force_submit=False, force_prompt_gen=False,
data = applyinputformatting(data)
vars.submission = data
execute_inmod()
vars.submission = re.sub(r"[^\S\r\n]*([\r\n]*)$", r"\1", vars.submission) # Remove trailing whitespace, excluding newlines
data = vars.submission
# Dont append submission if it's a blank/continue action
if(data != ""):

View File

@ -891,6 +891,7 @@ function dosubmit(disallow_abort) {
if((disallow_abort || gamestate !== "wait") && !memorymode && !gamestarted && ((!adventure || !action_mode) && txt.trim().length == 0)) {
return;
}
chunkOnFocusOut("override");
input_text.val("");
hideMessage();
hidegenseqs();
@ -1969,7 +1970,7 @@ function chunkOnKeyDownSelectionChange(event) {
// This gets run when you defocus the editor by clicking
// outside of the editor or by pressing escape or tab
function chunkOnFocusOut(event) {
if(!gametext_bound || !allowedit || event.target !== game_text[0]) {
if(event !== "override" && (!gametext_bound || !allowedit || event.target !== game_text[0])) {
return;
}
setTimeout(function() {

View File

@ -17,7 +17,7 @@
<script src="static/bootstrap.min.js"></script>
<script src="static/bootstrap-toggle.min.js"></script>
<script src="static/rangy-core.min.js"></script>
<script src="static/application.js?ver=1.18.1d"></script>
<script src="static/application.js?ver=1.18.1e"></script>
<script src="static/favicon.js"></script>
{% if flaskwebgui %}
<script src="static/flask_web_gui.js"></script>

View File

@ -104,6 +104,9 @@ def removespecialchars(txt, vars=None):
# If the next action follows a sentence closure, add a space
#==================================================================#
def addsentencespacing(txt, vars):
# Don't add sentence spacing if submission is empty or starts with whitespace
if(len(txt) == 0 or len(txt) != len(txt.lstrip())):
return txt
# Get last character of last action
if(len(vars.actions) > 0):
if(len(vars.actions[vars.actions.get_last_key()]) > 0):