Beispiel #1
0
def WriteOSC(params, bel=False, requestsReport=False):
    str_params = map(str, params)
    joined_params = ";".join(str_params)
    if bel:
        terminator = BEL
    else:
        terminator = ST
    sequence = OSC() + joined_params + terminator
    LogDebug("Send sequence: " + sequence.replace(ESC, "<ESC>"))
    Write(sequence, sideChannelOk=not requestsReport)
Beispiel #2
0
def GetCharSizePixels():
    """Returns a Size giving the font's character-size in pixels.

  While xterm can be told to change its font, none of these tests exercise
  that feature.  We cache a value to improve performance.
  """
    global gCharSizePixels
    if gCharSizePixels.height() == 0:
        esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_CHAR_SIZE_PIXELS)
        params = escio.ReadCSI("t")
        AssertTrue(params[0] == 6)
        AssertTrue(len(params) >= 3)
        gCharSizePixels = Size(params[2], params[1])
        LogDebug("size of CHARS " + str(gCharSizePixels.height()) + "x" +
                 str(gCharSizePixels.width()))
    return gCharSizePixels
Beispiel #3
0
def GetFrameSizePixels():
    """Returns a Size giving the terminal's border/title frame size.

  The frame size is used to adjust the expected error in window-resizing
  tests which modify the shell window's size.
  """
    global gFrameSizePixels
    if gFrameSizePixels.height() == 0:
        GetCharSizePixels()
        outer = GetWindowSizePixels()
        inner = GetScreenSize()
        gFrameSizePixels = Size(
            outer.height() - (inner.height() * gCharSizePixels.height()),
            outer.width() - (inner.width() * gCharSizePixels.width()))
        LogDebug("size of FRAME " + str(gFrameSizePixels.height()) + "x" +
                 str(gFrameSizePixels.width()))
    return gFrameSizePixels
Beispiel #4
0
def WriteCSI(prefix="", params=[], intermediate="", final="", requestsReport=False):
  if len(final) == 0:
    raise esctypes.InternalError("final must not be empty")
  def StringifyCSIParam(p):
    if p is None:
      return ""
    else:
      return str(p)
  str_params = map(StringifyCSIParam, params)

  # Remove trailing empty args
  while len(str_params) > 0 and str_params[-1] == "":
    str_params = str_params[:-1]

  joined_params = ";".join(str_params)
  sequence = CSI() + prefix + joined_params + intermediate + final
  LogDebug("Send sequence: " + sequence.replace(ESC, "<ESC>"))
  Write(sequence, sideChannelOk=not requestsReport)
Beispiel #5
0
def GetChecksumOfRect(rect):
    global gNextId
    Pid = gNextId
    gNextId += 1
    esccmd.DECRQCRA(Pid, 0, rect)
    params = escio.ReadDCS()

    str_pid = str(Pid)
    if not params.startswith(str_pid):
        Raise(esctypes.BadResponse(params, "Prefix of " + str_pid))

    i = len(str_pid)

    AssertTrue(params[i:].startswith("!~"))
    i += 2

    hex_checksum = params[i:]
    LogDebug("GetChecksum " + str_pid + " = " + hex_checksum)
    return int(hex_checksum, 16)
Beispiel #6
0
def GetScreenSizePixels():
    """Returns a Size giving the screen's size in pixels.

  The "screen" refers to the X display on which xterm is running.
  Because that does not change as a result of these tests, we
  cache a value to help with performance."""
    global gScreenSizePixels
    if gScreenSizePixels.height() == 0:
        if escargs.args.expected_terminal == "xterm":
            esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_SCREEN_SIZE_PIXELS)
            params = escio.ReadCSI("t")
            AssertTrue(params[0] == 5)
            AssertTrue(len(params) >= 3)
            gScreenSizePixels = Size(params[2], params[1])
        else:
            # iTerm2 doesn't support esccmd.WINOP_REPORT_SCREEN_SIZE_PIXELS so just fake it.
            gScreenSizePixels = Size(1024, 768)
        LogDebug("size of SCREEN " + str(gScreenSizePixels.height()) + "x" +
                 str(gScreenSizePixels.width()))
    return gScreenSizePixels