Ejemplo n.º 1
0
void *ChangeLineClearSize( LayerTypePtr Layer, LineTypePtr Line )
{
  int eax;
  int edx;
  int ebx;
  int esi;
  BDimension value = Absolute;
  if ( ( Line->Flags.f & 8224 ) != 32 || Line->Clearance == ( ( value < ( PCB->Bloat + 1 ) * 2 ? value : ( PCB->Bloat + 1 ) * 2 ) <= 0x989680 ? 10000000 : value < ( PCB->Bloat + 1 ) * 2 ? value : ( PCB->Bloat + 1 ) * 2 ) )
  {
  }
  AddObjectToClearSizeUndoList( 4, (void*)Layer, (void*)Line, (void*)Line );
  RestoreToPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line );
  EraseLine( Line );
  r_delete_entry( &Layer->line_tree, (int)( &Line->BoundingBox ) );
  Line->Clearance = value;
  if ( value == 0 )
  {
    Line->Flags.f &= -33;
    Line->Clearance = 1000;
  }
  SetLineBoundingBox( Line );
  r_insert_entry( &Layer->line_tree, (int)( &Line->BoundingBox ), 0 );
  ClearFromPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line );
  DrawLine( Layer, Line, 0 );
  return (void*)Line;
}
Ejemplo n.º 2
0
/**
 * Checks if the player have made some lines.
 */
void TetraminoesManager::InnerData::CheckLines() {
    int numLinesErased = 0;
    int accumPoints = 0;

    for (int i = 0; i < WORLD_HEIGHT; i++) {
        if (CheckLine(i)) {
            EraseLine(i);
            numLinesErased++;
            accumPoints += LINE_POINTS[level - 1];
        }
    }

    if (numLinesErased >= 4) {
        accumPoints *= 2;
    }

    lines += numLinesErased;
    score += accumPoints;

    if (lines > target) {
        level++;
        maxInterval = MAX_INTERVALS[level - 1];
        target += MAX_LINES[level - 1];
    }

    if (accumPoints > 0) {
        lineSound.Play();
        UpdateHud();
    } else if (Keyboard::IsKeyUp(Keyboard::X)) {
        fallSound.Play();
    } else {
        hitSound.Play();
    }
}
Ejemplo n.º 3
0
Archivo: insert.c Proyecto: thequux/pcb
/* ---------------------------------------------------------------------------
 * inserts a point into a line
 */
static void *
InsertPointIntoLine (LayerTypePtr Layer, LineTypePtr Line)
{
  LineTypePtr line;
  LocationType X, Y;

  if (((Line->Point1.X == InsertX) && (Line->Point1.Y == InsertY)) ||
      ((Line->Point2.X == InsertX) && (Line->Point2.Y == InsertY)))
    return (NULL);
  X = Line->Point2.X;
  Y = Line->Point2.Y;
  AddObjectToMoveUndoList (LINEPOINT_TYPE, Layer, Line, &Line->Point2,
			   InsertX - X, InsertY - Y);
  EraseLine (Line);
  r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
  Line->Point2.X = InsertX;
  Line->Point2.Y = InsertY;
  SetLineBoundingBox (Line);
  r_insert_entry (Layer->line_tree, (BoxTypePtr) Line, 0);
  DrawLine (Layer, Line, 0);
  /* we must create after playing with Line since creation may
   * invalidate the line pointer
   */
  if ((line = CreateDrawnLineOnLayer (Layer, InsertX, InsertY,
				      X, Y,
				      Line->Thickness, Line->Clearance,
				      Line->Flags)))
    {
      AddObjectToCreateUndoList (LINE_TYPE, Layer, line, line);
      DrawLine (Layer, line, 0);
      /* creation call adds it to the rtree */
    }
  Draw ();
  return (line);
}
Ejemplo n.º 4
0
void
EraseObject (int type, void *lptr, void *ptr)
{
  switch (type)
    {
    case VIA_TYPE:
    case PIN_TYPE:
      ErasePin ((PinType *) ptr);
      break;
    case TEXT_TYPE:
    case ELEMENTNAME_TYPE:
      EraseText ((LayerType *)lptr, (TextType *) ptr);
      break;
    case POLYGON_TYPE:
      ErasePolygon ((PolygonType *) ptr);
      break;
    case ELEMENT_TYPE:
      EraseElement ((ElementType *) ptr);
      break;
    case LINE_TYPE:
    case ELEMENTLINE_TYPE:
    case RATLINE_TYPE:
      EraseLine ((LineType *) ptr);
      break;
    case PAD_TYPE:
      ErasePad ((PadType *) ptr);
      break;
    case ARC_TYPE:
    case ELEMENTARC_TYPE:
      EraseArc ((ArcType *) ptr);
      break;
    default:
      Message ("hace: Internal ERROR, trying to erase an unknown type\n");
    }
}
Ejemplo n.º 5
0
	//函数功能:恢复线
	//参数:
	long CMapEditor10View::RecoverLinLBU(CPoint point)       
	{

		int linnum;
		RecoverLin(point,linnum);
		EraseLine(linnum);
		Invalidate();
		return 1;
	}
Ejemplo n.º 6
0
	//函数功能:删线
	//参数:
	long CMapEditor10View::DeleteLinLBU(CPoint point)       
	{

		CString str;
		int LineNum;
		FindNearLine(point,LineNum);
		EraseLine(LineNum);	 //图像中删除编号LineNum的线
		DelLine(LineNum);
		return 1;
	}
Ejemplo n.º 7
0
	//函数功能:移动线
	//参数:
	long CMapEditor10View::MoveLinLBD(CPoint point)       
	{
		int num;
		startPnt=point;	 //存储当前点为前一点
		FindNearLine(point,num);
		SelectLin(num);
		EraseLine(num);
		linToMove=num; //保存要移动的线号
		step=1;
		return 1;

	}
Ejemplo n.º 8
0
void *ChangeLineJoin( LayerTypePtr Layer, LineTypePtr Line )
{
  int esi;
  EraseLine( Line );
  AddObjectToClearPolyUndoList( 4, (void*)Layer, (void*)Line, (void*)Line, 0 );
  RestoreToPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line );
  AddObjectToFlagUndoList( 4, (void*)Layer, (void*)Line, (void*)Line );
  Line->Flags.f ^= 32;
  AddObjectToClearPolyUndoList( 4, (void*)Layer, (void*)Line, (void*)Line, 1 );
  ClearFromPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line );
  DrawLine( Layer, Line, 0 );
  return (void*)Line;
}
Ejemplo n.º 9
0
/* ---------------------------------------------------------------------------
 * removes a line from a layer 
 */
void *
RemoveLine (LayerTypePtr Layer, LineTypePtr Line)
{
  /* erase from screen */
  if (Layer->On)
    {
      EraseLine (Line);
      if (!Bulk)
	Draw ();
    }
  MoveObjectToRemoveUndoList (LINE_TYPE, Layer, Line, Line);
  return NULL;
}
Ejemplo n.º 10
0
/* ---------------------------------------------------------------------------
 * erases an element
 */
void
EraseElement (ElementType *Element)
{
  ELEMENTLINE_LOOP (Element);
  {
    EraseLine (line);
  }
  END_LOOP;
  ARC_LOOP (Element);
  {
    EraseArc (arc);
  }
  END_LOOP;
  EraseElementName (Element);
  EraseElementPinsAndPads (Element);
}
Ejemplo n.º 11
0
Archivo: clb.c Proyecto: mingpen/OpenNT
BOOL
RedrawVerticalLine(
    IN HDC hDC,
    IN LONG x,
    IN LPDRAW_ERASE_LINE DrawEraseLine
    )

/*++

Routine Description:

    RedrawVerticalLine erases the old line and redraws a new one at the
    supplied x position. It is merely a warpper for DrawLine and EraseLine.

Arguments:

    hDC             - Supplies a handle to the DC where the line should
                      be erased.
    x               - Supplies the new x coordinate where the line should
                      be drawn.
    DrawEraseLine   - Supplies a pointer to a DRAW_ERASE_LINE structure that
                      conatins the coordinates for the line to be erased.

Return Value:

    BOOL            - Returns TRUE if the line was succesfully erased.

--*/

{
    BOOL    Success;

    DbgHandleAssert( hDC );
    DbgPointerAssert( DrawEraseLine );


    DrawEraseLine->Draw.Src.x = x;
    DrawEraseLine->Draw.Dst.x = x;

    Success = EraseLine( hDC, DrawEraseLine );
    DbgAssert( Success );

    Success = DrawLine( hDC, DrawEraseLine );
    DbgAssert( Success );

    return Success;
}
Ejemplo n.º 12
0
/* ---------------------------------------------------------------------------
 * moves a line
 */
static void *
MoveLine (LayerTypePtr Layer, LineTypePtr Line)
{
  if (Layer->On)
    EraseLine (Line);
  RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
  r_delete_entry (Layer->line_tree, (BoxType *)Line);
  MOVE_LINE_LOWLEVEL (Line, DeltaX, DeltaY);
  r_insert_entry (Layer->line_tree, (BoxType *)Line, 0);
  ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
  if (Layer->On)
    {
      DrawLine (Layer, Line);
      Draw ();
    }
  return (Line);
}
Ejemplo n.º 13
0
/* ---------------------------------------------------------------------------
 * erase a ratline
 */
void
EraseRat (RatType *Rat)
{
  if (TEST_FLAG(VIAFLAG, Rat))
    {
      Coord w = Rat->Thickness;

      BoxType b;

      b.X1 = Rat->Point1.X - w * 2 - w / 2;
      b.X2 = Rat->Point1.X + w * 2 + w / 2;
      b.Y1 = Rat->Point1.Y - w * 2 - w / 2;
      b.Y2 = Rat->Point1.Y + w * 2 + w / 2;
      AddPart (&b);
    }
  else
    EraseLine ((LineType *)Rat);
}
Ejemplo n.º 14
0
/* Process the movement of one line. */
void TList::LineTick( HDC DC )
{
  EraseLine(DC, CurrentLine);
  if (ColorDuration < 0)   SelectNewColor();
  if (!IncrementCount)     SelectNewDeltaValues();
  AdjustX(X1,DeltaX1);  AdjustX(X2,DeltaX2);
  AdjustY(Y1,DeltaY1);  AdjustY(Y2,DeltaY2);

  Line[CurrentLine].LX1 = X1;
  Line[CurrentLine].LX2 = X2;
  Line[CurrentLine].LY1 = Y1;
  Line[CurrentLine].LY2 = Y2;
  Line[CurrentLine].Color = PenColor;

  DrawLine(DC, CurrentLine);
  CurrentLine++;
  if (CurrentLine >= MaxLines)  CurrentLine = 1;
  ColorDuration--;
  IncrementCount--;
};
Ejemplo n.º 15
0
void *ChangeLineSize( LayerTypePtr Layer, LineTypePtr Line )
{
  int eax;
  int ebx;
  int esi;
  int edi;
  BDimension value = Absolute;
  if ( value + -1 <= 0x98967f && Line->Thickness != value )
  {
    AddObjectToSizeUndoList( 4, (void*)Layer, (void*)Line, (void*)Line );
    EraseLine( Line );
    r_delete_entry( &Layer->line_tree, (int)( &Line->BoundingBox ) );
    RestoreToPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line );
    Line->Thickness = value;
    SetLineBoundingBox( Line );
    r_insert_entry( &Layer->line_tree, (int)( &Line->BoundingBox ), 0 );
    ClearFromPolygon( &PCB->Data, 4, (void*)Layer, (void*)Line );
    DrawLine( Layer, Line, 0 );
    return (void*)Line;
  }
}
Ejemplo n.º 16
0
/* ---------------------------------------------------------------------------
 * moves one end of a line
 */
static void *
MoveLinePoint (LayerTypePtr Layer, LineTypePtr Line, PointTypePtr Point)
{
  if (Layer)
    {
      if (Layer->On)
	EraseLine (Line);
      RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
      r_delete_entry (Layer->line_tree, &Line->BoundingBox);
      MOVE (Point->X, Point->Y, DeltaX, DeltaY);
      SetLineBoundingBox (Line);
      r_insert_entry (Layer->line_tree, &Line->BoundingBox, 0);
      ClearFromPolygon (PCB->Data, LINE_TYPE, Layer, Line);
      if (Layer->On)
	{
	  DrawLine (Layer, Line);
	  Draw ();
	}
      return (Line);
    }
  else				/* must be a rat */
    {
      if (PCB->RatOn)
	EraseRat ((RatTypePtr) Line);
      r_delete_entry (PCB->Data->rat_tree, &Line->BoundingBox);
      MOVE (Point->X, Point->Y, DeltaX, DeltaY);
      SetLineBoundingBox (Line);
      r_insert_entry (PCB->Data->rat_tree, &Line->BoundingBox, 0);
      if (PCB->RatOn)
	{
	  DrawRat ((RatTypePtr) Line);
	  Draw ();
	}
      return (Line);
    }
}
Ejemplo n.º 17
0
void DoRA_DecSlewMenu( int *menu )
{
   int      escape=0, acceptable=0, s[255], *p;
   double   oldRA, oldDec, Alt, Az, HA;
   long int X_Target, Y_Target;
   int      letter, firstxx, xx, yy, x=25; 
   int      w=TRACKINGDISPLAY+5, y=w+4+2*ShowXY, i, sign;
   double   temp, hr, min, sec;

   *menu = TrackingMenu;              
   while (!escape && !acceptable)
   {
      for (i=0;i<255;i++) s[i]=NULL;
      gotoxy(x,y); 
      for (i=y; i<25; i++) EraseLine(i);
      FrameScreen();
      gotoxy(x,y+0); printf("Enter coordinates to slew to...");
      gotoxy(x,y+1); printf("     (return to escape)");
      gotoxy(x,y+2); printf(" Enter RA: ");
      firstxx=wherex(); xx=firstxx; yy=wherey();
      p = s;
      do 
      {                                      // Continuously update coord's
         TrackingKeyboard(w,xx,yy,&letter);  // (runs until a key is hit).
         if (letter==BACKSPACE)              // If that key was backspace,
         {
            if (xx > firstxx)
            {
               *(--p) = NULL;                // delete last entry from string
               gotoxy(--xx,yy); 
               printf(" ");                  // and erase screen character.
            }
         }
         else                                // Otherwise,
         {
            *p++ = letter;                   // add that key to the string
            xx++;                            // and advance the screen cursor
         }
      } while (letter!=RETURN);
      p = s;
      RA.hour=ZERO; RA.minute=ZERO; RA.second=ZERO;
      escape = GetCoordinateFromString(s, &RA);
      if (escape) return;

      temp = RA.hour + (RA.minute + RA.second/SIXTY)/SIXTY;
      hr = _HOURS(temp);
      min = _MINUTES(temp);
      sec = _SECONDS(temp);

      for (i=0;i<255;i++) s[i]=NULL;
      gotoxy(x,y); 
      for (i=y; i<23; i++) EraseLine(i);
      gotoxy(x,y);   printf("Enter coordinates to slew to...");
      gotoxy(x,y+1); printf("     (return to escape)");
      gotoxy(x,y+2); printf("       RA: %2.0f:%02.0f:%02.0f", hr, min, sec);
      gotoxy(x,y+3); printf("Enter Dec: ");
      xx=wherex(); firstxx=xx; yy=wherey();
      p = s;
      do 
      {                                      // Continuously update coord's 
         TrackingKeyboard(w,xx,yy,&letter);  // (runs until a key is hit). 
         if (letter==BACKSPACE)              // If that key was backspace,
         {
            if (xx > firstxx)
            {
               *(--p) = NULL;                // delete last entry from string
               gotoxy(--xx,yy); printf(" "); // and erase screen character.
            }
         }
         else                                // Otherwise,
         {
            *p++ = letter;                   // add that key to the string
            ++xx;                            // and advance the screen cursor
         }
      } 
      while (letter!=RETURN);
      p = s;
      Dec.hour=ZERO; Dec.minute=ZERO; Dec.second=ZERO;
      GetSignFromString(s, &sign);
      escape = GetCoordinateFromString(s, &Dec);
      if (escape) return;

      oldRA = RA_Target;
      oldDec = DecTarget;
      RA_Target = RA.hour + (RA.minute + RA.second/SIXTY)/SIXTY;
      DecTarget = Dec.hour + (Dec.minute + Dec.second/SIXTY)/SIXTY;
      DecTarget *= sign;
      GetXY( RA_Target, DecTarget, &X_Target, &Y_Target );
      if ((pow(X_Target,2)+pow(Y_Target,2)) > 
                                 pow(MAXZENITHANGLE*STEPSPERDEGREE,2) )
      {
         escape = 0; acceptable=0;  // If user's requested coordinates would
         dX = 0; dY = 0;            // put the telescope too far over, user
         RA_Target = oldRA;         // is so informed and permitted to try
         DecTarget = oldDec;        // again.
         gotoxy(x,y); 
         for (i=y; i<25; i++) EraseLine(i);
         FrameScreen();
         gotoxy(10,y); 
         printf("     The values you typed will put ");
         printf("the telescope outside its");
         gotoxy(10,y+1); 
         printf("allowed bounds.  It is not allowed lower than a ");
         printf("%ld degree angle.", MAXZENITHANGLE);
         gotoxy(10,y+2);
         printf("               (press any key to continue)");
         xx=wherex(); yy=wherey();
         TrackingKeyboard(10,xx,yy,&letter); // waits for user to press a key
      }
      else 
      {
         acceptable=1;
         *menu=SlewingMenu;
      }
   }
   dX = X_Target - gX;
   dY = Y_Target - gY;
   RA_Orig = RA_Target;
   DecOrig = DecTarget;
   *menu=SlewingMenu;
}
Ejemplo n.º 18
0
	//函数功能:连接两条线
	//参数:线号1 2
	long CMapEditor10View::ConnectLins(int lin1,int lin2)  
	{
		int i=0;
		int j=0;
		int lin1num;
		int lin2num;
		double disX;
		double disY;
		CPoint temp;
		POINT Lin1[500];
		POINT Lin2[500];

		linnum1=SelectLinCon(lin1,Lin1);
		linnum2=SelectLinCon(lin2,Lin2);
		int resultType=HowToCon(Lin1,Lin2,linnum1-1,linnum2-1);
		if(linnum1==0 || linnum1==0)
			return 0;
		else
			switch(resultType)
		{
			case 0 :							//尾跟头连
				{
					for(i=0;i< linnum1;i++)
						linPnt[i]=Lin1[i];
					for(i=linnum1;i< linnum2+linnum1;i++)
					{
						linPnt[i]=Lin2[i-linnum1];
					}
				}
				break;	
			case 1 :							//尾跟尾连
				{
					for(i=0;i< linnum1;i++)
						linPnt[i]=Lin1[i];
					for(j=linnum1,i= linnum1+linnum2;i>=linnum1;i--,j++)
					{
						linPnt[j]=Lin2[i-linnum1-1];
					}
				}
				break;
			case 2 :							// 头跟头连
				{
					for(i=0;i< linnum1;i++)
						linPnt[i]=Lin1[linnum1-i-1];
					for(i=linnum1;i< linnum2+linnum1;i++)
					{
						linPnt[i]=Lin2[i-linnum1];
					}

				}
				break;
			case 3 :							// 头跟尾连
				{
					for(i=0;i< linnum1;i++)
						linPnt[i]=Lin1[linnum1-i-1];
					for(j=linnum1,i= linnum1+linnum2;i>=linnum1;i--,j++)
					{
						linPnt[j]=Lin2[i-linnum1-1];
					}

				}
				break;
			default:
				break;
		}
		LinPntNum=linnum1+linnum2;
		EraseLine(lin1);									//擦除两条线
		EraseLine(lin2);
		DelLine(lin1);								     //文件中删除两条线
		DelLine(lin2);
		WriteConLine();
		DrawConLine();
		firstlinnum=0;
		seclinnum=0;
		isfirst=0;
		issecond=0;
		LinPntNum=0;
		return 1;
	}
Ejemplo n.º 19
0
uint32_t ReadShellPrompt(int fd, char *buf, size_t len) {
	size_t total_len = 0;
	size_t rx_bytes;
	size_t i;
	char c;
	char t[2];
	t[1] = '\0';
	int8_t CurrCommandHistory = -1;
	char TmpBuf[MAX_CMD_LEN];
	uint32_t CursorPos = 0;
	
	bzero(TmpBuf, MAX_CMD_LEN);

	while ((receive(fd, &c, 1, &rx_bytes) == 0) && total_len < len-1) {
		if (rx_bytes == 0) {
			buf[0] = '\0';
			return(0);
		}
//		t[0] = c;
//		printf("$08x\n", t[0]);

		// backspace
		if (c == '\x7f') {
			if (CursorPos == total_len) {
				printf("\b\b\b   \b\b\b");
				total_len--;
				CursorPos--;
				continue;
			}
			for (i = CursorPos-1; i < total_len-1; i++) {
				buf[i] = buf[i+1];
			}
			total_len--;
			CursorPos--;
			EraseLine(0);
			PrintPrompt();
			buf[total_len] = '\0';
			printf("$s", buf);
			CursorLeft(total_len-CursorPos);
			continue;
		}

		// ctrl-c
		if (c == '\x03') {
			return(0);
		}

		// ctrl-e
		if (c == '\x05') {
			// move the cursor to the end
			EraseLine(0);
			PrintPrompt();
			buf[total_len] = '\0';
			printf("$s", buf);
			CursorPos = total_len;
			continue;
		}

		// ctrl-u
		if (c == '\x15') {
			EraseLine(0);
			PrintPrompt();
			total_len = 0;
			CursorPos = 0;
			continue;
		}

		// ctrl-d
		if (c == '\x04') {
			if (total_len > 0) {
				printf("\b\b  \b\b");
				continue;
			} else {
				printf("\b\b  \b\b");
				printf("exit  ");
				strcpy(buf, "exit");
				return(1);
			}
		}

		// escape codes
		if (c == '\x1b') {
			// receive the next char
			if (receive(fd, &c, 1, &rx_bytes) != 0) {
				buf[0] = '\0';
				return(0);
			}
			if (rx_bytes == 0) {
				buf[0] = '\0';
				return(0);
			}

			if (c == '\x5b') {
				// receive the next char
				if (receive(fd, &c, 1, &rx_bytes) != 0) {
					buf[0] = '\0';
					return(0);
				}
				if (rx_bytes == 0) {
					buf[0] = '\0';
					return(0);
				}

				if (c == '\x41') {
					// up arrow	
					// if there's no command history
					if (ENV.NumCommandHistory == 0) {
						EraseLine(0);
						PrintPrompt();
						buf[total_len] = '\0';
						printf("$s", buf);
						CursorPos = total_len;
						continue;
					}

					// if we're printing the first history buf,
					// save the current buf in case the user
					// arrow's back to it
					if (CurrCommandHistory == -1) {
						buf[total_len] = '\0';
						strcpy(TmpBuf, buf);
					}
					CurrCommandHistory++;
					if (CurrCommandHistory >= ENV.NumCommandHistory) {
						CurrCommandHistory = ENV.NumCommandHistory-1;
					}
					// print the next command in the history buf
					EraseLine(0);
					PrintPrompt();
					strcpy(buf, ENV.CommandHistory[CurrCommandHistory]);
					total_len = strlen(ENV.CommandHistory[CurrCommandHistory]);
					CursorPos = total_len;
					printf("$s", ENV.CommandHistory[CurrCommandHistory]);
					continue;
				} else if (c == '\x42') {
					// down arrow	
					if (CurrCommandHistory == -1) {
						// nothing to do
						EraseLine(0);
						PrintPrompt();
						buf[total_len] = '\0';
						printf("$s", buf);
						continue;
					}

					// see if we're at the first command in the history
					if (CurrCommandHistory == 0) {
						// go back to the user's original command
						EraseLine(0);
						PrintPrompt();
						strcpy(buf, TmpBuf);
						total_len = strlen(buf);
						CursorPos = total_len;
						printf("$s", buf);
						CurrCommandHistory = -1;
						continue;
					}

					// print the next command in the history
					CurrCommandHistory--;
					EraseLine(0);
					PrintPrompt();
					strcpy(buf, ENV.CommandHistory[CurrCommandHistory]);
					total_len = strlen(ENV.CommandHistory[CurrCommandHistory]);
					CursorPos = total_len;
					printf("$s", ENV.CommandHistory[CurrCommandHistory]);
					continue;

				} else if (c == '\x43') {
					// right arrow	
					if (CursorPos == total_len) {
						// nothing to do but remove the arrow control chars
						EraseLine(0);
						PrintPrompt();
						buf[total_len] = '\0';
						printf("$s", buf);
						continue;
					}

					// not at the end of the line, so move the cursor
					// right one character
					CursorPos++;
					EraseLine(0);
					PrintPrompt();
					buf[total_len] = '\0';
					printf("$s", buf);
					if (total_len != CursorPos) {
						CursorLeft(total_len-CursorPos);
					}
					continue;
				} else if (c == '\x44') {
					// left arrow	
					if (CursorPos == 0) {
						// nothing to do, re-print the line (to remove the control chars)
						EraseLine(0);
						PrintPrompt();
						buf[total_len] = '\0';
						printf("$s", buf);
						CursorLeft(total_len);
						continue;
					}
					// not at the beginning of the line, so move the cursor
					// left one character
					CursorPos--;
					EraseLine(0);
					PrintPrompt();
					buf[total_len] = '\0';
					printf("$s", buf);
					CursorLeft(total_len-CursorPos);
					continue;
				}
			}
		}

		if (c == '\r') {
			buf[CursorPos] = '\0';
			break;
		}
		if (c == '\n') {
			// receive the corresponding '\r'
			if (receive(fd, &c, 1, &rx_bytes) != 0) {
				buf[0] = '\0';
				return(0);
			}
			if (rx_bytes == 0) {
				buf[0] = '\0';
				return(0);
			}
			if (c != '\r') {
				buf[0] = '\0';
				return(0);
			}
			buf[CursorPos] = '\0';
//			EraseToEOL();
			break;
		}
		if (CursorPos == total_len) {
			buf[total_len++] = c;
			CursorPos++;
		} else {
			buf[CursorPos++] = c;
		}
		
	}
	if (rx_bytes == 0) {
		buf[0] = '\0';
		return(0);
	}
	buf[total_len] = '\0';

	return(total_len);
}
Ejemplo n.º 20
0
static void *
MoveLineToLayer (LayerType *Layer, LineType *Line)
{
  struct via_info info;
  BoxType sb;
  LineTypePtr newone;
  void *ptr1, *ptr2, *ptr3;

  if (TEST_FLAG (LOCKFLAG, Line))
    {
      Message (_("Sorry, the object is locked\n"));
      return NULL;
    }
  if (Dest == Layer && Layer->On)
    {
      DrawLine (Layer, Line);
      Draw ();
    }
  if (((long int) Dest == -1) || Dest == Layer)
    return (Line);

  AddObjectToMoveToLayerUndoList (LINE_TYPE, Layer, Line, Line);
  if (Layer->On)
    EraseLine (Line);
  RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
  newone = (LineTypePtr)MoveLineToLayerLowLevel (Layer, Line, Dest);
  Line = NULL;
  ClearFromPolygon (PCB->Data, LINE_TYPE, Dest, newone);
  if (Dest->On)
    DrawLine (Dest, newone);
  Draw ();
  if (!PCB->ViaOn || MoreToCome ||
      GetLayerGroupNumberByPointer (Layer) ==
      GetLayerGroupNumberByPointer (Dest) ||
      TEST_SILK_LAYER(Layer) ||
      TEST_SILK_LAYER(Dest))
    return (newone);
  /* consider via at Point1 */
  sb.X1 = newone->Point1.X - newone->Thickness / 2;
  sb.X2 = newone->Point1.X + newone->Thickness / 2;
  sb.Y1 = newone->Point1.Y - newone->Thickness / 2;
  sb.Y2 = newone->Point1.Y + newone->Thickness / 2;
  if ((SearchObjectByLocation (PIN_TYPES, &ptr1, &ptr2, &ptr3,
			       newone->Point1.X, newone->Point1.Y,
			       Settings.ViaThickness / 2) == NO_TYPE))
    {
      info.X = newone->Point1.X;
      info.Y = newone->Point1.Y;
      if (setjmp (info.env) == 0)
	r_search (Layer->line_tree, &sb, NULL, moveline_callback, &info);
    }
  /* consider via at Point2 */
  sb.X1 = newone->Point2.X - newone->Thickness / 2;
  sb.X2 = newone->Point2.X + newone->Thickness / 2;
  sb.Y1 = newone->Point2.Y - newone->Thickness / 2;
  sb.Y2 = newone->Point2.Y + newone->Thickness / 2;
  if ((SearchObjectByLocation (PIN_TYPES, &ptr1, &ptr2, &ptr3,
			       newone->Point2.X, newone->Point2.Y,
			       Settings.ViaThickness / 2) == NO_TYPE))
    {
      info.X = newone->Point2.X;
      info.Y = newone->Point2.Y;
      if (setjmp (info.env) == 0)
	r_search (Layer->line_tree, &sb, NULL, moveline_callback, &info);
    }
  Draw ();
  return (newone);
}
Ejemplo n.º 21
0
int parseCode() {
	size_t l = strlen(engInfo.code);
	int i = 1, j = 1;	// used for generically collecting values using sscanf_s()
	switch (engInfo.code[0]) {
		case '[':
			switch (engInfo.code[l-1]) {
				case '[':
					return PARTIAL;
				case 'A': // move cursor up
					sscanf_s(engInfo.code, "[%dA", &i);
					MoveCursor(-1, 0);
					return VALID;
				case 'B': // move cursor down
					sscanf_s(engInfo.code, "[%dB", &i);
					MoveCursor(i, 0);
					return VALID;
				case 'C': // move cursor right
					sscanf_s(engInfo.code, "[%dC", &i);
					MoveCursor(0, i);
					return VALID;
				case 'D': // move cursor left
					sscanf_s(engInfo.code, "[%dD", &i);
					MoveCursor(0, -i);
					return VALID;
				case 'H': // set cursor position
					sscanf_s(engInfo.code, "[%d;%DH", &i, &j);
					SetCursorPosition(i - 1, j - 1);
					return VALID;
				case 'f': // set cursor position
					sscanf_s(engInfo.code, "[%d;%df", &i, &j);
					SetCursorPosition(i - 1, j - 1);
					return VALID;
				case 'K':
					switch (engInfo.code[1]) {
						case 'K': // erase from cursor to end of line
							EraseFromCursorToEOL();
							return VALID;
						case '1': // erase from start of line to cursor
							EraseFromSOLToCursor();
							return VALID;
						case '2': // erase entire line
							EraseLine();
							return VALID;
					}
					break;
				case 'J':
					switch (engInfo.code[1]) {
						case 'J':
							EraseFromCursorToEOS();
							return VALID;
						case '1':
							EraseFromSOSToCursor();
							return VALID;
						case '2':
							EraseEntireScreen();
							return VALID;
					}
					break;
				case 'm':
					switch (engInfo.code[1]) {
						case 'm': // clear format
							SetFormat(FORMAT_BOLD | FORMAT_UL | FORMAT_INV, FALSE);
							return VALID;
						case '1': // set bold
							SetFormat(FORMAT_BOLD, TRUE);
							return VALID;
						case '4': // set underline
							SetFormat(FORMAT_UL, TRUE);
							return VALID;
						case '7': // set invert
							SetFormat(FORMAT_INV, TRUE);
							return VALID;
						default:
							return INVALID;
					}
					return INVALID;
				case 'h':
				case 'l':
					switch (engInfo.code[l-2]) {
						case 1:
							//setCursorKeyMode(engInfo.code[l-1] == 'h');
							return VALID;
						case 4:
							//setSlowScroll(engInfo.code[l-1] == 'h');
							return VALID;
						case 5:
							//setReverseVideo(engInfo.code[l-1] == 'h');
							return VALID;
						case 6:
							//setOriginMode(engInfo.code[l-1] == 'h');
							return VALID;
						case 7:
							//setAutoWrapMode(engInfo.code[l-1] == 'h');
							return VALID;
						case 0:	// 20
							//setNewLineMode(engInfo.code[l-1] == 'h');
							return VALID;
						default:
							return INVALID;
					}
				case 'r':
					sscanf_s(engInfo.code, "[%d;%dr", &i, &j);
					SetScrollingRegion(i, j);
					return VALID;
				case 'g':
					switch (engInfo.code[1]) {
						case 'g':
							//clearTabAtCurrentColumn();
							return VALID;
						case '0':
							//clearTabAtCurrentColumn();
							return VALID;
						case '3':
							//clearAllTabs();
							return VALID;
					}
					break;

				case 'n':
					switch (engInfo.code[1]) {
						case '6':
							//PrintString(ConstructCursorPositionReport());
							return VALID;
						case '5':
							//PrintString(ConstructStatusReport());
							return VALID;
					}
					break;
			}
			return PARTIAL;
		case 'D':
			//index();
			return VALID;
		case 'E':
			NewLine();
			return VALID;
		case 'M':
			//reverseIndex();
			return VALID;
		case '7':
			//saveCursorAndAttributes();
			return VALID;
		case '8':
			//restoreCursorAndAttributes();
			return VALID;
		case '#':
			if (l > 1) {
				switch (engInfo.code[1]) {
					case '2':
						//doubleHeightTopHalf();
						return VALID;
					case '4':
						//doubleHeightBottomHalf();
						return VALID;
					case '5':
						SingleWidthLine();
						return VALID;
					case '7':
						DoubleWidthLine();
						return VALID;
					default:
						return INVALID;
				}
			}
			return PARTIAL;
		case '=':
			//setApplicationKeypadMode();
			return VALID;
		case '>':
			//resetApplicationkeypadMode();
			return VALID;
		case 'H':
			//setTabAtCurrentColumn();
			return VALID;
		default:
			if (isalpha(engInfo.code[l-1]))
				return INVALID;
	}
	return PARTIAL;
}