Forum > General

CRT unit kills Ctrl-C - SOLVED

<< < (3/3)

Warfley:

--- Quote from: jollytall on June 05, 2023, 12:47:22 pm ---@Warfley: Thanks, it almost works.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---write(#27'[6n');read(s);gives back a string like

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---^[[9;1Rwhere 9 is the row (counting from the top of the screen) and 1 is the column. So, it works. Two problems:
- The reply string appears on the screen, though I would prefer it hidden.
- The read stops waiting for an enter (I tried writeLN and readLN in every combination, but it is the same).
How can I read the same string hidden and continue running?

--- End quote ---

I'm currently on Windows so I can't try myself, but you could try to turn the terminal into raw mode, send the request, read the response and then return back to buffered mode.
To enable RAW mode you can look at how I did it here: https://github.com/Warfley/LazTermUtils/blob/master/src/compatibility.pas#L143

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function EnableDirectRead(Handle: THandle): TDirectReadState;{$IfDef WINDOWS}begin  GetConsoleMode(Handle, Result);  SetConsoleMode(Handle, Result And Not (ENABLE_ECHO_INPUT Or ENABLE_LINE_INPUT or ENABLE_PROCESSED_INPUT));end;{$Else}var  nTIO: Termios;  i: SizeInt;begin  TCGetAttr(Handle, Result);  nTIO := Result;  // Raw to not echo the characters inputted  CFMakeRaw(nTIO);  // Directly read and don't line buffer  TCSetAttr(Handle, TCSANOW, nTIO);end;{$EndIf} procedure RestoreDirectRead(Handle: THandle; oldState: TDirectReadState);{$IfDef WINDOWS}begin  SetConsoleMode(Handle, oldState);end;{$Else}begin  TCSetAttr(Handle, TCSANOW, oldState);end;{$EndIf}
So it would be:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---OldState := EnableDirectRead(InputHandle);try    write(#27'[6n');    read(s);finally  RestoreDirectRead(InputHandle, OldState);end;

Navigation

[0] Message Index

[*] Previous page

Go to full version