gpt4 book ai didi

c++ - 鼠标向上滚动 (Ncurses/C++)

转载 作者:行者123 更新时间:2023-11-28 05:17:19 26 4
gpt4 key购买 nike

我的问题是我不知道如何使用 ncurses5 和鼠标事件上下滚动。

我知道这是 ncurses5.6+ 的一个特性,但我不知道我是否可以从包装商那里获得这个版本。

即使我能得到它,zsh、bash、sh 等也可以在每个终端上很好地滚动(如何?),这是硬件功能吗?我可以在不添加比 ncurses、c standard 和 std 更多的 lib 的情况下在我的 c++ 程序中得到我自己的吗?

此代码适用于向下滚动,但在我尝试集成 BUTTON5_PRESSED 时无法编译(因为我的 ncurses 版本)。

等等,实际上我可以处理向下滚动但不能处理向上滚动。有没有办法同时处理这两者?

 // mouse event structure
MEVENT event;

if (getmouse(&event) == OK) {
printw("mouse Event OK");
if (event.bstate & BUTTON4_PRESSED)
wprintw(_win, "Button4\n");
else if (event.bstate & BUTTON5_PRESSED) // does not compile
wprintw(_win, "Button5\n");
}

我的实际代码托管在 github https://github.com/Liroo/Nanotekspice/blob/master/lib/cli/mode/NcursesMode.cpp ,看看你是否有动力! (顺便说一句,将它与此命令一起使用以获得 ncurses 格式:./nanotekspice resources/basics/test.nts c=1 --mode=ncurses)

最佳答案

简而言之:不,没有解决方法

长—滚轮鼠标(按照惯例)发送 button-4 和 button-5 用于向上/向下事件。 ncurses5 不为这两个按钮提供编码。这是 ncurses6 ( September 2005 ) 的标准扩展(来自 August 2015 ):

These notes are for ncurses 6.0, released August 8, 2015.

This release is designed to be source-compatible with ncurses 5.0 through 5.9; providing a new application binary interface (ABI). Although the source can still be configured to support the ncurses 5 ABI, the intent of the release is to provide extensions which are generally useful, but binary-incompatible with ncurses 5:

  • Extend the cchar_t structure to allow more than 16 colors to be encoded.

  • Modify the encoding of mouse state to make room for a 5th mouse button. That allows one to use ncurses with a wheel mouse with xterm or similar X terminal emulators.

进一步阅读:

关于c++ - 鼠标向上滚动 (Ncurses/C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42356352/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com