org.jline.terminal.Terminal.getSize()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.jline.terminal.Terminal.getSize()方法的一些代码示例,展示了Terminal.getSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terminal.getSize()方法的具体详情如下:
包路径:org.jline.terminal.Terminal
类名称:Terminal
方法名:getSize

Terminal.getSize介绍

暂无

代码示例

代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core

@Override
public Size getSize() {
  return terminal.getSize();
}

代码示例来源:origin: apache/karaf

@Override
public Size getSize() {
  return terminal.getSize();
}

代码示例来源:origin: com.github.fonimus/spring-boot-ssh-shell-starter

@Override
public Size getSize() {
  return delegate().getSize();
}

代码示例来源:origin: com.github.fonimus/ssh-shell-starter

@Override
public Size getSize() {
  return delegate().getSize();
}

代码示例来源:origin: org.jline/jline

default int getWidth() {
  return getSize().getColumns();
}

代码示例来源:origin: org.jline/jline

default int getHeight() {
  return getSize().getRows();
}

代码示例来源:origin: org.apache.karaf/org.apache.karaf.client

private static void registerSignalHandler(final Terminal terminal, final PtyCapableChannelSession channel) {
  try {
    Class<?> signalClass = Class.forName("sun.misc.Signal");
    Class<?> signalHandlerClass = Class.forName("sun.misc.SignalHandler");
    // Implement signal handler
    Object signalHandler = Proxy.newProxyInstance(Main.class.getClassLoader(),
        new Class<?>[]{signalHandlerClass}, (proxy, method, args) -> {
          Size size = terminal.getSize();
          channel.sendWindowChange(size.getColumns(), size.getRows());
          return null;
        }
    );
    // Register the signal handler, this code is equivalent to:
    // Signal.handle(new Signal("CONT"), signalHandler);
    signalClass.getMethod("handle", signalClass, signalHandlerClass).invoke(
        null,
        signalClass.getConstructor(String.class).newInstance("WINCH"),
        signalHandler);
  } catch (Exception e) {
    // Ignore this exception, if the above failed, the signal API is incompatible with what we're expecting
  }
}

代码示例来源:origin: apache/karaf

private static void registerSignalHandler(final Terminal terminal, final PtyCapableChannelSession channel) {
  try {
    Class<?> signalClass = Class.forName("sun.misc.Signal");
    Class<?> signalHandlerClass = Class.forName("sun.misc.SignalHandler");
    // Implement signal handler
    Object signalHandler = Proxy.newProxyInstance(Main.class.getClassLoader(),
        new Class<?>[]{signalHandlerClass}, (proxy, method, args) -> {
          Size size = terminal.getSize();
          channel.sendWindowChange(size.getColumns(), size.getRows());
          return null;
        }
    );
    // Register the signal handler, this code is equivalent to:
    // Signal.handle(new Signal("CONT"), signalHandler);
    signalClass.getMethod("handle", signalClass, signalHandlerClass).invoke(
        null,
        signalClass.getConstructor(String.class).newInstance("WINCH"),
        signalHandler);
  } catch (Exception e) {
    // Ignore this exception, if the above failed, the signal API is incompatible with what we're expecting
  }
}

代码示例来源:origin: org.jline/jline-builtins

public void handle(Signal signal) {
  size.copy(terminal.getSize());
  try {
    display.clear();
    display(false);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.jline/jline

public void handle(Signal signal) {
  size.copy(terminal.getSize());
  try {
    display.clear();
    display(false);
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.jline/jline-builtins

private void handle(Terminal.Signal signal) {
  int prevw = size.getColumns();
  size.copy(terminal.getSize());
  try {
    if (size.getColumns() < prevw) {
      display.clear();
    }
    display();
  } catch (IOException e) {
    // ignore
  }
}

代码示例来源:origin: org.jline/jline

private void handle(Terminal.Signal signal) {
  int prevw = size.getColumns();
  size.copy(terminal.getSize());
  try {
    if (size.getColumns() < prevw) {
      display.clear();
    }
    display();
  } catch (IOException e) {
    // ignore
  }
}

代码示例来源:origin: org.jline/jline

protected void handle(Signal signal) {
  if (buffer != null) {
    size.copy(terminal.getSize());
    buffer.computeAllOffsets();
    buffer.moveToChar(buffer.offsetInLine + buffer.column);
    resetDisplay();
    display();
  }
}

代码示例来源:origin: org.jline/jline-builtins

protected void handle(Signal signal) {
  if (buffer != null) {
    size.copy(terminal.getSize());
    buffer.computeAllOffsets();
    buffer.moveToChar(buffer.offsetInLine + buffer.column);
    resetDisplay();
    display();
  }
}

代码示例来源:origin: org.jline/jline-builtins

private void handleResize() {
  // Re-compute the layout
  if (resized.compareAndSet(true, false)) {
    size.copy(terminal.getSize());
  }
  layout.resize(size.getColumns(), size.getRows() - 1);
  panes.forEach(vc -> {
    if (vc.width() != vc.layout.sx || vc.height() != vc.layout.sy
        || vc.left() != vc.layout.xoff || vc.top() != vc.layout.yoff) {
      vc.resize(vc.layout.xoff, vc.layout.yoff, vc.layout.sx, vc.layout.sy);
      display.clear();
    }
  });
}

代码示例来源:origin: org.jline/jline

private void handleResize() {
  // Re-compute the layout
  if (resized.compareAndSet(true, false)) {
    size.copy(terminal.getSize());
  }
  layout.resize(size.getColumns(), size.getRows() - 1);
  panes.forEach(vc -> {
    if (vc.width() != vc.layout.sx || vc.height() != vc.layout.sy
        || vc.left() != vc.layout.xoff || vc.top() != vc.layout.yoff) {
      vc.resize(vc.layout.xoff, vc.layout.yoff, vc.layout.sx, vc.layout.sy);
      display.clear();
    }
  });
}

代码示例来源:origin: org.jline/jline-builtins

size.copy(terminal.getSize());
Terminal.SignalHandler prevHandler = terminal.handle(Terminal.Signal.WINCH, this::handle);
Attributes attr = terminal.enterRawMode();

代码示例来源:origin: org.jline/jline

protected void handleSignal(Signal signal) {
  if (signal == Signal.WINCH) {
    size.copy(terminal.getSize());
    display.resize(size.getRows(), size.getColumns());
    redisplay();
  }
  else if (signal == Signal.CONT) {
    terminal.enterRawMode();
    size.copy(terminal.getSize());
    display.resize(size.getRows(), size.getColumns());
    terminal.puts(Capability.keypad_xmit);
    redrawLine();
    redisplay();
  }
}

代码示例来源:origin: org.jline/jline

try {
  size.copy(terminal.getSize());
  layout = new Layout();
  layout.sx = size.getColumns();

代码示例来源:origin: org.jline/jline-builtins

try {
  size.copy(terminal.getSize());
  layout = new Layout();
  layout.sx = size.getColumns();

相关文章