SimpleIDE terminal cursor control
Rsadeika
Posts: 3,837
I started experimenting with cursor control, and the first problem I am running into is, Back Space backs up two characters instead of one. Am I using the code incorrectly? Also, when I test for a cursor left, nothing occurs, is there something that I am missing?
Ray
Ray
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 '' This program uses the terminal and some common tools, so '' to use them, label the objects. OBJ term : "Extended_FDSerial" '' An enhanced version of FullDuplexSerial (FDS) '' misc : "tools" '' My object that contains some common tools. PUB Start '' Setup EFDS for a 115200 BAUD rate. '' Rx,Tx,Mode,BAUD term.Start(31,30,0,115200) Main PUB Main | inAbyte repeat repeat inAbyte := term.Rx term.Tx(inAbyte) if inAbyte == 10 '' Is it a CR CRLF if inAbyte == 8 '' Is it a Back Space term.Tx(8) '' Moves back two characters if inAbyte == 3 '' Is it a cursor left term.Tx(3) '' This does nothing PUB CRLF term.Tx(13) '' CR term.Tx(10) '' LF
Comments
Code fragment ....
Ray
Ugh, suffering from buffering again. No idea wtf putchar should be buffered.
The simpletext library will solve that and many other stdio related print problems.
Here is a more interesting example.
Ray
It is an example of backspace operation which is language agnostic.
You were concerned about backspace operation not working.
Ray
Ray,
Could your original program get two back-spaces because you enter a backspace and it gets echoed?
Again, try a simple loop without entering keys ... in spin this time ... and see what happens.
Arrow keys have different codes than back-space.
The larger problem is that if I am doing an RxStr how do I capture the Backspace press, and then remove the char from the RxStr input stream? This would be an even larger problem if I use the left cursor or right cursor keys to place the cursor on the char that I want to backspace/delete. I guess this is where I would want the power of C to take care of the issue. I will keep looking at this, but a push in the right direction would be appreciated.
Ray
Yes, that is expected behavior.
Ray I looked at the common serial input objects, and didn't see any input handling like this.
The simpletext library is designed to handle backspace (and delete, but the terminal only recognizes backspace).
Arrow keys are not handled. Arrow keys are defined for ANSI/VT100 terminals. ANSI terminal functions are beyond the scope of the Simple Terminal at this time.
You send the Backspace character twice, no wonder that it goes two spaces back:
Andy
Ray
Ray
Postedit: Actually there is code to add to a line, but it doesn't work for some reason.
The image also allows doing project-less spin compile if no project is open and no project exists with the same spin name.
Ray
Ray
Most likely your "broken" code is affected by the interpretation of Enter.
One fix is to use "if inAbyte == 10 or inAbyte == 13 '' Is it a CR", but that won't be perfect
The other fix is to use the Terminal options "Enter is NL" check-box.
There are two interpretations of Enter depending on the operating system being used: 10 and 13.
In the terminal options, you can choose what enter means.
By default Enter is NL (10) is checked. If you uncheck "Enter is NL", Enter will be CR (13).
Is there a switch control, in SimpleIDE, to direct it to an external terminal program. It seems like it may be easier to find an external terminal program that has cursor, and screen control, then to keep getting surprises in the SimpleIDE terminal. It also seems like if you design the program for use with an external terminal program you will have difficulty in running correctly on the SimpleIDE serial program. But then there might be the case where I am the only guy that is doing this, so maybe I should just find another alternative.
Ray
You have it backwards. Are you using Return instead of Enter?
I'm thinking the terminal should just send 10 to the program if it gets either 10 or 13.