[Solved] ClearScreen White Space Issue (was UNDO Issue)

This is really a continuation of the now closed topic from October:
http://textadventures.co.uk/forum/quest/topic/gxxws68qyko6hqwkf9q2ua/unexpected-undo-problem-resolved-again

I assume that any operation that uses ClearScreen can't be fully undone if any text has been cleared but is it possible to detect that this has happened within UNDO and give a warning?

Update
...now also noticed that there is a 'white space' problem when undoing past an operation that uses ClearScreen, as the space for the text is restored but not the text itself!


Hello.


I assume that any operation that uses ClearScreen can't be fully undone if any text has been cleared

That depends on how you define "fully undone".

There are a few people around here who will probably say making cleared text reappear is not UNDO's job. ( I'm not particularly saying that, but I don't have much of an argument against it, either.)

Regardless of that, I think there's probably a way to undo screen clearing. (I'm thinking about the way the transcript stuff works, but I can't think about it clearly enough to effect a solution right now. (I've been fooling around with the next Quest, and I just realized I've forgotten quite a bit of old Quest-ese.))

I don't want to sound negative, but I wouldn't bet that such functionality would ever be added to Quest 5 (although I may be mistaken). If you find a solution to this, you would probably have to include the code in each of your games.


is it possible to detect that this has happened within UNDO and give a warning?

I don't fully understand this question.

Do you mean that the screen clears after entering UNDO? If yes, this probably depends on the script that invokes ClearScreen, but I think you could code that script to check the current command before clearing the screen.


now also noticed that there is a 'white space' problem when undoing past an operation that uses ClearScreen, as the space for the text is restored but not the text itself!

It seems like I remember someone mentioning this previously? ( I might be am crazy, though.)


Opinion(s)

I am quite fond of UNDO (and making it fully functional), but, now that I've thought about it, I wouldn't call this thing with ClearScreen an UNDO issue. I would opine that this is something which should be handled by any author who chooses to clear the screen with ClearScreen during play -- an offense of which I have been guilty on numerous occasions.

Instead of using ClearScreen in a parser (especially a parser that has the UNDO feature), perhaps it would be better to print out a blank div which is the height of the output element. This is how the old text adventures did it (I think). It has the same effect, but the player can always scroll up to view everything printed during play.

I'm pretty sure this would look odd in Quest, though.

EDIT

I'm pretty sure this will do that ("that" meaning: create a screen full of whitespace):

msg ("<div style='min-height:100vh;'></div>")
msg ("Your screen just got cleared the old way!")

EDIT 2

Tested and approved (although it does act a little funny).


I played around with this for a few minutes.

I don't think UNDO should have anything to do with what text has printed or what text has been cleared. Otherwise, logic would dictate that UNDO should clear the text printed out in response to each action being undone and restore any text cleared due each action, and that would be illogical.


Hi K.V., Happy New Year!
Sorry, my posting was lazy! I should have provided code. I've now done that in the game where I noticed the problem:
https://textadventures.co.uk/games/view/e4hrqb_vpeo4np1a0jel9g/l-too-another-mathemagical-adventure

To see the issue:

  1. run the game online and type ABOUT to bring up a couple of pages of text
  2. type CLEAR, which just uses ClearScreen to remove the text
  3. type UNDO, which seems to insert the white space occupied by the text as a side effect of undoing CLEAR?

UPDATE
The problem seems to be in the code I use to restore the state of the game after UNDO, rather than UNDO itself, linked to code you gave me to deal with white space appearing when game panes are swapped out:
https://textadventures.co.uk/forum/quest/topic/w7mtakf7ykixomwl09kjfw/pain-with-panes-issue-3-expanding-whitespace

I'll experiment further!

UPDATE 2
You gave me the following code in 2018 to tidy up white space when taking out game panes:

JS.eval ("var reHeight = 0;  $('#divOutput').children().each(function(){reHeight += $(this).height();});  $('#divOutput').css('min-height',reHeight);")

Unfortunately that seems to fail after the use of ClearScreen. For example, in the posted game:

  1. Type PANES twice to move panes in and out, showing all is fine
  2. Type CLEAR
  3. Type PANES twice again

On the second use, when removing the panes, white space appears. My easy workaround is to remove the use of ClearScreen but I'd love to know what was causing the problem?


Man, I really wish I remembered doing all this. I have no clue where I came up with that code in UPDATE 2.

Anyway, it has something to do the min-height of the "divOutput" element.

Running this in the console after the undo makes the whitespace go away:

document.getElementById('divOutput').style.minHeight = null


So, try adding this line at the end of your undo script:

     JS.eval("document.getElementById('divOutput').style.minHeight = null")

Many thanks K.V. I've used your new code in place of the old, tying it specifically to tidying up after panes are removed, and everything now looks perfect. I've uploaded a new version of the game and it seems to be coping with every sequence I throw at it. I'll try playing through to just before the end and then undoing back to the beginning. It'll take a while!


Hurray!

After reading through mrangel's posts in that old thread, that seemed like the fix.

So, mrangel technically solved this one.


Thanks K.V. I'd call it a joint effort but I still plan to buy another book from mrangel when I've finished the three I've downloaded already. I'm not currently working on any games so hopefully I won't be bothering the forum for a while.


I have no idea why Quest keeps setting the document's min-height to the height of its contents. That should have no effect at all, except introducing pointless white space.

You might as well do something like $('head style').last().append('#divOutput {min-height: initial !important}') in your init script, and not have to keep fiddling with edge cases.


@mrangel, many thanks for the simplified code. I've tried it out on the cases that were failing and all seems perfect. I'll use a longer test tomorrow.


Apologies mrangel, in my rush to test your code yesterday I must have left in K.V.s code as well because tests this morning show white space returning. K.V.'s solution is reasonably specific anyway as it is only used when panes are removed and I have given it a thorough check (I think!)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums