Esempio n. 1
0
int EBuffer::BlockUnTab() {
    EPoint B, E;
    ELine *L;
    int O, C;

    AutoExtend = 0;
    if (CheckBlock() == 0) return 0;
    if (RCount <= 0) return 0;
    B = BB;
    E = BE;
    Draw(B.Row, E.Row);
    for (int i = B.Row; i < E.Row; i++) {
        L = RLine(i);
        O = 0;
        C = 0;
        while (O < L->Count) {
            if (L->Chars[O] == '\t') {
                C = NextTab(C, BFI(this, BFI_TabSize));

                if (DelChars(i, O, 1) != 1)
                    return 0;
                if (InsChars(i, O, C - O, 0) != 1)
                    return 0;
                O = C;
            } else {
                O++;
                C++;
            }
        }
    }
    return 1;
}
Esempio n. 2
0
int EBuffer::MoveFirstNonWhite() {
    int C = 0, P = 0;
    PELine L = VLine(CP.Row);

    while (C < L->Count) {
        if (L->Chars[C] == ' ') P++;
        else if (L->Chars[C] == 9) P = NextTab(P, BFI(this, BFI_TabSize));
        else break;
        C++;
    }
    if (SetPos(P, CP.Row) == 0) return 0;
    return 1;
}
Esempio n. 3
0
Widget* MultiTabs::ClickUp(const Point2i &mousePosition, uint button)
{
  if (tabs.size() != 1) {

    Rectanglei rect_header(position.x, position.y,
                           size.x, prev_tab_bt->GetSizeY());

    if (rect_header.Contains(mousePosition)) {
      if (button == SDL_BUTTON_WHEELDOWN) {
        PrevTab();

      } else if (button == SDL_BUTTON_WHEELUP) {
        NextTab();

      } else {
        // Either Left, Middle or Right buttons.
        if (prev_tab_bt->Contains(mousePosition)) {
          PrevTab();
        } else if (next_tab_bt->Contains(mousePosition)) {
          NextTab();
        } else if (nb_visible_tabs > 1) {
          uint clicked_tab = (mousePosition.x - prev_tab_bt->GetPositionX()
                              - prev_tab_bt->GetSizeX() - 5)
                           / tab_header_width + first_tab;
          SelectTab(clicked_tab);
        }
      }

      return this;
    }
  }

  if (!tabs.empty())
    return tabs[current_tab].box->ClickUp(mousePosition, button);

  return NULL;
}
Esempio n. 4
0
bool iCastleView::OnKeyDown(sint32 key)
{
	if (key == KEY_UP || key == KEY_DOWN) {
		if ( m_curTab == CVT_CONSTRUCT) {
			iCnstTab* pCnstTab = (iCnstTab*)m_pChilds[CVT_CONSTRUCT];
			if (key == KEY_UP) pCnstTab->CnstList()->SelPrev();
			else if (key == KEY_DOWN) pCnstTab->CnstList()->SelNext();
		}
	} else if (key == KEY_LEFT){
		PrevTab();
	} else if (key == KEY_RIGHT){
		NextTab();
	} else {
		return false;
	}
	return true;
}
Esempio n. 5
0
bool MultiTabs::SendKey(const SDL_keysym& key)
{
  if (tabs.empty())
    return false;

  if (SDL_GetModState()&(KMOD_CTRL|KMOD_META)) {
    switch (key.sym) {
    case SDLK_PAGEUP:
      PrevTab();
      return true;
    case SDLK_PAGEDOWN:
      NextTab();
      return true;
    default:
      break;
    }
  }

  return tabs[current_tab].box->SendKey(key);
}
Esempio n. 6
0
int EBuffer::InsertSpacesToTab(int TSize) {
    int P = CP.Col, P1;

    if (BFI(this, BFI_InsertKillBlock) == 1)
        if (CheckBlock() == 1)
            if (BlockKill() == 0)
                return 0;

    if (TSize <= 0)
        TSize = BFI(this, BFI_TabSize);

    P1 = NextTab(P, TSize);
    if (BFI(this, BFI_Insert) == 0) {
        if (CP.Col < LineLen())
            if (DelText(VToR(CP.Row), CP.Col, P1 - P) == 0) return 0;
    }
    if (InsText(VToR(CP.Row), CP.Col, P1 - P, 0) == 0) return 0;
    if (SetPos(P1, CP.Row) == 0) return 0;
    return 1;
}
Esempio n. 7
0
char* wxTextPrintout::PlotLine(wxDC *dc,
			       float x0, float y0, float w, float h, 
			       float *y,
			       char *StillToPrint,
			       int PrintIt)
{
  if (!StillToPrint)
    {
      *y=-1.0f;
      return 0;
    }
  // buffer to print currenly
  char tmp[2048];
  tmp[0]=' ';
  tmp[1]=0;
  // number of chars to print
  int numchars;
  // size of message
  float tw,th,x;
  // chck if we are stil within range
  if (*y>y0+h)
    {
      *y=-1.0f;
      // size is to big
      return StillToPrint;
    }
  // now find out what to print
  x=0.0f;
  int quit=0;
  int base=0;
  tw=0.0f;
  th=0.0f;
  // tabcounter
  int tabcount=0;
  for (numchars=0;numchars<2048;numchars++)
    {
      // fill in Buffer
      char c=StillToPrint[numchars];
      switch (c)
	{
	case '\n': // newline
	  // ignore this character
	  numchars++;
	  quit=1;
	  break;
	case '\t': // Tabulated
	  // print text first
	  if (PrintIt) 
	    { 
	      // draw plot
	      dc->DrawText(tmp,x0+x,*y); 
	    }
	  // we are at the next-tab-count
	  tabcount++;
	  // get extent
	  dc->GetTextExtent(tmp,&tw,&th);
	  // calculate new start-position
	  x=x+tw;
	  // and now get next tab
	  NextTab(&x,tabcount);
	  // empty Buffer
	  tmp[0]=' ';
	  tmp[1]=0;
	  base=numchars+1;
	  break;
	default:
	  if (!iscntrl(c))
	    {
	      // copy characters
	      tmp[numchars-base]=c;
	      tmp[numchars-base+1]=0;
	      // get size
	      dc->GetTextExtent(tmp,&tw,&th);
	      if (x+tw>w)
		{
		  numchars--;
		  tmp[numchars-base]=0;
		  quit=1;
		}
	    }
	  break;
	}
      if (quit) { break; }
    }
  // get size
  dc->GetTextExtent(tmp,&tw,&th);
  // does line still fit on Screen?
  StillToPrint=&StillToPrint[numchars];
  // draw text
  if (PrintIt) 
    { dc->DrawText(tmp,x0+x,*y); }
  // calculate new coordinate
  *y+=int(th);
  // check what to return
  if (StillToPrint[0]==0) { return 0;}
  return StillToPrint;
}
Esempio n. 8
0
int EBuffer::MoveNextTab() {
    int P = CP.Col;

    P = NextTab(P, BFI(this, BFI_TabSize));
    return SetPos(P, CP.Row);
}
Esempio n. 9
0
int EBuffer::BlockEnTab() {
    EPoint B, E;
    ELine *L;
    int O, C, O1, C1;
    char tab = '\t';

    AutoExtend = 0;
    if (CheckBlock() == 0) return 0;
    if (RCount <= 0) return 0;
    B = BB;
    E = BE;
    Draw(B.Row, E.Row);
    for (int i = B.Row; i < E.Row; i++) {
        L = RLine(i);
        O = C = 0;
        O1 = C1 = 0;
        while (O < L->Count) {
            if (L->Chars[O] == '\t') { // see if there are spaces to remove
                int C2 = NextTab(C, BFI(this, BFI_TabSize));
                int N = BFI(this, BFI_TabSize) - (C2 - C);
                if (O - O1 < N)
                    N = O - O1;
                if (N > 0) {
                    if (DelChars(i, O - N, N) != 1)
                        return 0;
                    O -= N;
                    C = C2;
                    O++;
                    C1 = C;
                    O1 = O;
                } else {
                    O++;
                    C = C2;
                    O1 = O;
                    C1 = C;
                }
            } else if (L->Chars[O] != ' ') { // nope, cannot put tab here
                O++;
                C++;
                C1 = C;
                O1 = O;
            } else if (((C % BFI(this, BFI_TabSize)) == (BFI(this, BFI_TabSize) - 1)) &&
                       (C - C1 > 0))
            { // reached a tab and can put one
                int N = BFI(this, BFI_TabSize);
                if (O - O1 + 1 < N) {
                    N = O - O1 + 1;
                } else if (O - O1 + 1 > N) {
                    O1 = O - N + 1;
                }
                if (DelChars(i, O1, N) != 1)
                    return 0;
                if (InsChars(i, O1, 1, &tab) != 1)
                    return 0;
                O1++;
                O = O1;
                C++;
                C1 = C;
            } else {
                O++;
                C++;
            }
        }
    }
    return 1;
}