コード例 #1
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveEol( LPCLASSDATA lpcd )
{
	/*
	 *	Are we already there?
	 */
	if ( lpcd->ptCaretPos.x < GETLINE( lpcd )->nLength )
	{
		/*
		 *	No, move to the end.
		 */
		lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;

		/*
		 *	Save this position.
		 */
		lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );
	}

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
コード例 #2
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveUp( LPCLASSDATA lpcd )
{
	/*
	 *	Caret at the first line?
	 */
	if ( lpcd->ptCaretPos.y > 0 )
        {
		/*
		 *	Fast scrolling?
		 */
		if ( Parser->bFastScroll && lpcd->bRepeatMode )
		{
			/* 
			 *	Are we at the top of the view?
			 */
			if ( lpcd->ptCaretPos.y == lpcd->ptViewPos.y )
				/*
				 *	Setup new position.
				 */
				lpcd->ptCaretPos.y = max( lpcd->ptCaretPos.y - 2, 0 );
			else
				/*
				 *	One line up.
				 */
				 lpcd->ptCaretPos.y--;
		}
		else
			/*
			 *	Go one up.
			 */
			lpcd->ptCaretPos.y--;

                /*
		 *	Try to locate the caret as close to the
		 *	last column position as possible since
                 *	the user changed the column.
		 */
		lpcd->ptCaretPos.x = GetTextOffset( lpcd,  lpcd->nLastColumnPos );

                /*
		 *	Are we passed the end?
		 */
                if ( lpcd->ptCaretPos.x > GETLINE( lpcd )->nLength )
	                /*
			 *	Set us at the end.
			 */
			lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
	}

        /*
	 *	Make sure the care is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
	 */
        UpdateCaret( lpcd );
}
コード例 #3
0
//DEFINE Function   
void DEFINE()
{
	int LEVEL,i=0,j=0,k=0;
        char param[3][9];
        char s[3];
        strcpy(s,"123");
 
        strcpy(mynamtab[namcount].name,label);		//enter Macro name in NAMTAB
        mynamtab[namcount].start=defcount;		//enter starting pointer 
        strcpy(mydeftab[defcount].macroline,line);	//enter the line in the deftab which the starting pointer is pointing
      
        while(operand[i]!='\0')	//while operand is there
        {
        	if(operand[i]!=',')
                	param[j][k++]=operand[i];
                else
                {
                	param[j++][k]='\0';
                        k=0;
                }
                i++;
        }//end while
        param[j][k]='\0';
                             
        LEVEL=1;
        //for nested macro
        while(LEVEL>0)
        	{
                	GETLINE();
           		if(operand[0]!='\0')	//if operand is there
             		{
            			for(i=0;i<3;i++)
			        {
			        	if(!strcmp(operand,param[i]))
				        {
						operand[0]='?';		//substituting the positional parameter
            					operand[1]=s[i];
            					operand[2]='\0';
             				}//end if
             			}//end for
             		}//end if
           		if(!strcmp(opcode,"MACRO"))
            			LEVEL++;
           		else if(!strcmp(opcode,"MEND"))
            			LEVEL--;

            		strcpy(mydeftab[defcount].macroline,opcode);	//copy the opcode in deftab
            		if(operand[0]!='\0')
	            	{
		            strcat(mydeftab[defcount].macroline," ");	//copy the operand in deftab
        		    strcat(mydeftab[defcount].macroline,operand);
        		    strcat(mydeftab[defcount].macroline,"\n");
        	        }
        	    	strcat(mydeftab[defcount++].macroline,"\n");
		}
                mynamtab[namcount++].end=defcount;	//get the end pointer to deftab
}//end define
コード例 #4
0
ファイル: strcollectiongen.c プロジェクト: jacob-navia/ccl
/* Bug fixes proposed by oetelaar.automatisering */
static ElementType *CreateFromFile(const char *fileName)
{
    ElementType *result;
    CHAR_TYPE *line=NULL;
    int llen=0,r;
    ContainerAllocator *mm = CurrentAllocator;
    FILE *f;

    if (fileName == NULL) {
        NullPtrError("CreateFromFile");
        return NULL;
    }
    f = fopen((char *)fileName,"r");
    if (f == NULL) {
        iError.RaiseError("istrCollection.CreateFromFile",CONTAINER_ERROR_NOENT);
        return NULL;
    }
    result = iElementType.Create(10);
    if (result == NULL) {
        fclose(f); /* Was missing! */
        return NULL;
    }
    r = GETLINE(&line,&llen,f,mm);
    while (r >= 0) {
        if (iElementType.Add(result,line) <= 0) {
            Finalize(result);
            mm->free(line); /* was missing! */
            fclose(f);
            return NULL;
        }
        r = GETLINE(&line,&llen,f,mm);
    }
    if (r != EOF) {
        Finalize(result);
        mm->free(line);
        fclose(f);
        return NULL;
    }
    mm->free(line);
    fclose(f);
    return result;
}
コード例 #5
0
int main()
{
  int n;
  char buffer[MAXSIZE];

  while((n = GETLINE(buffer, MAXSIZE)) > 0)
    {
      if(remove_space(buffer, n))
	bufferFlush(buffer);
    }
  return 0;
}
コード例 #6
0
void main()
{
	char option;
	EXPANDING=0;
	
	input =fopen("ip.txt","r");      //opens the input file   in readable mode                 
	expanded=fopen("expanded.txt","w");	//opens the output file in writable mode
	GETLINE();	//gets the current line in the form of label,opcode and operand
 
	while(strcmp(opcode,"END")!=0)	//string not equal to END
	{  
		PROCESSLINE();		
       		GETLINE();
	}
        fprintf(expanded,"%s",line);	//copies the 'line' in expandable file
     	printf("\n*******************************\n\nEXPANDED FILE GENERATED!\n\n*******************************\n");
/*
	printf("\nDo you want to open the expanded file?(Y/N)\n");
	scanf("%c",&option);
     	if(option=='Y'||option=='y')
		system("sh sscript.sh");
	else
		exit(0);*/
  }
コード例 #7
0
ファイル: bounce_template.c プロジェクト: Gelma/Postfix
static void bounce_template_parse_buffer(BOUNCE_TEMPLATE *tp)
{
    char   *tval = tp->buffer;
    char   *cp;
    char  **cpp;
    int     cpp_len;
    int     cpp_used;
    int     hlen;
    char   *hval;

    /*
     * Sanity check.
     */
    if ((tp->flags & BOUNCE_TMPL_FLAG_NEW_BUFFER) == 0)
	msg_panic("bounce_template_parse_buffer: nothing to do here");
    tp->flags &= ~BOUNCE_TMPL_FLAG_NEW_BUFFER;

    /*
     * Discard the unusable template and use the default one instead.
     */
#define CLEANUP_AND_RETURN() do { \
	bounce_template_reset(tp); \
	return; \
    } while (0)

    /*
     * Parse pseudo-header labels and values.
     */
#define GETLINE(line, buf) \
        (((line) = (buf)) != 0 ? ((buf) = split_at((buf), '\n'), (line)) : 0)

    while ((GETLINE(cp, tval)) != 0 && (hlen = is_header(cp)) > 0) {
	for (hval = cp + hlen; *hval && (*hval == ':' || ISSPACE(*hval)); hval++)
	    *hval = 0;
	if (*hval == 0) {
	    msg_warn("%s: empty \"%s\" header value in %s template "
		     "-- ignoring this template",
		     tp->origin, cp, tp->class);
	    CLEANUP_AND_RETURN();
	}
	if (!allascii(hval)) {
	    msg_warn("%s: non-ASCII \"%s\" header value in %s template "
		     "-- ignoring this template",
		     tp->origin, cp, tp->class);
	    CLEANUP_AND_RETURN();
	}
コード例 #8
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveSol( LPCLASSDATA lpcd )
{
	int nFirst = 0;
	LPLINE pLine = GETLINE( lpcd );

	/*
	 *	Any characters on the line?
	 */
	if ( pLine->nLength == 0 ) return;

	/*
	 *	Find first character offset.
	 */
	while ( nFirst < pLine->nLength && _istspace( pLine->pcText[ nFirst ] ) ) nFirst++;

	/*
	 *	Are we already there?
	 */
	if ( lpcd->ptCaretPos.x > 0 && lpcd->ptCaretPos.x <= nFirst )
		/*
		 *	No, move to the start.
		 */
		lpcd->ptCaretPos.x = 0;
	else
		/*
		 *	No, move to the start.
		 */
		lpcd->ptCaretPos.x = nFirst;

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
コード例 #9
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveLeft( LPCLASSDATA lpcd )
{
        /*
	 *	Caret at the start of the line?
	 */
	if ( lpcd->ptCaretPos.x == 0 )
        {
	        /*
		 *	Yes. Are we at the first line?
		 */
	        if ( lpcd->ptCaretPos.y > 0 )
		{
                        /*
			 *	Go up one.
			 */
			lpcd->ptCaretPos.y--;

                        /*
			 *	Go to the end of the line.
			 */
			lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
                }
	}
	else
	        /*
		 *	One left.
		 */
	        lpcd->ptCaretPos.x--;

        /*
	 *	Save off this position.
	 */
        lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

        /*
	 *	Make sure the care is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
	 */
        UpdateCaret( lpcd );
}
コード例 #10
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveRight( LPCLASSDATA lpcd )
{
        /*
	 *	Caret at the end of the line?
	 */
	if ( lpcd->ptCaretPos.x == GETLINE( lpcd )->nLength )
        {
	        /*
		 *	Yes. Are we at the last line?
		 */
                if ( lpcd->ptCaretPos.y < ArrayGetSize( lpcd->lpLines ) - 1 )
	        {
		        /*
			 *	Go down one.
			 */
		        lpcd->ptCaretPos.y++;
			lpcd->ptCaretPos.x = 0;
                }
	}
	else
	        /*
		 *	One right.
		 */
	        lpcd->ptCaretPos.x++;

        /*
	 *	Save off this position.
	 */
        lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

        /*
	 *	Make sure the caret is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
         */
	UpdateCaret( lpcd );
}
コード例 #11
0
void EXPAND()
{
	int i,end=0,j=0,k=0;
        EXPANDING=1;
        int arg=0;
                      
        fprintf(expanded,"//%s",line);		//comments the call
        for(i=0;i<namcount;i++)			
        {
        	if(!strcmp(opcode,mynamtab[i].name))	//if opcode matches name available in the NAMTAB
                {
                	curr=mynamtab[i].start;
                        end=mynamtab[i].end;
                        while(operand[i]!='\0')		//if operand is there
                        {
                        	if(operand[i]!=',')
                                myargtab.arg[j][k++]=operand[i];
                                else
                                {
                                        myargtab.arg[j++][k]='\n';
                                	k=0;
                                }
                              
                                i++;
                        }//endwhile                             
                        myargtab.arg[j][k]='\n';	//generating the ARGTAB
                 }//end if
        }//end for
        while(curr<(end-1)) //continue till end of the DEFTAB is reached
        {
        	GETLINE();
                if(operand[0]=='?')	//if positional parameter
		        strcpy(operand,myargtab.arg[operand[1]-'0'-1]);	//then put its value from ARGTAB in the operand
			fprintf(expanded,"%s %s %s",label,opcode,operand); //copy the whole line in expanded file
        }
        EXPANDING=0; //end of expansion
}//end expand
コード例 #12
0
ファイル: formatVTK.c プロジェクト: CIBC-Internal/teem
int
_nrrdFormatVTK_read(FILE *file, Nrrd *nrrd, NrrdIoState *nio) {
  static const char me[]="_nrrdReadVTK";
  char *three[3];
  int sx, sy, sz, ret, N;
  double xm=0.0, ym=0.0, zm=0.0, xs=1.0, ys=1.0, zs=1.0;
  airArray *mop;
  unsigned int llen;

  if (!_nrrdFormatVTK_contentStartsLike(nio)) {
    biffAddf(NRRD, "%s: this doesn't look like a %s file", me,
             nrrdFormatVTK->name);
    return 1;
  }

#define GETLINE(what)                                        \
  do {                                                       \
    ret = _nrrdOneLine(&llen, nio, file);                    \
  } while (!ret && (1 == llen));                             \
  if (ret || !llen) {                                        \
    biffAddf(NRRD, "%s: couldn't get " #what " line", me);   \
    return 1;                                                \
  }

  /* read in content */
  GETLINE(content);
  if (strcmp(NRRD_UNKNOWN, nio->line)) {
    if (!(nrrd->content = airStrdup(nio->line))) {
      biffAddf(NRRD, "%s: couldn't read or copy content string", me);
      return 1;
    }
  }
  GETLINE(encoding); airToUpper(nio->line);
  if (!strcmp("ASCII", nio->line)) {
    nio->encoding = nrrdEncodingAscii;
  } else if (!strcmp("BINARY", nio->line)) {
    nio->encoding = nrrdEncodingRaw;
  } else {
    biffAddf(NRRD, "%s: encoding \"%s\" wasn't \"ASCII\" or \"BINARY\"",
             me, nio->line);
    return 1;
  }
  GETLINE(DATASET); airToUpper(nio->line);
  if (!strstr(nio->line, "STRUCTURED_POINTS")) {
    biffAddf(NRRD,
             "%s: sorry, only STRUCTURED_POINTS data is nrrd-ready", me);
    return 1;
  }
  GETLINE(DIMENSIONS); airToUpper(nio->line);
  if (!strstr(nio->line, "DIMENSIONS")
      || 3 != sscanf(nio->line, "DIMENSIONS %d %d %d", &sx, &sy, &sz)) {
    biffAddf(NRRD, "%s: couldn't parse DIMENSIONS line (\"%s\")",
             me, nio->line);
    return 1;
  }
  GETLINE(next); airToUpper(nio->line);
  while (!strstr(nio->line, "POINT_DATA")) {
    if (strstr(nio->line, "ORIGIN")) {
      if (3 != sscanf(nio->line, "ORIGIN %lf %lf %lf", &xm, &ym, &zm)) {
        biffAddf(NRRD, "%s: couldn't parse ORIGIN line (\"%s\")",
                 me, nio->line);
        return 1;
      }
    } else if (strstr(nio->line, "SPACING")) {
      if (3 != sscanf(nio->line, "SPACING %lf %lf %lf",
                      &xs, &ys, &zs)) {
        biffAddf(NRRD, "%s: couldn't parse SPACING line (\"%s\")",
                 me, nio->line);
        return 1;
      }
    } else if (strstr(nio->line, "ASPECT_RATIO")) {
      if (3 != sscanf(nio->line, "ASPECT_RATIO %lf %lf %lf",
                      &xs, &ys, &zs)) {
        biffAddf(NRRD, "%s: couldn't parse ASPECT_RATIO line (\"%s\")",
                 me, nio->line);
        return 1;
      }
    }
    GETLINE(next); airToUpper(nio->line);
  }
  if (1 != sscanf(nio->line, "POINT_DATA %d", &N)) {
    biffAddf(NRRD, "%s: couldn't parse POINT_DATA line (\"%s\")",
             me, nio->line);
    return 1;
  }
  if (N != sx*sy*sz) {
    biffAddf(NRRD,
             "%s: product of sizes (%d*%d*%d == %d) != # elements (%d)",
             me, sx, sy, sz, sx*sy*sz, N);
    return 1;
  }
  GETLINE(attribute declaration);
  mop = airMopNew();
  if (3 != airParseStrS(three, nio->line, AIR_WHITESPACE, 3, AIR_FALSE)) {
    biffAddf(NRRD,
             "%s: didn't see three words in attribute declaration \"%s\"",
             me, nio->line);
    return 1;
  }
  airMopAdd(mop, three[0], airFree, airMopAlways);
  airMopAdd(mop, three[1], airFree, airMopAlways);
  airMopAdd(mop, three[2], airFree, airMopAlways);
  airToLower(three[2]);
  if (!strcmp(three[2], "bit")) {
    if (nrrdEncodingAscii == nio->encoding) {
      fprintf(stderr, "%s: WARNING: \"bit\"-type data will be read in as "
              "unsigned char\n", me);
      nrrd->type = nrrdTypeUChar;
    } else {
      biffAddf(NRRD, "%s: can't read in \"bit\"-type data as BINARY", me);
      return 1;
    }
  } else if (!strcmp(three[2], "unsigned_char")) {
    nrrd->type = nrrdTypeUChar;
  } else if (!strcmp(three[2], "char")) {
    nrrd->type = nrrdTypeChar;
  } else if (!strcmp(three[2], "unsigned_short")) {
    nrrd->type = nrrdTypeUShort;
  } else if (!strcmp(three[2], "short")) {
    nrrd->type = nrrdTypeShort;
  } else if (!strcmp(three[2], "unsigned_int")) {
    nrrd->type = nrrdTypeUInt;
  } else if (!strcmp(three[2], "int")) {
    nrrd->type = nrrdTypeInt;
  } else if (!strcmp(three[2], "float")) {
    nrrd->type = nrrdTypeFloat;
  } else if (!strcmp(three[2], "double")) {
    nrrd->type = nrrdTypeDouble;
  } else {
    /* "unsigned_long" and "long" fall in here- I don't know what
       the VTK people mean by these types, since always mean different
       things on 32-bit versus 64-bit architectures */
    biffAddf(NRRD, "%s: type \"%s\" not recognized", me, three[2]);
    airMopError(mop); return 1;
  }
  airToUpper(three[0]);
  if (!strncmp("SCALARS", three[0], strlen("SCALARS"))) {
    GETLINE(LOOKUP_TABLE); airToUpper(nio->line);
    if (strcmp(nio->line, "LOOKUP_TABLE DEFAULT")) {
      biffAddf(NRRD,
               "%s: sorry, can only deal with default LOOKUP_TABLE", me);
      airMopError(mop); return 1;
    }
    nrrd->dim = 3;
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize,
                       AIR_CAST(size_t, sx),
                       AIR_CAST(size_t, sy),
                       AIR_CAST(size_t, sz));
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSpacing, xs, ys, zs);
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMin, xm, ym, zm);
  } else if (!strncmp("VECTORS", three[0], strlen("VECTORS"))) {
    nrrd->dim = 4;
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize,
                       AIR_CAST(size_t, 3),
                       AIR_CAST(size_t, sx),
                       AIR_CAST(size_t, sy),
                       AIR_CAST(size_t, sz));
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSpacing, AIR_NAN, xs, ys, zs);
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMin, AIR_NAN, xm, ym, zm);
    nrrd->axis[0].kind = nrrdKind3Vector;
  } else if (!strncmp("TENSORS", three[0], strlen("TENSORS"))) {
    nrrd->dim = 4;
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSize,
                       AIR_CAST(size_t, 9),
                       AIR_CAST(size_t, sx),
                       AIR_CAST(size_t, sy),
                       AIR_CAST(size_t, sz));
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoSpacing, AIR_NAN, xs, ys, zs);
    nrrdAxisInfoSet_va(nrrd, nrrdAxisInfoMin, AIR_NAN, xm, ym, zm);
    nrrd->axis[0].kind = nrrdKind3DMatrix;
  } else {
    biffAddf(NRRD,
             "%s: sorry, can only deal with SCALARS, VECTORS, and TENSORS "
             "currently, so couldn't parse attribute declaration \"%s\"",
             me, nio->line);
    airMopError(mop); return 1;
  }
  if (!nio->skipData) {
    if (_nrrdCalloc(nrrd, nio, file)) {
      biffAddf(NRRD, "%s: couldn't allocate memory for data", me);
      return 1;
    }
    if (nio->encoding->read(file, nrrd->data, nrrdElementNumber(nrrd),
                            nrrd, nio)) {
      biffAddf(NRRD, "%s:", me);
      return 1;
    }
    if (1 < nrrdElementSize(nrrd)
        && nio->encoding->endianMatters
        && airMyEndian() != airEndianBig) {
      /* encoding exposes endianness, and its big, but we aren't */
      nrrdSwapEndian(nrrd);
    }
  } else {
    nrrd->data = NULL;
  }

  airMopOkay(mop);
  return 0;
}
コード例 #13
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveNextWord( LPCLASSDATA lpcd )
{
	/*
	 *	Obtain current caret column and a
	 *	pointer to the line.
	 */
	int	nPos = lpcd->ptCaretPos.x;
	LPLINE	lpLine = GETLINE( lpcd );

	/*
	 *	Are we at the end of the line?
	 */
	if ( nPos == lpLine->nLength )
	{
		/*
		 *	Yes go down one line and to the
		 *	first word on that line.
		 */
		if ( lpcd->ptCaretPos.y < ArrayGetSize( lpcd->lpLines ) - 1 )
		{
			/*
			 *	Start at 0
			 */
			nPos = 0;

			/*
			 *	Go down.
			 */
			lpcd->ptCaretPos.y++;

			/*
			 *	Skip spaces.
			 */
			lpLine = GETLINE( lpcd );

			if ( lpLine->pcText )
			{
				while ( _istspace( lpLine->pcText[ nPos ] ) && nPos < GETLINE( lpcd )->nLength )
					nPos++;
			}

			/*
			 *	Store new column position.
			 */
			lpcd->ptCaretPos.x = nPos;
		}
	}
	else
	{
		BOOL	bBreakOnNonSpace = FALSE;

		/*
		 *	Are we on a white space?
		 */
		if ( _istspace( lpLine->pcText[ nPos ] ))
		{
			/*
			 *	Skip spaces...
			 */
			while ( _istspace( lpLine->pcText[ nPos ] ) && nPos < lpLine->nLength )
				nPos++;
		}
		else if ( IsDelimiter( lpcd, lpLine->pcText [ nPos ] )) /* A delimiter? */
		{
			/*
			 *	Skip all delimiters and white spaces.
			 */
			while (( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ) || _istspace( lpLine->pcText[ nPos ] )) && nPos < lpLine->nLength )
			{
				/*
				 *	White space?
				 */
				if ( _istspace( lpLine->pcText[ nPos ] ))
					/*
					 *	Yes. Break on the next non-white space.
					 */
					bBreakOnNonSpace = TRUE;
				else if ( bBreakOnNonSpace )
					/*
					 *	Stop at this non-white space.
					 */
					break;
				nPos++;
			}
		}
		else
		{
			/*
			 *	Skip all non delimiters and white spaces.
			 */
			while (( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ) == FALSE || _istspace( lpLine->pcText[ nPos ] )) && nPos < lpLine->nLength )
			{
				/*
				 *	White space?
				 */
				if ( _istspace( lpLine->pcText[ nPos ] ))
					/*
					 *	Yes. Break on the next non-white space.
					 */
					bBreakOnNonSpace = TRUE;
				else if ( bBreakOnNonSpace )
					/*
					 *	Stop at this non-white space.
					 */
					break;
				nPos++;
			}
		}

		/*
		 *	Store position.
		 */
		lpcd->ptCaretPos.x = nPos;
	}

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the caret is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
コード例 #14
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveDown( LPCLASSDATA lpcd )
{
	/*
	 *	Caret at the last line?
	 */
	if ( lpcd->ptCaretPos.y < ArrayGetSize( lpcd->lpLines ) - 1 )
	{
		/*
		 *	Fast scrolling?
		 */
		if ( Parser->bFastScroll && lpcd->bRepeatMode )
		{
			/* 
			 *	Are we at the top of the view?
			 */
			if ( lpcd->ptCaretPos.y == ( lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1 ))
				/*
				 *	Setup new position.
				 */
				lpcd->ptCaretPos.y = min( lpcd->ptCaretPos.y + 2, ArrayGetSize( lpcd->lpLines ) - 1 );
			else
				/*
				 *	One line up.
				 */
				 lpcd->ptCaretPos.y++;
		}
		else
			/*
			 *	Go one down.
			 */
			lpcd->ptCaretPos.y++;

                /*
		 *	Try to locate the cursor as close to the
		 *	last column position as possible since
                 *	the user changed the column.
		 */
		lpcd->ptCaretPos.x = GetTextOffset( lpcd, lpcd->nLastColumnPos );

		/*
		 *	Are we passed the end?
		 */
                if ( lpcd->ptCaretPos.x > GETLINE( lpcd )->nLength )
	                /*
			 *	Set us at the end.
			 */
                        lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
        }
	else
	{
		/*
		 *	Caret at the end of the line?
		 */
    // Modified by Stephan (2005-06-08): Don't jump to end of line
		//if ( lpcd->ptCaretPos.x < GETLINE( lpcd )->nLength )
			//lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
	}

        /*
	 *	Make sure the care is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
	 */
        UpdateCaret( lpcd );
}
コード例 #15
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MoveEnd( LPCLASSDATA lpcd )
{
	/*
	 *	Are we there yet?
	 */
	if ( lpcd->ptCaretPos.y == ArrayGetSize( lpcd->lpLines ) - 1 && lpcd->ptCaretPos.x == GETLINE( lpcd )->nLength )
		/*
		 *	Yes.
		 */
		return;

	/*
	 *	Put us on the last line.
	 */
	lpcd->ptCaretPos.y = ArrayGetSize( lpcd->lpLines ) - 1;

	/*
	 *	Move us to the end.
	 */
	//lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;   // Modified by Stephan (2005-06-08): Don't jump to the end of the line
  lpcd->ptCaretPos.x = 0;

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
コード例 #16
0
ファイル: caret.c プロジェクト: x2on/NiLogViewer
static void MovePrevWord( LPCLASSDATA lpcd )
{
	/*
	 *	Obtain current caret column and
	 *	the line were on.
	 */
	int	nPos = lpcd->ptCaretPos.x;
	LPLINE	lpLine = GETLINE( lpcd );

	/*
	 *	Are we at the start of the line?
	 */
	if ( nPos == 0 )
	{
		/*
		 *	Yes go down one line and to the
		 *	end of that line.
		 */
		if ( lpcd->ptCaretPos.y > 0 )
		{
			/*
			 *	Go up.
			 */
			lpcd->ptCaretPos.y--;

			/*
			 *	Put the caret at the end.
			 */
			lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;

			if ( lpcd->ptCaretPos.x )
				/*
				 *	Recursivly call ourselves.
				 */
				MovePrevWord( lpcd );
		}
	}
	else
	{
		/*
		 *	Previous character.
		 */
		nPos--;

		/*
		 *	Are we on a white space?
		 */
		if ( _istspace( lpLine->pcText[ nPos ] ))
		{
			/*
			 *	Skip spaces...
			 */
			while ( _istspace( lpLine->pcText[ nPos ] ) && nPos )
				nPos--;
		}

		/*
		 *	Start of the line?
		 */
		if ( nPos )
		{
			/*
			 *	Did we reach a delimiter?
			 */
			if ( IsDelimiter( lpcd, lpLine->pcText[ nPos ] )) /* A delimiter? */
			{
				/*
				 *	Skip all delimiters.
				 */
				while ( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ))
				{
					/*
					 *	White space?
					 */
					if ( _istspace( lpLine->pcText[ nPos ] ))
						break;

					/*
					 *	Start of the line?
					 */
					if ( nPos == 0 )
					{
						/*
						 *	Will force the caret at position 0
						 */
						nPos = -1;
						break;
					}
					nPos--;
				}
				nPos++;
			}
			else
			{
				/*
				 *	Skip all non delimiters.
				 */
				while ( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ) == FALSE )
				{
					/*
					 *	White space?
					 */
					if ( _istspace( lpLine->pcText[ nPos ] ))
						break;

					/*
					 *	Start of the line
					 */
					if ( nPos == 0 )
					{
						/*
						 *	Will force the caret at position 0
						 */
						nPos = -1;
						break;
					}
					nPos--;
				}
				nPos++;
			}
		}

		/*
		 *	Store position.
		 */
		lpcd->ptCaretPos.x = nPos;
	}

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}