【问题标题】:Hiding Cursor in Xterm Tektronix 4014 Mode在 Xterm Tektronix 4014 模式下隐藏光标
【发布时间】:2016-05-16 12:05:16
【问题描述】:

我编写了以下程序来测试 Xterm Tektronix 4014 模式:

#define _BSD_SOURCE
#include <stdio.h>
#include <assert.h>
#include <unistd.h>

#define GS ((char)0x1D)
#define ESC ((char)0x1B)
#define FF ((char)0x0C)

static void xy (int x,  int y, char* restrict xy) {
  xy[3] = (x % 32) + 64; // x low
  xy[2] = (x >> 5) + 32; // x high
  xy[1] = (y % 32) + 96; // y low
  xy[0] = (y >> 5) + 32; // y high
  assert (x == 32 * (xy[2] - 32) + xy[3] - 64);
  assert (y == 32 * (xy[0] - 32) + xy[1] - 96);
}

static void enter_graphic () {
  printf("%c", GS);
}

static void leave_graphic () {
  printf("\n");
}


static char pt[] = { ESC, 0, 0, 0, 0, 0, 0 };

/* This function is NOT threadsafe! (but why should it be ...) */
static void line_to (int x, int y, char pattern) {
  pt[1] = pattern ? pattern : '`';
  xy(x, y, pt + 2);
  printf("%s", pt);
}

static void clear () {
  printf("%c%c", ESC, FF);
}

static void randgrph (int dx, int dy) {
  int x, y;
  enter_graphic ();

  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      x = (x + 7) % 200;
      y = (y + 39) % 200;
      line_to(x + dx, y + dy, 'b');
    }
  }

  leave_graphic();
}

int main (void) {
  int i, j;
  for (i = 0; i < 200; ++i) {
    for (j = 0; j < 200; ++j) {
      clear();
      randgrph(i, j);
      usleep(1000000/25);
    }
  }
}

这似乎工作正常。 xy 创建一个坐标对,line_to 绘制一条线。这将在循环中清除屏幕,绘制一些虚线。至少在 Xterm 上,它看起来是“动画的”(我猜真正的 Tektronix 速度不够快,但它只是用于测试)。

但是:它总是显示文本光标。我怎样才能阻止它这样做?我找不到 Tek 控制序列来隐藏文本光标,只能隐藏图形光标,反正 xterm 中没有显示。

【问题讨论】:

    标签: c linux graphics terminal xterm


    【解决方案1】:

    解决方案是控制终端需要设置为不回显输入。这可以通过来自libncursesnoecho() 来完成。

    【讨论】:

      【解决方案2】:

      VT100 转义不适用于 Tek4014 显示器。 Tek4014只有两种光标模式:

      • 正常(箭头)
      • 图形GIN 模式(也称为十字光标)。

      图形光标由转义序列 escapecontrolZ 激活并通过鼠标单击停用,例如 gin-press 操作在translations 资源中使用。

      供参考:

      【讨论】:

        【解决方案3】:

        VT100 序列ESC [ ? 2 5 l 可能有效。

        【讨论】:

          猜你喜欢
          • 2011-04-06
          • 1970-01-01
          • 2010-11-02
          • 1970-01-01
          • 1970-01-01
          • 2011-10-06
          • 1970-01-01
          • 2022-12-21
          • 2020-02-10
          相关资源
          最近更新 更多