在 ncurses 中移动制表符空间

Moving over tab spaces in ncurses

我正在使用 ncurses 创建一个基本的文本编辑器。它可以很好地显示文本,但是使用箭头键导航会在遇到制表符时出现问题。调用 move(y, x) 会将光标自由移动到选项卡 space 上,大多数文本编辑器将跳转到下一个字符。 ncurses 中是否有跳过选项卡 spaces 的功能,还是我需要自己找到一种方法来完成它?

你必须自己做:wmove移动到给定的坐标,忽略字符在屏幕上的显示方式。

如果破坏性(用空格填充)选项卡适用于您的应用程序,那么您可以使用 waddch:

If ch is a tab, newline, carriage return or backspace, the cursor is moved appropriately within the window:

Tabs are considered to be at every eighth column. The tab interval may be altered by setting the TABSIZE variable.

对于编辑器,您可能不希望出现这种行为(尽管在显示文本时使用 TABSIZE 功能可能会有所帮助)。