FAQ
Hi,

I try to write a application running in the command line of linux.

I want the application to be triggered when the user click the shortcut
key, such as ctrl+r

The question is how the go codes know user click the ctrl+r, which is from
the system.

Regards,
Yaotian

Search Discussions

  • Alan Donovan at Sep 30, 2012 at 4:27 pm
    This isn't really a question about Go per se. The command line of
    Linux is really two programs: the shell (e.g. Bash), which interprets
    the command you type, and the terminal emulator, which is a program
    that:
    (a) converts special sequences of bytes in the output of your program
    (called terminal control codes) into effects such as color, cursor
    repositioning, etc,
    (b) delivers signals to your program on certain events, such as when
    the window size changes,
    (c) turns keyboard events into lines of input to your program, e.g. by
    buffering up a line at a time.

    When you type Ctrl-r at Bash in a terminal, the effect you see
    (reverse incremental search) results from shell program (using the GNU
    Readline library) working together with your terminal in "raw mode"
    which means the terminal passes on every keyboard event to the shell
    instead of processing. I suggest you read more about Bash, GNU
    Readline and terminals (raw and "cooked" modes) to understand how to
    answer your question.

    cheers
    alan

    On 30 September 2012 04:48, yaotian wrote:
    Hi,

    I try to write a application running in the command line of linux.

    I want the application to be triggered when the user click the shortcut key,
    such as ctrl+r

    The question is how the go codes know user click the ctrl+r, which is from
    the system.

    Regards,
    Yaotian
  • Yaotian at Oct 1, 2012 at 11:41 am
    Thanks Alan. I will read more about what you suggested. And i will update
    to this email chain once i got the answer.

    2012/10/1 Alan Donovan <adonovan@google.com>
    This isn't really a question about Go per se. The command line of
    Linux is really two programs: the shell (e.g. Bash), which interprets
    the command you type, and the terminal emulator, which is a program
    that:
    (a) converts special sequences of bytes in the output of your program
    (called terminal control codes) into effects such as color, cursor
    repositioning, etc,
    (b) delivers signals to your program on certain events, such as when
    the window size changes,
    (c) turns keyboard events into lines of input to your program, e.g. by
    buffering up a line at a time.

    When you type Ctrl-r at Bash in a terminal, the effect you see
    (reverse incremental search) results from shell program (using the GNU
    Readline library) working together with your terminal in "raw mode"
    which means the terminal passes on every keyboard event to the shell
    instead of processing. I suggest you read more about Bash, GNU
    Readline and terminals (raw and "cooked" modes) to understand how to
    answer your question.

    cheers
    alan

    On 30 September 2012 04:48, yaotian wrote:
    Hi,

    I try to write a application running in the command line of linux.

    I want the application to be triggered when the user click the shortcut key,
    such as ctrl+r

    The question is how the go codes know user click the ctrl+r, which is from
    the system.

    Regards,
    Yaotian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 30, '12 at 1:51p
activeOct 1, '12 at 11:41a
posts3
users2
websitegolang.org

2 users in discussion

Yaotian: 2 posts Alan Donovan: 1 post

People

Translate

site design / logo © 2022 Grokbase