in qpython, how do I enter a "return" character - qpython

Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter)

go to settings->input method select word-based

The console works just like a normally python console. You can use a function if you want to write a script in the console.

There is no way of doing it.
The console will automatically input a break line when the line of code ends so you can continue inputting in the screen without any scroll bars.
For complex code, you should use the editor.

Would a newline character solve your problem?
s = "line 1\n line 2"
print(s)
Should print out
line 1
line 2
If that's what you're looking for? It's called an escape - Python has other ones for tab, etc.

Related

Trouble with Scilab "print" instruction

Trying to debug a program in Scilab, I inserted a couple
of "print" instructions to track what is going on.
At first, I used the %io(2) output "file" which, according
to the Help, stands for the console. Nothing happened.
Then I used an actual filename:
print("C:\Leszek\Xprmnt\scl\Ovsjanko\K3ScilabLog.txt", "START! \n \n \n \n GOING \n")
which does print to that file, but when the dust has settled
and I want to inspect the file what I find inside is just the last
message (just before the program crashed), even though there should
have been others before it, including the "START" etc in the quote above.
Apparently, every print command reopens the file for writing as a clean slate,
overwriting whatever was in it before. Looking into Help and online docs
I didn't find any options or parameters that I could use to change this.
What I want is, obviously, the output from all my print commands since the
beginning of the program, either on the console or in a text file.
TIA.
Just use disp("some text") or mprintf("format",var1,...,varn), both will display on the console. If you need to write in a file use fd = mopen("file.txt") then mfprint(fd,"format",var1,...,varn).

Resizing output Terminal in C Language

would like to get some help on a c project i am currently working on. I have a string/array of output to the terminal, but somehow the standard terminal is too small for my output. Even after i manually expand the window of the console the output is still cut off, instead of printing in a single line, it just gets cut off and go to the next row automatically.
hope to get help.
I think that the only way to correct this is by splitting your one-line output in multiple lines, using "\n" at the end of every line.
By doing this you can control when and where it has to write in the next line, and you can make it look more like you wanted to.

Displaying text files

I'm trying to display the "Phrack" text files. The problem is that the screen doesn't clear before displaying the text file. And overwrites whatever is on the screen at the time. I've tried printf() declarations, like printf("^[[2J") and printf("^[[22;1H") and so forth. And various ncurses "clear screen" commands. None of which worked. Here's the line:
system("/usr/bin/stty -raw") | system("/usr/bin/cat /home/imp/phrack/1/P01-01") | system("/usr/bin/stty -cooked");
Thanks.
The line
printf("^[[2J")
and the tag c indicate that OP wants to write a program in C to clear the screen. The problem with that line is that there's no escape character. This would work:
printf("\033[H\033[2J"); fflush(stdout);
because it uses the escape character. I added the fflush to make it happen "now" rather than sometime later.
There are no uses of ncurses in the question.

C escape sequence \033[999D not working properly

I'm trying to use the escape sequence \033[999D as a brute-force way of moving the cursor to the top row in the console. When I run my program, rather than doing what I intend, it returns a left-pointing arrow and a [999D, on the same line that I was last on.
How should I properly use this escape code? Are there any (better) substitutions?
My (test) code:
printf("This is a line\n");
printf("This is another line\n");
printf("\033[999D Overwrite");
My output:
This is a line
This is another line
←[999D Overwrite
Check out the Win32 Console API.
Particularly of interest to you:
GetStdHandle (MSDN)
SetConsoleCursorPosition (MSDN)
Here is an example showing how to move the cursor to a specific position.
Here is an example showing how to clear the screen.
Of interest to people looking to set console colors:
SetConsoleTextAttribute
There are two problems (most likely): The first is that the D VT100 cursor control sequence is to go back a number of columns, which means it will go back a number of columns on the current row. It will not change line.
The second and the likely problem the code is printed is because you probably are using the Windows console program (the "DOS prompt") which is very bad at handling VT100 sequences by default.

UART, return to the start of the page

Is it possible,somehow,to return to the beginning of the page, not line, page.
Using something like "hello\r" would,obviously, write "hello" and return to the start of the line.
But what about when I am on a second line?
So after "hello\n" it would put me on a second line.
Can I somehow return back to the 1st line.
From the research I have conducted it seems that you can only operate on 1 line, but I am not 100% sure and thus would like someone to confirm this.
Programming in C and using RealTerm.
RealTerm has an ANSI terminal emulation mode.
Find the "Display Formatting " configuration dialog and select the Ansi option.
Now you can embed an escape sequence for Cursor Home much like you embed the newline.
<ESC>[H
Where, of course, <ESC> means the single character 0x1b. You can implement it like this
sprintf(buffer, "%c[Hmy text\n", 27);
transmit(buffer);
or similar.

Resources