代码之家  ›  专栏  ›  技术社区  ›  JesperE

在GNU屏幕中使用滚轮

  •  230
  • JesperE  · 技术社区  · 17 年前

    如何设置GNU屏幕以允许鼠标的滚轮在回滚缓冲区中滚动?我试着在谷歌上搜索一下,但大多数点击都是关于如何允许屏幕内的应用程序使用滚轮。

    10 回复  |  直到 6 年前
        1
  •  375
  •   Lekensteyn    12 年前

    我相信你可以把这样的一行添加到你的 ~/.screenrc :

    termcapinfo xterm* ti@:te@
    

    screen -d -r 然后重新连接 ls 几次,然后尝试向后滚动。它对我有用。


    这是什么魔法?好吧,让我们查阅一下手册。

    screen(1)

    termcapinfo term terminal-tweaks [window-tweaks]
      [..]
      The first argument specifies which terminal(s) should be affected by this
      definition. You can specify multiple terminal names by separating them with
      `|'s. Use `*' to match all terminals and `vt*' to match all terminals that
      begin with "vt".
      [..]
      Some examples:
    
          termcap xterm*  LP:hs@
    
      Informs screen that all terminals that begin with `xterm' have firm
      auto-margins that allow the last position on the screen to be updated (LP),
      but they don't really have a status line (no 'hs' -  append  `@'  to turn
      entries off).  Note that we assume `LP' for all terminal names that start
      with "vt", but only if you don't specify a termcap command for that terminal.
    

    从…起 termcap(5) :

    String capabilities
        [..]
        te   End program that uses cursor motion
        ti   Begin program that uses cursor motion
    
        2
  •  75
  •   sleske    11 年前

    在屏幕中,您必须首先进入“滚动模式”(或“复制模式”),才能在滚动缓冲区:键组合中滚动 - A. 电子稳定控制系统 - A. - . 然后,您可以使用向上和向下键(或 Ctrl键 B , Ctrl键 - F

    在这种模式下,如果鼠标滚轮在其他应用程序中也能工作,那么它也应该能工作。 电子稳定控制系统

    至于在不首先进入滚动模式的情况下滚动滚动滚动缓冲区,如果不修改屏幕,这可能是不可能的。除了滚动模式之外,我从未听说过访问滚动缓冲区的方法。

        3
  •  24
  •   Tommi R.    15 年前

    Jon Z提到的那篇优秀的文章已经不存在了,但是我能够从Google缓存中找到它的纯文本版本。我把它保存在这里,以防谷歌将来也放弃它。最初的帖子是由Mikael Stldal写的,所以应该在这里注明信用。

    GNU屏幕支持回滚,但默认情况下,您必须使用笨拙的键才能使用它。我希望能够使用Shift PageUp、Shift PageDown和鼠标滚轮进行滚动,就像您在xterm中所做的那样。

    为此配置屏幕并不容易,它涉及到和终端仿真器的合作。但我最终成功地找到了一个非常有效的解决方案。将其添加到~/.Xresources文件中(您需要注销才能使其生效):

    XTerm*saveLines: 0
    XTerm*vt100.translations: #override \n\
      Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
      Lock Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
      Lock @Num_Lock Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
      @Num_Lock Ctrl <Btn4Down>: string(0x1b) string("[25S") \n\
      <Btn4Down>: string(0x1b) string("[5S") \n\
      Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
      Lock Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
      Lock @Num_Lock Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
      @Num_Lock Ctrl <Btn5Down>: string(0x1b) string("[25T") \n\
      <Btn5Down>: string(0x1b) string("[5T") \n\
      Shift <KeyPress> Prior: string(0x1b) string("[25S") \n\
      Shift <KeyPress> Next: string(0x1b) string("[25T") \n
    

    然后将其添加到~/.screenrc文件中:

    defscrollback 1000
    
    # Scroll up
    bindkey -d "^[[5S" eval copy "stuff 5\025"
    bindkey -m "^[[5S" stuff 5\025
    
    # Scroll down
    bindkey -d "^[[5T" eval copy "stuff 5\004"
    bindkey -m "^[[5T" stuff 5\004
    
    # Scroll up more
    bindkey -d "^[[25S" eval copy "stuff \025"
    bindkey -m "^[[25S" stuff \025
    
    # Scroll down more
    bindkey -d "^[[25T" eval copy "stuff \004"
    bindkey -m "^[[25T" stuff \004
    

    xterm -e screen
    
        4
  •  13
  •   Jesse Crossen    13 年前

    对于OS X(雪豹),以下几点对我很有用:

    http://slaptijack.com/system-administration/mac-os-x-terminal-and-gnu-screen-scrollback/

    简单地说,它包括将以下内容添加到远程主机上的~/.screenrc(您正在运行screen的主机):

    defscrollback 5000
    termcapinfo xterm* ti@:te@
    
        5
  •  11
  •   edench    14 年前

    [.vimrc]

    set mouse=a             " hold shift to copy xterm
    set ttymouse=xterm2     " necessary for gnu screen & mouse
    
        6
  •  8
  •   j0k gauthamp    13 年前

    + A. 然后 [

    要恢复正常,请按Esc键或按Enter键几次。

        7
  •  7
  •   lemonsqueeze    11 年前

    背景 TERM vt100 xterm

    将此添加到您的 .bashrc :

    # make scrollbar / wheel scrolling work when running screen in gnome-terminal (or other)
    if [ "$TERM" = "xterm" ]; then
      export TERM=vt100
    fi
    

    作为参考,我的 .screenrc

    # Extend the vt100 desciption by some sequences.
    termcap  vt100* ms:AL=\E[%dL:DL=\E[%dM:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC
    terminfo vt100* ms:AL=\E[%p1%dL:DL=\E[%p1%dM:UP=\E[%p1%dA:DO=\E[%p1%dB:LE=\E[%p1%dD:RI=\E[%p1%dC
    
        8
  •  5
  •   Torbjör Weiland    11 年前

    编辑.screenrc并添加

    terminfo xterm* ti=:te=
    
        9
  •  3
  •   nachocab    8 年前

    如果上面的答案不适合你,请确保你没有 说明文字 或者 始终斜线 在.screenrc中设置选项。如果您有,这将不起作用:

    termcapinfo xterm* ti@:te@
    

    如果需要此信息,可以尝试在终端标题中设置它(使用 termcapinfo

        10
  •  3
  •   Malcolm Boekhoff    8 年前

    a) 。使现代化 $HOME/.screenrc 正如前面的答案所规定的那样:

    termcapinfo xterm* ti@:te@
    

    一些多余的注释

    • 没有其他终端,包括安装“lxterminal”,

    • 通过单击屏幕左上角的菜单按钮,您可以 可以使用右下角的第三个图标获取设置对话框

    推荐文章