コード例 #1
0
ファイル: vt520.c プロジェクト: hharte/vttest
/*
 * VT500 & up
 *
 * Test if terminal can control whether the screen is cleared when changing
 * DECCOLM.
 */
static int
tst_DECNCSM(MENU_ARGS)
{
  int last = max_lines - 4;
  char temp[80];

  decaln();
  deccolm(FALSE);
  vt_move(last, 1);
  ruler(last, min_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be cleared (%d-columns)", min_cols);
  println(temp);
  holdit();

  decaln();
  deccolm(TRUE);
  vt_move(last, 1);
  ruler(last, max_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be cleared (%d-columns)", max_cols);
  println(temp);
  holdit();

  decncsm(TRUE);

  decaln();
  deccolm(FALSE);
  vt_move(last, 1);
  ruler(last, min_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be filled (%d-columns)", min_cols);
  println(temp);
  holdit();

  decaln();
  deccolm(TRUE);
  vt_move(last, 1);
  ruler(last, max_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be filled (%d of %d-columns)", min_cols, max_cols);
  println(temp);
  holdit();

  decncsm(FALSE);
  deccolm(FALSE);
  vt_move(last, 1);
  ruler(last, min_cols);
  vt_clear(0);
  sprintf(temp, "Screen should be cleared (%d-columns)", min_cols);
  println(temp);

  return MENU_HOLD;
}
コード例 #2
0
ファイル: fhedit.c プロジェクト: loverabbit/kbs-redis
int fh_modify(int num)
{
    struct fileheader fh;
    if (num <= 0) {
        printf("number must be specified.\n");
        return 0;
    }
    lseek(fd, (num - 1) * sizeof(struct fileheader), SEEK_SET);
    if (binary) {
        while (fread(&fh, sizeof(struct fileheader), 1, stdin) > 0)
            write(fd, &fh, sizeof(struct fileheader));
    } else {
        if (read(fd, &fh, sizeof(struct fileheader)) <= 0)
            return 0;
        lseek(fd, (num - 1) * sizeof(struct fileheader), SEEK_SET);
        if (fhbool.filename[0])
            strncpy(fh.filename, fhopt.filename, FILENAME_LEN);
        if (fhbool.id)
            fh.id = fhopt.id;
        if (fhbool.groupid)
            fh.groupid = fhopt.groupid;
        if (fhbool.reid)
            fh.reid = fhopt.reid;
        if (fhbool.o_bid)
            fh.o_bid = fhopt.o_id;
        if (fhbool.o_id)
            fh.o_id = fhopt.o_id;
        if (fhbool.o_groupid)
            fh.o_groupid = fhopt.o_groupid;
        if (fhbool.o_reid)
            fh.o_reid = fhopt.o_reid;
        if (fhbool.innflag[0])
            strncpy(fh.innflag, fhopt.innflag, 2);
        if (fhbool.owner[0])
            strncpy(fh.owner, fhopt.owner, OWNER_LEN);
        if (fhbool.eff_size)
            fh.eff_size = fhopt.eff_size;
        if (fhbool.attachment)
            fh.attachment = fhopt.attachment;
        if (fhbool.title[0])
            strncpy(fh.title, fhopt.title, ARTICLE_TITLE_LEN);
        if (accessed9)
            ruler((char *)fh.accessed);
        else {
            if (fhbool.accessed[0])
                fh.accessed[0] = fhopt.accessed[0];
            if (fhbool.accessed[1])
                fh.accessed[1] = fhopt.accessed[1];
            if (fhbool.accessed[2])
                fh.accessed[2] = fhopt.accessed[2];
            if (fhbool.accessed[3])
                fh.accessed[3] = fhopt.accessed[3];
        }
        write(fd, &fh, sizeof(struct fileheader));
    }
    return 1;
}
コード例 #3
0
ファイル: CDataScope.cpp プロジェクト: neuks/Synaptics
void CDataScope::OnPaint(WPARAM wParam, LPARAM lParam)
{
  RECT rect;
  PAINTSTRUCT ps;
  INT nValue;
  SolidBrush brush(Color(0, 0, 0));
  Font font(L"Tahoma", 10, FontStyleRegular);

  // Stop rendering if minimized
  if (m_bMinimized)
  {
    return;
  }

  // Begin painting
  GetClientRect(m_hWnd, &rect);
  BeginPaint(m_hWnd, &ps);

  // Create back buffer
  Bitmap bitmap(rect.right, rect.bottom);
  Graphics window(ps.hdc), buffer(&bitmap);
  buffer.SetSmoothingMode(SmoothingModeAntiAlias);
  buffer.Clear(Color(255, 255, 255));

  // Drawing rulers
  Pen ruler(Color(0, 0, 0));
  AdjustableArrowCap arrow(8, 4, TRUE);
  ruler.SetCustomEndCap(&arrow);
  buffer.DrawLine(&ruler, 50, rect.bottom-20, 50, 12);
  buffer.DrawLine(&ruler, 50, rect.bottom-20, rect.right-12, rect.bottom-20);

  // Processing overflow data scrolling
  int nSize = m_qData[0].size();
  int wSize = (int)(((double)rect.right - 70) / m_fXScale);
  int nDiff = 0;
  if (nSize < wSize)
  {
    nDiff = 0;
  }
  else
  {
    nDiff = nSize - wSize;
  }

  // Calculate boundary
  double fMin = 0, fMax = 0;
  if (m_qData.size() > 0)
  {
    fMin = m_qData[0][nDiff];
    fMax = m_qData[0][nDiff];
  }
  for (int i = 0; i < m_qData.size(); i++)
  {
    for (int j = nDiff; j < m_qData[i].size(); j++)
    {
      if (m_qData[i][j] < fMin)
      {
        fMin = m_qData[i][j];
      }
      if (m_qData[i][j] > fMax)
      {
        fMax = m_qData[i][j];
      }
    }
  }
  if (fMax == fMin)
  {
    m_fYScale = 1;
    double nHeight = (rect.bottom - 40) / m_fYScale;
    fMin = fMin - nHeight / 2;
    fMax = fMax + nHeight / 2;
  }
  else
  {
    m_fYScale = (rect.bottom - 40) / (fMax - fMin);
  }

  // Prepare to draw axis labels
  RectF rectf;
  WCHAR buf[256];
  StringFormat format;
  format.SetAlignment(StringAlignmentCenter);
  format.SetLineAlignment(StringAlignmentCenter);

  // Draw Y-axis limit label
  swprintf(buf, L"%f", fMax);
  rectf = RectF(0, 10, 45, 20);
  buffer.DrawString(buf, -1, &font, rectf, &format, &brush);
  swprintf(buf, L"%f", fMin);
  rectf = RectF(0, rect.bottom - 40, 45, 20);
  buffer.DrawString(buf, -1, &font, rectf, &format, &brush);

  // Draw X-axis limit label
  swprintf(buf, L"%f", (double)nDiff / 100);
  rectf = RectF(50, rect.bottom - 20, 45, 20);
  buffer.DrawString(buf, -1, &font, rectf, &format, &brush);
  swprintf(buf, L"%f", (double)(nDiff + wSize) / 100);
  rectf = RectF(rect.right - 50, rect.bottom - 20, 45, 20);
  buffer.DrawString(buf, -1, &font, rectf, &format, &brush);

  // Draw cursor
  Pen cursor(Color(100, 100, 100));
  if ((m_nCursorX >= 50) && (m_nCursorX <= rect.right - 20) &&
      (m_nCursorY >= 20) && (m_nCursorY <= rect.bottom - 20))
  {
    buffer.DrawLine(&cursor, m_nCursorX, rect.bottom-20, m_nCursorX, 12);
    buffer.DrawLine(&cursor, 50, m_nCursorY, rect.right-20, m_nCursorY);

    // Draw Y cursor label
    swprintf(buf, L"%f",
        (double)(rect.bottom - m_nCursorY - 20) / (rect.bottom - 40) *
        (fMax - fMin) + fMin);
    rectf = RectF(0, m_nCursorY - 10, 45, 20);
    buffer.DrawString(buf, -1, &font, rectf, &format, &brush);

    // Draw X cursor label
    swprintf(buf, L"%f", ((m_nCursorX - 50) / m_fXScale + nDiff) / 100);
    rectf = RectF(m_nCursorX - 25, rect.bottom - 20, 50, 20);
    buffer.DrawString(buf, -1, &font, rectf, &format, &brush);
  }

  // Draw item
  Pen line(Color(0, 0, 255));
  for (int i = 0; i < m_qData.size(); i++)
  {
    if (m_qData[i].size() > 0)
    {
      UINT nInputs = m_pBlock->m_vInput.size();
      if (i < nInputs)
      {
        line.SetColor(Color(m_pBlock->m_vInput[i]->m_nColor));
      }
      else
      {
        line.SetColor(Color(m_pBlock->m_vOutput[i - nInputs]->m_nColor));
      }
      // Draw the signals
      for (int j = nDiff; j < m_qData[i].size() - 1; j++)
      {
        buffer.DrawLine(&line,
            (REAL)(50 + m_fXScale * (j - nDiff)),
            (REAL)(rect.bottom - 20 - m_fYScale * (m_qData[i][j] - fMin)),
            (REAL)(50 + m_fXScale * (j - nDiff + 1)),
            (REAL)(rect.bottom - 20 - m_fYScale * (m_qData[i][j + 1] - fMin)));
      }
    }
  }

  // Draw labels
  format.SetAlignment(StringAlignmentFar);
  for (int i = 0; i < m_qData.size(); i++)
  {
    wstring ws;
    rectf = RectF(rect.right - 200, 25 + 20 * i, 180, 20);

    // Setup color and convert strings
    if (m_qData[i].size() > 0)
    {
      UINT nInputs = m_pBlock->m_vInput.size();
      if (i < nInputs)
      {
        brush.SetColor(Color(m_pBlock->m_vInput[i]->m_nColor));
        ws = wstring(m_pBlock->m_vInput[i]->m_sName.begin(),
            m_pBlock->m_vInput[i]->m_sName.end());
      }
      else
      {
        brush.SetColor(Color(m_pBlock->m_vOutput[i - nInputs]->m_nColor));
        ws = wstring(m_pBlock->m_vOutput[i - nInputs]->m_sName.begin(),
            m_pBlock->m_vOutput[i - nInputs]->m_sName.end());
      }

      // Draw the signal labels
      buffer.DrawString(ws.c_str(), -1, &font, rectf, &format, &brush);
    }
  }

  // Draw trademark
  brush.SetColor(Color(0, 0, 0));
  rectf = RectF(rect.right - 200, 0, 190, 20);
  buffer.DrawString(L"(C) Synaptics INC.", -1, &font, rectf, &format, &brush);

  // Finish painting
  window.DrawImage(&bitmap, 0, 0);
  EndPaint(m_hWnd, &ps);
}