Esempio n. 1
0
File: alias.c Progetto: wfp5p/elm
static void get_realnames(char *aliasname, char *firstname, char *lastname,
			  char *comment, char *buffer)
{
	/* FOO - this is not handling enter_string() aborts properly */

	sprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesEnterLastName,
		"Enter last name for %s: "), aliasname);
	PutLine(LINES-2, 0, buffer);
	enter_string(lastname, SLEN, -1, -1, ESTR_REPLACE);

	sprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesEnterFirstName,
		"Enter first name for %s: "), aliasname);
	PutLine(LINES-2, 0, buffer);
	enter_string(firstname, SLEN, -1, -1, ESTR_REPLACE);

	if (strlen(lastname) == 0) {
	    if (strlen(firstname) == 0) {
	        strcpy(lastname, aliasname);
	    }
	    else {
	        strcpy(lastname, firstname);
	        *firstname = '\0';
	    }
	}

	sprintf(buffer, catgets(elm_msg_cat, AliasesSet, AliasesEnterComment,
		"Enter optional comment for %s: "), aliasname);
	PutLine(LINES-2, 0, buffer);
	enter_string(comment, SLEN, -1, -1, ESTR_REPLACE);

}
Esempio n. 2
0
static int DrawMarkers(Engine *engine, long n, const GpReal *px,
                       const GpReal *py)
{
  PSEngine *psEngine= (PSEngine *)engine;
  GpXYMap *map= &engine->map;
  long maxPoints= 4050, nPoints;
  int type, markEnd= 0;
  GpPoint *points;
  int size;
  char typeString[8];

  if (n<1 || gistA.m.type<=0) return 0;
  if (CheckClip(psEngine)) return 1;
  if (SetupColor(psEngine, gistA.m.color) ||
      SetupFont(psEngine, gistA.m.size*DEFAULT_MARKER_SIZE)) return 1;
  if (psEngine->curClip) size= 0;
  else size= (int)(psEngine->curHeight*NDC_TO_PS);

  if (gistA.m.type>32 && gistA.m.type<127) {
    char *now= typeString;
    *now++= '(';
    if (gistA.m.type=='(' || gistA.m.type==')' || gistA.m.type=='\\')
      *now++= '\\';
    *now++= type= gistA.m.type;
    *now++= ')';
    *now++= '\0';
  } else {
    if (gistA.m.type<0 || gistA.m.type>M_CROSS) type= M_ASTERISK;
    else type= gistA.m.type;
    sprintf(typeString, "%d", type-1);
  }

  if (n>90) {
    long nLines= (n-1)/9 + 1;  /* 9 points is 72 characters */
    if (psEngine->nchars && PutLine(psEngine)) return 1;
    sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1);
    if (Append(psEngine, line) || PutLine(psEngine)) return 1;
    markEnd= 1;
  }
  if (Append(psEngine, typeString)) return 1;  /* "(A)" or "1", e.g. */
  sprintf(line, type<32? "%ld MS" : "%ld M", n);
  if (Append(psEngine, line) || PutLine(psEngine)) return 1;

  while ((nPoints=
          GpIntPoints(map, maxPoints, n, px, py, &points))) {
    if (PutPoints(psEngine, points, nPoints, size)) return 1;
    if (n==nPoints) break;
    n-= nPoints;
    px+= nPoints;
    py+= nPoints;
  }

  if (markEnd) {
    if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1;
  }

  return 0;
}
Esempio n. 3
0
static int BeginPage(PSEngine *psEngine)
{
  int currentPage= psEngine->currentPage;

  psEngine->e.marked= 1;

  /* A change in color table can take place only at the beginning
     of a page.  ChangePalette strobes the palette in the Engine base
     class part into the PSEngine palette.  */
  psEngine->nColors= 0;      /* reset to mono mode */
  ChangePalette((Engine *)psEngine);

  if (psEngine->nchars && PutLine(psEngine)) return 1;
  if (PutLine(psEngine)) return 1;

  sprintf(line, "%%%%Page: %d %d", currentPage, currentPage);
  if (Append(psEngine, line) || PutLine(psEngine)) return 1;

  if (Append(psEngine, "%%PageBoundingBox: (atend)") ||
      PutLine(psEngine)) return 1;

  if (Append(psEngine, "GistPrimitives begin /PG save def GI") ||
      PutLine(psEngine)) return 1;

  /* Set transform viewport to reflect current page orientation */
  if (psEngine->landscape != psEngine->e.landscape) {
    SetPSTransform(&psEngine->e.transform, psEngine->e.landscape);
    psEngine->landscape= psEngine->e.landscape;
  }
  if (psEngine->landscape) {
    if (Append(psEngine, "LAND") ||
        PutLine(psEngine)) return 1;
  }

  if (psEngine->e.colorMode && psEngine->e.palette &&
      psEngine->e.nColors>0) {
    int i, nColors= psEngine->e.nColors;
    GpColorCell *palette= psEngine->e.palette;
    long color;
    sprintf(line, "%d CT", nColors);
    if (Append(psEngine, line) || PutLine(psEngine)) return 1;
    for (i=0 ; i<nColors ; i++) {
      color= P_R(palette[i])<<16 | P_G(palette[i])<<8 | P_B(palette[i]);
      sprintf(line, "%06lx", color);
      if (Append(psEngine, line)) return 1;
    }
    if (psEngine->nchars && PutLine(psEngine)) return 1;
    psEngine->colorMode= 1;  /* color table has been written */
    psEngine->nColors= nColors;
  } else {
    psEngine->colorMode= 0;  /* NO color table exists on this page */
    /* But, if there is a palette, still want to use grays */
    if (psEngine->e.palette && psEngine->e.nColors>0)
      psEngine->nColors= psEngine->e.nColors;
  }

  if (Append(psEngine, "%%EndPageSetup") || PutLine(psEngine)) return 1;
  return 0;
}
Esempio n. 4
0
static int DrawLines(Engine *engine, long n, const GpReal *px,
                     const GpReal *py, int closed, int smooth)
{
  PSEngine *psEngine= (PSEngine *)engine;
  GpXYMap *map= &engine->map;
  long maxPoints= 4050, nPoints;
  long np= n + (closed?1:0);
  int firstPass= 1, markEnd= 0;
  GpPoint firstPoint, *points;
  int size;

  if (CheckClip(psEngine)) return 1;
  if (n<1) return 0;
  if (SetupLine(psEngine, &gistA.l)) return 1;
  if (psEngine->curClip) size= 0;
  else size= (int)(psEngine->curWidth*0.5*DEFAULT_PS_WIDTH);

  if (np>90) {
    long nLines= (np-1)/9 + 1;  /* 9 points is 72 characters */
    if (psEngine->nchars && PutLine(psEngine)) return 1;
    sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1);
    if (Append(psEngine, line) || PutLine(psEngine)) return 1;
    markEnd= 1;
  }
  sprintf(line, smooth? "%ld LS" : "%ld L", np);
  if (Append(psEngine, line) || PutLine(psEngine)) return 1;

  while ((nPoints=
          GpIntPoints(map, maxPoints, n, px, py, &points))) {
    if (closed) {
      if (firstPass) {
        firstPoint= points[0];
        firstPass= 0;
      }
      if (n==nPoints) {
        n++;
        points[nPoints++]= firstPoint;
      }
    }
    if (PutPoints(psEngine, points, nPoints, size)) return 1;
    if (n==nPoints) break;
    n-= nPoints;
    px+= nPoints;
    py+= nPoints;
  }

  if (markEnd) {
    if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1;
  }

  return 0;
}
Esempio n. 5
0
void Stroker::Cap(const Pointf& p, const Pointf& v, const Pointf& o,
                  const Pointf& a, const Pointf& b)
{
	PutMove(a);
	if(linecap == LINECAP_SQUARE) {
		Pointf nv = Ortogonal(o);
		PutLine(a + nv);
		PutLine(b + nv);
	}
	if(linecap == LINECAP_ROUND)
		Round(p, -o, o, w2);
	PutLine(b);
}
Esempio n. 6
0
File: editmsg.c Progetto: wfp5p/elm
static void get_with_expansion(const char *prompt, char *buffer,
			       char *expanded_buffer, const char *sourcebuf)
{
	char savecopy[SLEN];

	/** This is used to prompt for a new value of the specified field.
	    If expanded_buffer == NULL then we won't bother trying to expand
	    this puppy out!  (sourcebuf could be an initial addition)
	**/

	PutLine(-1, -1, prompt);

	if (sourcebuf != NULL) {
	  while (!whitespace(*sourcebuf) && *sourcebuf != '\0')
	    sourcebuf++;
	  if (*sourcebuf != '\0') {
	    while (whitespace(*sourcebuf))
	      sourcebuf++;
	    if (strlen(sourcebuf) > 0) {
	      strcat(buffer, " ");
	      strcat(buffer, sourcebuf);
	    }
	  }
	}

	(void) strfcpy(savecopy, buffer, sizeof(savecopy));
	if (enter_string(buffer, SLEN, -1, -1, ESTR_UPDATE) < 0) {
	    /* undo */
	    (void) strcpy(buffer, savecopy);
	    PutLine(-1, -1, prompt);
	    PutLine(-1, -1, buffer);
	    NewLine();
	    return;
	}

	if(expanded_buffer != NULL) {
	  build_address(strip_commas(buffer), expanded_buffer);
	  if(*expanded_buffer != '\0') {
	    if (*prompt != '\n')
	      NewLine();
	    PutLine(-1, -1, prompt);
	    PutLine(-1, -1, expanded_buffer);
	  }
	}
	NewLine();

	return;
}
Esempio n. 7
0
void prompt(const char *s)
{
	/** prompt user for input on LINES-3 line, left justified **/

	PutLine(LINES-3,0,s);
	CleartoEOLN();
}
Esempio n. 8
0
void Stroker::Finish()
{
	if(IsNull(p1) || IsNull(p2) || IsNull(p0))
		return;
	if(p2 == p0)
		Line(p0 + v0);
	else {
		PutMove(a1);
		PutLine(a1 + v1);
		PutMove(b1 + v1);
		PutLine(b1);
		Cap(p0, v0, o0, b0, a0);
		Cap(p2, -v1, -o1, a1 + v1, b1 + v1);
	}
	p0 = p1 = p2 = Null;
}
Esempio n. 9
0
static int DrawFill(Engine *engine, long n, const GpReal *px,
                    const GpReal *py)
{
  PSEngine *psEngine= (PSEngine *)engine;
  GpXYMap *map= &engine->map;
  long maxPoints= 4050, nPoints;
  int markEnd= 0;
  GpPoint *points;
  int value= 0;

  /* For now, only FillSolid style supported */

  if (n<1) return 0;
  if (CheckClip(psEngine) || SetupColor(psEngine, gistA.f.color)) return 1;

  if (n>90) {
    long nLines= (n-1)/9 + 1;  /* 9 points is 72 characters */
    if (psEngine->nchars && PutLine(psEngine)) return 1;
    sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1);
    if (Append(psEngine, line) || PutLine(psEngine)) return 1;
    markEnd= 1;
  }
  if (gistA.e.type==L_NONE) sprintf(line, "%ld F", n);
  else sprintf(line, "%ld E", n);
  if (Append(psEngine, line) || PutLine(psEngine)) return 1;

  while ((nPoints=
          GpIntPoints(map, maxPoints, n, px, py, &points))) {
    if (PutPoints(psEngine, points, nPoints, 0)) return 1;
    if (n==nPoints) break;
    n-= nPoints;
    px+= nPoints;
    py+= nPoints;
    value= 1;   /* Polygons with >4050 sides won't be filled correctly */
  }
  if (gistA.e.type!=L_NONE) {
    /* setup for edge (usually different color than fill), then draw it */
    if (SetupLine(psEngine, &gistA.e)) return 1;
    if (Append(psEngine, "0 E") || PutLine(psEngine)) return 1;
  }

  if (markEnd) {
    if (Append(psEngine, "%%EndData") || PutLine(psEngine)) return 1;
  }

  return value;
}
Esempio n. 10
0
static void Kill(Engine *engine)
{
  PSEngine *psEngine= (PSEngine *)engine;
  long fonts= psEngine->fonts;
  int i, xll, yll, xur, yur;
  int bad= 0;

  if (psEngine->e.marked) bad= EndPage(psEngine);

  if (psEngine->file) {
    if (!bad) bad= PutLine(psEngine);
    if (!bad) bad= Append(psEngine, "%%Trailer");
    if (!bad) bad= PutLine(psEngine);

    sprintf(line, "%%%%Pages: %d", psEngine->currentPage-1);
    if (!bad) bad= Append(psEngine, line);
    if (!bad) bad= PutLine(psEngine);

    xll= psEngine->docBB.xll;
    xur= psEngine->docBB.xur;
    if (xll < xur) {
      yll= psEngine->docBB.yll;
      yur= psEngine->docBB.yur;
    } else {
      xll= yll= 0;
      xur= 612;
      yur= 792;
    }
    sprintf(line, "%%%%BoundingBox: %d %d %d %d", xll, yll, xur, yur);
    if (!bad) bad= Append(psEngine, line);
    if (!bad) bad= PutLine(psEngine);

    strcpy(line, "%%DocumentFonts: ");
    for (i=0 ; i<N_PSFONTS ; i++) {
      if ((1<<i) & fonts) {
        strcat(line, psFontNames[i]);
        if (!bad) bad= Append(psEngine, line);
        if (!bad) bad= PutLine(psEngine);
        strcpy(line, "%%+ ");
      }
    }

    if (psEngine->file!=pf_stdout) p_fclose(psEngine->file);
  }
  GpDelEngine(engine);
}
Esempio n. 11
0
/*** Replace - edit character in a file
*
* Purpose:
*   Replace will take the specified character and place it into the
*   specified position in the specified file.  If the edit is a NOP
*   (overstriking the same character) then no modification takes place
*
* Input:
*   c		character to edit in file
*   x, y	column, row of file to be changed
*   pFile	file being modified
*   fInsert	TRUE => character is inserted before the position
*
* Output:
*    TRUE => line was successfully edited, FALSE => line was too long
*
* Notes:
*
*************************************************************************/
flagType
Replace (
    char    c,
    COL     x,
    LINE    y,
    PFILE   pFile,
    flagType fInsert
    )
{
    linebuf buf;                             /* working buffer               */
    struct  lineAttr rgla[sizeof(linebuf)];
    flagType fColor = FALSE, fSpace = 0;
    char    *pxLog;

    fColor = GetColor (y, rgla, pFile);

    if (fInsSpaceColor (x, y, fInsert ? 1 : 0, pFile, buf, fColor ? rgla : NULL)) {

        pxLog = pLog (buf, x, TRUE);

        if (cbLog(buf) <= x) {

            /*
             * If the logical length of the buffer is less than what we need, then it was
             * at least space filled by fInsert, and we just need to append our character
             * to the buffer
             */

            *(unsigned int UNALIGNED *)pxLog = (unsigned int)(unsigned char)c;

        } else if (fInsert || (*pxLog != c)) {

            /*
             * if we're inserting, or the character we're overtyping is different, place
             * the character. Be sure to check the new logical length of the line as well,
             * in case it was a tab that overflowed it.
             */

            *pxLog = c;
            if (cbLog(buf) >= sizeof(linebuf)) {
                return FALSE;
            }
        }

        if (fInsert) {
            MarkCopyBox (pFile, pFile, x, y, sizeof(linebuf), y, x+1, y);
        }

        PutLine (y, buf, pFile);
        if (fColor) {
            ColorToLog (rgla, buf);
            PutColor (y, rgla, pFile);
        }
        return TRUE;
    }
    return FALSE;
}
Esempio n. 12
0
void ListWordValue(CARDINAL w)
{
  if (printState && ((1 << ListPC) & listStatus)) {
    if (linePosition >= TextStart) PutLine();
    Tab(CodeStart);
    PutHexCardinal(w);
    PutCh(Space);
  }; /* if */
} /* End ListWordValue */
Esempio n. 13
0
void ListByteValue(char b)
{
  if (printState && ((1 << ListPC) & listStatus)) {
    if (linePosition >= TextStart) PutLine();
    Tab(CodeStart);
    PutHexCh(b / 0x10);
    PutHexCh(b % 0x10);
    PutCh(Space);
  }; /* if */
} /* End ListByteValue */
Esempio n. 14
0
void CenterLine(int line, const char *str)
{
    int col;

    /* some systems require cast to ensure signed arithmetic */
    col = (COLS - (int)strlen(str)) / 2;
    if (col < 0)
	col = 0;
    PutLine(line, col, str);
}
Esempio n. 15
0
void PrintLine(void)
{
  CARDINAL i = 0;
  if (!linePrinted) {
    if (TextStart >= maxCols) {
      /*This is the silly line format case*/
      if (linePosition > TextStart) PutLine();
      else Tab(TextStart);
      while (currentLinePointer[i] != CR) PutCh(currentLinePointer[i++]);
    } else {
      /*This is the sensible case*/
      if ((linePosition > TextStart) && (currentLinePointer[i] != Space))
        PutLine();
      do {

        if ((currentLinePointer[i] == CommentSymbol) || (OpcodeStart >= maxCols))
         break;
        /*Write out the label*/
        WriteField(TextStart, FALSE, &i);

        if ((currentLinePointer[i] == CR) || (currentLinePointer[i] == CommentSymbol) || (OperandStart >= maxCols))
         break ;

        /*We have an opcode*/
        if (linePosition >= OpcodeStart) PutLine();
        WriteField(OpcodeStart, FALSE, &i);

        if ((currentLinePointer[i] == CR) || (currentLinePointer[i] == CommentSymbol) || (CommentStart >= maxCols))
         break ;

        /*We have an operand*/
        if (linePosition >= OperandStart) PutLine();
        WriteField(OperandStart, TRUE, &i);
      } while (1);
      if (currentLinePointer[i] != CR) WriteComment(&i);
    }; /* if */
    PutLine();
  }; /* if */
  linePrinted = TRUE;
  linePosition = 0;
  if (PollEscape()) abortFlag = TRUE;
} /* End PrintLine */
Esempio n. 16
0
static int break_line_now(PSEngine *psEngine, char **nw, int *nchs)
{
  char *now= *nw;
  *now++= '\\';
  *now= '\0';
  psEngine->nchars= *nchs+1;
  if (PutLine(psEngine)) return 1;
  *nchs= 0;
  *nw= psEngine->line;
  return 0;
}
Esempio n. 17
0
/*** WriteMarks - Write Marks back out to the markfile.
*
* Purpose:
*
*   To update the markfile if any marks have changed
*
* Input:
*   pFile - owner of the marks
*
* Output: None.
*
*************************************************************************/
void
WriteMarks (
    PFILE pFile
    ) {

    REGISTER MARK UNALIGNED * pm;
    char            szMark[BUFLEN];
    char            szFile[BUFLEN];
    linebuf         lbuf;
    LINE            yMark, l;
    COL             xMark;

    if (pFileMark == NULL || TESTFLAG(FLAGS(pFile), FAKE)) {
        return;
    }

    if (!fCacheMarks (pFile)) {
        return;
    }

    // First, we read the whole file looking for marks for
    // this file.  When we find one, we look it up in the
    // cache to find the new value and write it back
    // out.  Unchanged marks are not re-written.
    //
    for (l = 0L; l < pFileMark->cLines; l++) {
        GetLine (l, lbuf, pFileMark);
        if (sscanf (lbuf, " %[^ ] %[^ ] %ld %d ", szMark, szFile, &yMark, &xMark) >= 3) {
            if (!_stricmp (szFile, pFile->pName)) {
                if (pm = FindLocalMark (szMark, TRUE)) {
                    sprintf (lbuf, "%s %s %ld %d", szMark, szFile, pm->fl.lin+1, pm->fl.col+1);
                    PutLine (l, lbuf, pFileMark);
                    RSETFLAG (pm->flags, MF_DIRTY);
                }
            }
        }
    }

    // Now we read through the cache to find any new marks.  These
    // will be appended to the markfile.
    //
    for (   pm = pfmCache->marks;
            !TESTFLAG(pm->flags, MF_DUMMY);
            (char *)pm += pm->cb) {

        if (TESTFLAG (pm->flags, MF_DIRTY)) {
            sprintf (lbuf, "%s %s %ld %d", pm->szName,
                                          pFile->pName,
                                          pm->fl.lin + 1,
                                          pm->fl.col + 1);
            AppFile (lbuf, pFileMark);
        }
    }
}
Esempio n. 18
0
void Stroker::Round(const Pointf& p, const Pointf& v1, const Pointf& v2, double r)
{
	double tolerance = 0.3;
	double a1 = Bearing(v1);
	double a2 = Bearing(v2);
	if(a1 < a2)
		a1 += 2 * M_PI;
	while(a1 > a2) {
		PutLine(Polar(p, r, a1));
		a1 -= fid;
	}
}
Esempio n. 19
0
File: editmsg.c Progetto: wfp5p/elm
static void print_message_so_far(FILE *edit_fd, const SEND_HEADER *shdr)
{
	/** This prints out the message typed in so far.  We accomplish
	    this in a cheap manner - close the file, reopen it for reading,
	    stream it to the screen, then close the file, and reopen it
	    for appending.  Simple, but effective!

	    A nice enhancement would be for this to -> page <- the message
	    if it's sufficiently long.  Too much work for now, though.
	**/

	char buffer[SLEN];

	fflush(edit_fd);
	fseek(edit_fd, 0L, 0);

	NewLine();
	PutLine(-1, -1, "To: %s\r\n",		format_long(shdr->to, 4));
	PutLine(-1, -1, "Cc: %s\r\n",		format_long(shdr->cc, 4));
	PutLine(-1, -1, "Bcc: %s\r\n",		format_long(shdr->bcc, 5));
	PutLine(-1, -1, "Subject: %s\r\n",	shdr->subject);
	NewLine();

	while (fgets(buffer, SLEN, edit_fd) != NULL) {
	  PutLine(-1, -1, buffer);
	  NewLine();
	}

	PutLine(-1, -1, catgets(elm_msg_cat, ElmSet, ElmEditmsgPrintContinue,
	    "\n\r(Continue entering message.)\n\r"));
}
Esempio n. 20
0
static int EndPage(PSEngine *psEngine)
{
  char *line= psEngine->line;
  int xll, yll, xur, yur;

  if (EndClip(psEngine)) return 1;

  if ((psEngine->nchars && PutLine(psEngine)) ||
      Append(psEngine, "PG restore") || PutLine(psEngine)) return 1;
  if (Append(psEngine, "showpage") || PutLine(psEngine)) return 1;
  if (Append(psEngine, "end") || PutLine(psEngine)) return 1;
  if (Append(psEngine, "%%PageTrailer") || PutLine(psEngine)) return 1;

  GetEPSFBox(psEngine->e.landscape, &psEngine->pageBB,
             &xll, &yll, &xur, &yur);
  if (xll < psEngine->docBB.xll) psEngine->docBB.xll= xll;
  if (yll < psEngine->docBB.yll) psEngine->docBB.yll= yll;
  if (xur > psEngine->docBB.xur) psEngine->docBB.xur= xur;
  if (yur > psEngine->docBB.yur) psEngine->docBB.yur= yur;
  sprintf(line, "%%%%PageBoundingBox: %d %d %d %d", xll, yll, xur, yur);
  if (Append(psEngine, line) || PutLine(psEngine)) return 1;

  psEngine->currentPage++;
  psEngine->e.marked= 0;
  SetPageDefaults(psEngine);
  if (psEngine->file!=pf_stdout) p_fflush(psEngine->file);
  return 0;
}
Esempio n. 21
0
File: alias.c Progetto: wfp5p/elm
static int superceed_system(int this_alias)
{

	PutLine(LINES-2, 0, catgets(elm_msg_cat,
	        AliasesSet, AliasesSystemAlias, "System (%6s) alias for %s."),
	    alias_type(aliases[this_alias]->type), aliases[this_alias]->alias);
/*
 *	If they don't want to superceed the SYSTEM alias then
 *	return a FALSE.
 */
	return enter_yn(catgets(elm_msg_cat, AliasesSet, AliasesSuperceed,
	        "Superceed?"), FALSE, LINES-3, FALSE);
}
Esempio n. 22
0
static void WriteComment(CARDINAL *i)
{
  CARDINAL tempPosition,
           length;
  if (currentLinePointer[*i] != CommentSymbol)
   {

    /*This is the silly line format case*/
    while (currentLinePointer[*i] != CR) PutCh(currentLinePointer[(*i)++]);
    PutLine();
  } else {
    if (linePosition <= TextStart) tempPosition = TextStart;
    else {
      tempPosition = CommentStart;
      PutCh(Space);
    }; /* if */
    Tab(tempPosition);
    if (linePosition > CommentStart) {
      length = 0;
      while (currentLinePointer[*i + length] != CR) length++;
      if ((linePosition + length > maxCols) &&
        (tempPosition + length <= maxCols)) {
        PutLine();
        Tab(CommentStart);
      }; /* if */
    }; /* if */
    do {
      while (linePosition < maxCols) {
        if (currentLinePointer[*i] == CR) break;
        PutCh(currentLinePointer[(*i)++]);
      }; /* while */
      if (linePosition < maxCols) break;
        /* The previous break was meant to leave the loop */
      PutLine();
      Tab(tempPosition);
    } while (1);
  }; /* if */
} /* End WriteComment */
Esempio n. 23
0
File: editmsg.c Progetto: wfp5p/elm
int edit_message(const char *filename, SEND_HEADER *shdr,
		 const char *sel_editor)
{
    /* Return 0 if successful, -1 on error. */

    char buffer[SLEN];
    int rc, return_value = 0, err;

    /* pick default editor on NULL */
    if (sel_editor == NULL)
	sel_editor = (IS_BUILTIN(editor) ? alternative_editor : editor);

    /* handle request for the builtin editor */
    if (IS_BUILTIN(sel_editor))
	return builtin_editor(filename, shdr);

    /* we will be running an external editor */
    PutLine(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmInvokeEditor,
	    "Invoking editor..."));

    if (strstr(sel_editor, "%s") != NULL)
	sprintf(buffer, sel_editor, filename);
    else
	sprintf(buffer, "%s %s", sel_editor, filename);

    chown(filename, userid, groupid);

    if ((rc = system_call(buffer, SY_COOKED|SY_ENAB_SIGHUP|SY_DUMPSTATE)) < 0) {
	err = errno;
	dprint(1, (debugfile,
	    "System call failed with status %d (edit_message)\n", rc));
	dprint(1, (debugfile, "** %s **\n", strerror(err)));
	ClearLine(LINES-1);
	show_error(catgets(elm_msg_cat, ElmSet, ElmCantInvokeEditor,
	    "Can't invoke editor '%s' for composition."), sel_editor);
	if (sleepmsg > 0)
	    sleep(sleepmsg);
	return_value = -1;
    }

    /* Flush input buffer.  This is especially important under X,
    * where accidental keystrokes in the elm window could make
    * things messy.
    */
    if (edit_flush)
	FlushInput();

    return return_value;
}
Esempio n. 24
0
void ListStringValue(Name string)
{
 CARDINAL i ;

 if (printState && ((1 << ListPC) & listStatus))
  {
   for (i = 1; (i <= string.length); i++)
    {
     if (linePosition >= (MaxLineLength - 4))
      PutLine() ;
     Tab(CodeStart) ;
     EscapeWriteCh(string.key[i - 1]) ;
    }
  }
} /* End ListStringValue */
Esempio n. 25
0
static int EndClip(PSEngine *psEngine)
{
  if (psEngine->curClip) {
    if ((psEngine->nchars && PutLine(psEngine)) ||
        Append(psEngine, "CLOF")) return 1;
    psEngine->curClip= 0;
    /* Restore state at time of CLON */
    psEngine->curColor= psEngine->clipColor;
    psEngine->curType= psEngine->clipType;
    psEngine->curWidth= psEngine->clipWidth;
    psEngine->curFont= psEngine->clipFont;
    psEngine->curHeight= psEngine->clipHeight;
  }
  return 0;
}
Esempio n. 26
0
void RenderingMethod::ApplyPoints(int vd_id)
{
	vec4* tf = color_table + vd_id*TF_WIDTH;
	std::vector<TF_POINT> *tf_isos1 = &tf_points[vd_id];

	vec2 ww = vec2(1,0);
	for(int i=0;i<tf_isos1->size();i++)
	{
		float val = (*tf_isos1)[i].value;
		ww.x = min(ww.x,val);
		ww.y = max(ww.y,val);
	}
	tf_ww[vd_id] = ww;
	int iso_id[MAX_POINTS_NUM];
	memset(tf,0,sizeof(float)*4*TF_WIDTH);
	if(tf_isos1->size()>1)
	{
		//sort
		for(int i=0;i<tf_isos1->size();i++)
			iso_id[i]=i;
		for(int i=0;i<tf_isos1->size()-1;i++)
			for(int j=i+1;j<tf_isos1->size();j++)
				if((*tf_isos1)[iso_id[i]].value > (*tf_isos1)[iso_id[j]].value)
				{
					swap(iso_id[i],iso_id[j]);
				}

		//fill
		for(int i=1;i<tf_isos1->size();i++)
		{
			PutLine((*tf_isos1)[iso_id[i-1]].value, (*tf_isos1)[iso_id[i]].value, (*tf_isos1)[iso_id[i-1]].color,(*tf_isos1)[iso_id[i]].color,ww,tf);
		}

	}
	if(tf_isos1->size()==1)
	{
		tf_ww[vd_id].set(0,1);
		for(int i=0;i<TF_WIDTH;i++)
			tf[i] = (*tf_isos1)[0].color;
	}

	tf[1]=tf[0];
	tf[TF_WIDTH-2]=tf[TF_WIDTH-1];

	CT::need_rerender=1;
	need_reload_color_table = 1;
}
Esempio n. 27
0
static int Append(PSEngine *psEngine, const char *s)
{
  long len= s? strlen(s) : 0;
  long nchars= psEngine->nchars;
  char *line= psEngine->line;

  if (nchars+1+len>78) {
    if (PutLine(psEngine)) return 1;
    nchars= 0;
  } else if (nchars>0) {
    line[nchars++]= ' ';
  }
  strcpy(line+nchars, s);
  psEngine->nchars= nchars+len;

  return 0;
}
Esempio n. 28
0
void PrintLineNumber(void)
{
  char     digits[7];
  int      i;
  CARDINAL j;
  BOOLEAN  suppress = FALSE;
  j = lineNumber;
  for (i = 5; i >= 0; i--) {
    digits[i] = (suppress) ? Space : '0' + (j % 10);
    j = j / 10;
    suppress = j == 0;
  }; /* for */
  if (linePosition > 0) PutLine();
  digits[6] = 0;
  PutChs(digits);
  PutCh(Space);
} /* End PrintLineNumber */
Esempio n. 29
0
void show_last_error(void)
{
    int lines_of_msg;

    if (Term.status & TERM_IS_INIT) {
	lines_of_msg = (strlen(err_buffer) + COLS - 1) / COLS;
	ClearLine(LINES);
	if (lines_of_msg > 1)
	    PutLine(LINES + 1 - lines_of_msg, 0, err_buffer);
	else
	    CenterLine(LINES, err_buffer);
    } else {
	fputs(err_buffer, stderr);
	putc('\r', stderr);
	putc('\n', stderr);
    }
    FlushOutput();
}
Esempio n. 30
0
/*** ReplaceEdit - perform replacement in a line of text
*
* Purpose:
*
* Input:
*  p		= pointer to beginning of match within scanreal
*  rpl		= text of replacement
*
* Output:
*  Returns nothing
*
*************************************************************************/
void
ReplaceEdit (
    char *p,
    char *rpl
    )
{
    int c;                      /*  length of replacement string              */

    /*	if the len of line - len of search + len of replacement string < BUFLEN
     *	then we can make the replacement.  Otherwise we flag an error and
     *	advance to the next line
     */
    c = strlen (rpl);
    if (cbLog (scanreal) + c - srchlen < sizeof(linebuf)) {
	/*  open up a space in the buffer at the spot where the string was
	 *  found.  Move the characters starting at the END of the match to
	 *  the point after where the END of the replacement is.
	 */
	memmove ((char*) &p[c], (char *) &p[srchlen], sizeof(linebuf) - flScan.col - c);
	memmove ((char *) p, (char *) rpl, c);
        PutLine (flScan.lin, scanreal, pFileHead);

	/*  if search length != 0 or replace length != 0, skip over replacement */
        if (srchlen != 0 || c != 0) {
            flScan.col += c - 1;
        }

        //
        // Adjust scan len to account for the fact that the end of the region being
        // scanned may have moved as a result of the replacement. Adjust by the
        // replacement difference, and bound by 0 and the length of the line.
        //
	scanlen = max (0, min (scanlen + c - srchlen, cbLog(scanreal)));
	cRepl++;
    } else {
	printerror ("line %ld too long; replacement skipped", flScan.lin+1);
	flScan.col = scanlen;
    }
}