Terminal control/Restricted width positional input/With wrapping: Difference between revisions
Terminal control/Restricted width positional input/With wrapping (view source)
Revision as of 18:22, 28 August 2022
, 1 year agosyntax highlighting fixup automation
(Terminal control/Restricted width positional input/With wrapping in FreeBASIC) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 23:
==={{header|ncurses}}===
To interface ncurses from Lisp, the ''[https://www.cliki.net/croatoan croatoan]'' library is used.
<
(ql:quickload "croatoan")
(in-package :croatoan)
Line 40:
;; call the routine
(field-input-with-wrapping 2 4 8)</
=={{header|FreeBASIC}}==
<
Locate fila, columna, 0
Dim As String KBD, cadena = ""
Line 67:
Dim As String s = getInput(3, 5, 8)
Locate 23,1 : Print "You entered: "; s
Sleep</
Line 75:
<br>
This uses _getch() rather than _getwch() as only ASCII is supported.
<
/*
Line 155:
setCursor(coord)
fmt.Printf("You entered '%s'\n", s)
}</
=={{header|Julia}}==
Requires an ANSI compatible terminal and a system C library implementing _getch() for unbuffered keyboard input.
<
cls() = print("\33[2J")
reposition(row, col) = print("\u001b[$row;$(col)H")
Line 184:
s = input_y_x_upto(3, 5, 80, 8)
println("\n\n\nResult: You entered <<$s>>")
</syntaxhighlight>
=={{header|Kotlin}}==
{{works with|Windows 10}}
This follows a similar approach to the Kotlin entry for the [[Terminal control/Restricted width positional input/No wrapping]] task except, of course, that the code now allows for wrapping.
<
import kotlinx.cinterop.*
Line 257:
}
println("You entered '$s'")
}</
=={{header|Nim}}==
Line 265:
We had also to check for backspace character and for character <code>'\x7f'</code> as the backspace key gives this last value (but Control+H gives <code>'\x08'</code> i.e. ASCII backspace character).
<
proc eraseLineEnd() = stdout.write("\e[K")
Line 282:
setCursorPos(3, 5)
let s = inputXYUpto(3, 5, 80, 8)
echo &"\n\n\nResult: You entered <<{s}>>"</
=={{header|Phix}}==
<!--<
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (position, wait_key)</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">getInput</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">row</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">col</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">width</span><span style="color: #0000FF;">)</span>
Line 319:
<span style="color: #7060A8;">position</span><span style="color: #0000FF;">(</span><span style="color: #000000;">23</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"You entered '%s'\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">s</span><span style="color: #0000FF;">})</span>
<!--</
=={{header|Raku}}==
Line 328:
All printable character keys (except Tab) work, as does backspace and enter. Ctrl-c to exit. All other keys / key-combos are ignored.
<syntaxhighlight lang="raku"
constant $saved = Term::termios.new(fd => 1).getattr;
Line 394:
@screen = "\e[41m{' ' x $cols}\e[0m" xx $rows;
print "\e[H\e[J{@screen.join: "\n"}\e[$row;{$column}H$str\e[$row;{$column + $pointer}H";
}</
=={{header|REXX}}==
(Only works with: REXX/Personal)
<
parse arg row col len . /*obtain optional arguments from the CL*/
if row=='' | row=="," then row= 3 /*Not specified? Then use the default.*/
Line 414:
say 'data read from terminal row ' row " col " col ' length ' len " is:"
say $
exit 0 /*stick a fork in it, we're all done. */</
=={{header|Wren}}==
Due to a bug the ''Stdin.readByte()'' method can currently process only the first byte of a multi-byte character. The others are skipped.
<
var textAtPos = Fn.new { |text, r, c|
Line 463:
var res = input.call(3, 5, 8)
System.print(res)</
=={{header|Yabasic}}==
<
// by Galileo, 04/2022
Line 496:
text$ = getInput$(3, 5, 8)
print at(1, 23) "You entered: ", text$</
|