Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal weirdness - uparrow at bottom line - doesn't redraw command. #1289

Closed
Dunbaratu opened this issue Dec 1, 2015 · 6 comments
Closed
Assignees
Labels
bug Weird outcome is probably not what the mod programmer expected.

Comments

@Dunbaratu
Copy link
Member

To reproduce:

  • Run some commands interactively until the cursor scrolls far enough down that it has caused the terminal to scroll some, and the cursor is on the bottom row.
  • Use up-arrow to retrieve the previous command.

The command is invisible but it is in the buffer. If you hit enter it will run again. You can edit it, but you have to edit it blindly - i.e. backspace some and then retype stuff.

The moment you make an edit that will insert a new character into the line, THEN it redraws the line. Before that it does not. Deleting a char doesn't redraw it - only adding a new nonblank character does.

@Dunbaratu Dunbaratu self-assigned this Dec 1, 2015
@Dunbaratu
Copy link
Member Author

I am suspecting the problem is in the "dirty check" that's used to decide whether or not there's a need to draw those characters. Note the problem happens the same on the in-game window and in telnet.

@Dunbaratu Dunbaratu added the bug Weird outcome is probably not what the mod programmer expected. label Dec 1, 2015
@Dunbaratu
Copy link
Member Author

Interesting - it's dumping an exception silently to the output log when this happens. The exception isn't causing it to barf - it's just silently continuing on.

ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
  at System.Collections.Generic.List`1[kOS.Safe.Screen.IScreenBufferLine].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Screen.ScreenBuffer.MarkRowsDirty (Int32 startRow, Int32 numRows) [0x00000] in <filename unknown>:0 
  at kOS.Screen.Interpreter.ShowCommandHistoryEntry (Int32 deltaIndex) [0x00000] in <filename unknown>:0 
  at kOS.Screen.Interpreter.SpecialKey (Char key) [0x00000] in <filename unknown>:0 
  at kOS.AddOns.RemoteTech.RemoteTechInterpreter.SpecialKey (Char key) [0x00000] in <filename unknown>:0 
  at kOS.Screen.TermWindow.SpecialKey (Char key) [0x00000] in <filename unknown>:0 
  at kOS.Screen.TermWindow.ProcessOneInputChar (Char ch, kOS.UserIO.TelnetSingletonServer whichTelnet) [0x00000] in <filename unknown>:0 
  at kOS.Screen.TermWindow.ProcessKeyEvents () [0x00000] in <filename unknown>:0 
  at kOS.Screen.TermWindow.OnGUI () [0x00000] in <filename unknown>:0 

@hvacengi
Copy link
Member

hvacengi commented Dec 1, 2015

I seem to remember a similar error in a recent issue (again related to the line buffer for the terminal) but I can't seem to find it. I want to say that you @Dunbaratu fixed it, maybe you recall?

@Dunbaratu
Copy link
Member Author

I think there was an earlier problem with it throwing an exception in some edge cases of the screen redraw, but it was fixed - this must be being caused by a different set of circumstances.

@Dunbaratu
Copy link
Member Author

Note to self to try when I come back to this:

I think the exception is caused by the fact that in Interpreter.cs, in the following lines:

line 112]                    MarkRowsDirty(LineSubBuffer.PositionRow, LineSubBuffer.RowCount);
line 113]                    LineSubBuffer.Wipe();
line 114]                    UpdateLineSubBuffer();

The MarkRowsDirty call blows past the last line of the buffer (giving the out of bounds error) because the subbuffer starts on the last row and extends past the end of the screen buffer. The call to UpdateLineSubBuffer on line 114 normally would cause the extra line to be appended to the buffer (eventually, when it finally gets to the call to KeepCursorInBounds nested inside it), but that doesn't occur until after it attempted MarkRowsDirty.

The problem is I have to solve this chicken-and-egg situation by exploding some of the parts of these out. At the moment, MarkRowsDirty must be called prior to UpdateLineSubBuffer and UpdateLineSubBuffer must be called prior to MarkRowsDIrty.

erendrake added a commit that referenced this issue Dec 27, 2015
…_history

Fixes #1289 (buffer overrun in command history)
@Dunbaratu
Copy link
Member Author

Closed #730 from this too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Weird outcome is probably not what the mod programmer expected.
Projects
None yet
Development

No branches or pull requests

2 participants