About: Wait for user input (getchar) without moving cursor   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

The most basic form is something like this: imap imap =PrintChar() function! PrintChar() let chr="" if getchar(1) let chr = getchar() endif call feedkeys("\") echo chr return '' endfunction When the user presses F8, the above script simply echos the keypresses until the user presses Escape. Every time PrintChar() is called, it uses feedkeys() to reactivate itself, setting up an input loop.

AttributesValues
rdfs:label
  • Wait for user input (getchar) without moving cursor
rdfs:comment
  • The most basic form is something like this: imap imap =PrintChar() function! PrintChar() let chr="" if getchar(1) let chr = getchar() endif call feedkeys("\") echo chr return '' endfunction When the user presses F8, the above script simply echos the keypresses until the user presses Escape. Every time PrintChar() is called, it uses feedkeys() to reactivate itself, setting up an input loop.
Version
  • 7(xsd:integer)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 0(xsd:integer)
Author
  • Q335r49
Subpage
  • /2014
Complexity
  • basic
Created
  • 2014-01-30(xsd:date)
ID
  • 0(xsd:integer)
NEXT
  • 0(xsd:integer)
abstract
  • The most basic form is something like this: imap imap =PrintChar() function! PrintChar() let chr="" if getchar(1) let chr = getchar() endif call feedkeys("\") echo chr return '' endfunction When the user presses F8, the above script simply echos the keypresses until the user presses Escape. Every time PrintChar() is called, it uses feedkeys() to reactivate itself, setting up an input loop. The first line, imap <f8> <esc> <nop></nop> </esc> </f8> serves two functions. First, it allows a way to break the loop. The second is more subtle: it makes the F8 mapping ambiguous, which will cause Vim to pause momentarily to wait for the next keystroke, since it is unsure which mapping the user wants to activate. This is a clever way to slow down the loop while still leaving Vim responsive for user input.
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software