예제 #1
0
파일: caret.c 프로젝트: NVIDIA/winex_lgpl
void ME_LButtonDown(ME_TextEditor *editor, int x, int y)
{
  ME_Cursor tmp_cursor;
  int is_selection = 0;
  
  editor->nUDArrowX = -1;
  
  y += ME_GetYScrollPos(editor);

  tmp_cursor = editor->pCursors[0];
  is_selection = ME_IsSelection(editor);

  ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd);
  
  if (GetKeyState(VK_SHIFT)>=0)
  {
    editor->pCursors[1] = editor->pCursors[0];
  }
  else
  {
    if (!is_selection) {
      editor->pCursors[1] = tmp_cursor;
      is_selection = 1;
    }
  }
  ME_InvalidateSelection(editor);
  HideCaret(editor->hWnd);
  ME_MoveCaret(editor);
  ShowCaret(editor->hWnd);
  ME_ClearTempStyle(editor);
  ME_SendSelChange(editor);
}
예제 #2
0
void ME_MouseMove(ME_TextEditor *editor, int x, int y)
{
  ME_Cursor tmp_cursor;
  
  y += ME_GetYScrollPos(editor);

  tmp_cursor = editor->pCursors[0];
  /* FIXME: do something with the return value of ME_FindPixelPos */
  if (!editor->linesel)
    ME_FindPixelPos(editor, x, y, &tmp_cursor, &editor->bCaretAtEnd);
  else ME_FindPixelPos(editor, (y > editor->sely) * editor->rcFormat.right, y, &tmp_cursor, &editor->bCaretAtEnd);

  if (!memcmp(&tmp_cursor, editor->pCursors, sizeof(tmp_cursor)))
    return;

  ME_InvalidateSelection(editor);
  if (!editor->linesel)
    editor->pCursors[0] = tmp_cursor;
  else if (!memcmp(&tmp_cursor, editor->pCursors+2, sizeof(tmp_cursor)) ||
           !memcmp(&tmp_cursor, editor->pCursors+3, sizeof(tmp_cursor)))
  {
    editor->pCursors[0] = editor->pCursors[2];
    editor->pCursors[1] = editor->pCursors[3];
  }
  else if (y < editor->sely)
  {
    editor->pCursors[0] = tmp_cursor;
    editor->pCursors[1] = editor->pCursors[2];
  }
  else
  {
    editor->pCursors[0] = tmp_cursor;
    editor->pCursors[1] = editor->pCursors[3];
  }

  HideCaret(editor->hWnd);
  ME_MoveCaret(editor);
  ME_InvalidateSelection(editor);
  ShowCaret(editor->hWnd);
  ME_SendSelChange(editor);
}
예제 #3
0
파일: caret.c 프로젝트: NVIDIA/winex_lgpl
void ME_MouseMove(ME_TextEditor *editor, int x, int y)
{
  ME_Cursor tmp_cursor;
  
  y += ME_GetYScrollPos(editor);

  tmp_cursor = editor->pCursors[0];
  /* FIXME: do something with the return value of ME_FindPixelPos */
  ME_FindPixelPos(editor, x, y, &tmp_cursor, &editor->bCaretAtEnd);
  
  if (tmp_cursor.pRun == editor->pCursors[0].pRun && 
      tmp_cursor.nOffset == editor->pCursors[0].nOffset)
    return;
  
  ME_InvalidateSelection(editor);
  editor->pCursors[0] = tmp_cursor;
  HideCaret(editor->hWnd);
  ME_MoveCaret(editor);
  ME_InvalidateSelection(editor);
  ShowCaret(editor->hWnd);
  ME_SendSelChange(editor);
}
예제 #4
0
void ME_ShowCaret(ME_TextEditor *ed)
{
  ME_MoveCaret(ed);
  if(ed->bHaveFocus && !ME_IsSelection(ed))
    ShowCaret(ed->hWnd);
}
예제 #5
0
파일: caret.c 프로젝트: AmesianX/wine
void ME_ShowCaret(ME_TextEditor *ed)
{
  ME_MoveCaret(ed);
  if(ed->bHaveFocus && !ME_IsSelection(ed))
    ITextHost_TxShowCaret(ed->texthost, TRUE);
}
예제 #6
0
void ME_LButtonDown(ME_TextEditor *editor, int x, int y)
{
  ME_Cursor tmp_cursor;
  int is_selection = 0;
  
  editor->nUDArrowX = -1;
  
  y += ME_GetYScrollPos(editor);

  tmp_cursor = editor->pCursors[0];
  is_selection = ME_IsSelection(editor);

  if (x >= editor->selofs)
  {
    ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd);
    if (GetKeyState(VK_SHIFT)>=0)
    {
      editor->pCursors[1] = editor->pCursors[0];
    }
    else if (!is_selection) {
      editor->pCursors[1] = tmp_cursor;
      is_selection = 1;
    }

    ME_InvalidateSelection(editor);
    HideCaret(editor->hWnd);
    ME_MoveCaret(editor);
    ShowCaret(editor->hWnd);
    ME_ClearTempStyle(editor);
    ME_SendSelChange(editor);
  }
  else
  {
    ME_DisplayItem *pRow;

    editor->linesel = 1;
    editor->sely = y;
    /* Set pCursors[0] to beginning of line */
    ME_FindPixelPos(editor, x, y, &editor->pCursors[1], &editor->bCaretAtEnd);
    /* Set pCursors[1] to end of line */
    pRow = ME_FindItemFwd(editor->pCursors[1].pRun, diStartRowOrParagraphOrEnd);
    assert(pRow);
    /* pCursor[0] is the position where the cursor will be drawn,
     * pCursor[1] is the other end of the selection range
     * pCursor[2] and [3] are backups of [0] and [1] so I
     * don't have to look them up again
     */

    if (pRow->type == diStartRow) {
      /* FIXME WTF was I thinking about here ? */
      ME_DisplayItem *pRun = ME_FindItemFwd(pRow, diRun);
      assert(pRun);
      editor->pCursors[0].pRun = pRun;
      editor->pCursors[0].nOffset = 0;
      editor->bCaretAtEnd = 1;
    } else {
      editor->pCursors[0].pRun = ME_FindItemBack(pRow, diRun);
      assert(editor->pCursors[0].pRun && editor->pCursors[0].pRun->member.run.nFlags & MERF_ENDPARA);
      editor->pCursors[0].nOffset = 0;
      editor->bCaretAtEnd = 0;
    }
    editor->pCursors[2] = editor->pCursors[0];
    editor->pCursors[3] = editor->pCursors[1];
    ME_InvalidateSelection(editor);
    HideCaret(editor->hWnd);
    ME_MoveCaret(editor);
    ShowCaret(editor->hWnd);
    ME_ClearTempStyle(editor);
    ME_SendSelChange(editor);
  }
}
예제 #7
0
void ME_ShowCaret(ME_TextEditor *ed)
{
  ME_MoveCaret(ed);
  if(ed->bHaveFocus)
    ShowCaret(ed->hWnd);
}
예제 #8
0
파일: caret.c 프로젝트: NVIDIA/winex_lgpl
void ME_ShowCaret(ME_TextEditor *ed)
{
  ME_MoveCaret(ed);
  ShowCaret(ed->hWnd);
}
예제 #9
0
파일: paint.c 프로젝트: howard5888/wineT
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, RECT *rcUpdate) {
  ME_DisplayItem *item;
  ME_Context c;
  int yoffset;

  editor->nSequence++;
  yoffset = ME_GetYScrollPos(editor);
  ME_InitContext(&c, editor, hDC);
  SetBkMode(hDC, TRANSPARENT);
  ME_MoveCaret(editor);
  item = editor->pBuffer->pFirst->next;
  c.pt.y -= yoffset;
  while(item != editor->pBuffer->pLast) {
    int ye;
    assert(item->type == diParagraph);
    ye = c.pt.y + item->member.para.nHeight;
    if (!bOnlyNew || (item->member.para.nFlags & MEPF_REPAINT))
    {
      BOOL bPaint = (rcUpdate == NULL);
      if (rcUpdate)
        bPaint = c.pt.y<rcUpdate->bottom && 
          c.pt.y+item->member.para.nHeight>rcUpdate->top;
      if (bPaint)
      {
        ME_DrawParagraph(&c, item);
        if (!rcUpdate || (rcUpdate->top<=c.pt.y && rcUpdate->bottom>=ye))
          item->member.para.nFlags &= ~MEPF_REPAINT;
      }
    }
    c.pt.y = ye;
    item = item->member.para.next_para;
  }
  if (c.pt.y<c.rcView.bottom) {
    RECT rc;
    int xs = c.rcView.left, xe = c.rcView.right;
    int ys = c.pt.y, ye = c.rcView.bottom;
    
    if (bOnlyNew)
    {
      int y1 = editor->nTotalLength-yoffset, y2 = editor->nLastTotalLength-yoffset;
      if (y1<y2)
        ys = y1, ye = y2+1;
      else
        ys = ye;
    }
    
    if (rcUpdate && ys!=ye)
    {
      xs = rcUpdate->left, xe = rcUpdate->right;
      if (rcUpdate->top > ys)
        ys = rcUpdate->top;
      if (rcUpdate->bottom < ye)
        ye = rcUpdate->bottom;
    }

    if (ye>ys) {
      rc.left = xs;
      rc.top = ys;
      rc.right = xe;
      rc.bottom = ye;
      FillRect(hDC, &rc, c.editor->hbrBackground);
    }
    if (ys == c.pt.y) /* don't overwrite the top bar */
      ys++;
  }
  if (editor->nTotalLength != editor->nLastTotalLength)
    ME_SendRequestResize(editor, FALSE);
  editor->nLastTotalLength = editor->nTotalLength;
  ME_DestroyContext(&c);
}