예제 #1
0
파일: testxmc.c 프로젝트: aosm/X11apps
/*
 * After writing text to the screen, resolve mismatch between the current
 * location and any attributes that would have been set by preceding locations.
 */
void
Resolve_XMC(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    LineData *ld;
    Bool changed = False;
    Char start;
    Char my_attrs = CharOf(screen->xmc_attributes & XMC_FLAGS);
    int row = screen->cur_row;
    int col = screen->cur_col;

    /* Find the preceding cell.
     */
    ld = getLineData(screen, row);
    if (ld->charData[col] != XMC_GLITCH) {
	if (col != 0) {
	    col--;
	} else if (!screen->xmc_inline && row != 0) {
	    ld = getLineData(screen, --row);
	    col = LineMaxCol(screen, ld);
	}
    }
    start = (ld->attribs[col] & my_attrs);

    /* Now propagate the starting state until we reach a cell which holds
     * a glitch.
     */
    for (;;) {
	if (col < LineMaxCol(screen, ld)) {
	    col++;
	} else if (!screen->xmc_inline && row < screen->max_row) {
	    col = 0;
	    ld = getLineData(screen, ++row);
	} else
	    break;
	if (ld->charData[col] == XMC_GLITCH)
	    break;
	if ((ld->attribs[col] & my_attrs) != start) {
	    ld->attribs[col] =
		CharOf(start | (ld->attribs[col] & ~my_attrs));
	    changed = True;
	}
    }

    TRACE(("XMC %s (%s:%d/%d) from %d,%d to %d,%d\n",
	   changed ? "Ripple" : "Nochange",
	   BtoS(xw->flags & my_attrs),
	   my_attrs, start,
	   screen->cur_row, screen->cur_col,
	   row, col));

    if (changed) {
	ScrnUpdate(xw, screen->cur_row, 0, row + 1 - screen->cur_row,
		   MaxCols(screen), True);
    }
}
예제 #2
0
/*
 * Reset all lines on the screen to single-width/single-height.
 */
void
xterm_ResetDouble(XtermWidget xw)
{
#if OPT_DEC_CHRSET
    TScreen *screen = TScreenOf(xw);
    Boolean changed = False;
    unsigned code;
    int row;

    for (row = 0; row < screen->max_row; ++row) {
	LineData *ld;

	if ((ld = getLineData(screen, ROW2INX(screen, row))) != 0) {
	    code = GetLineDblCS(ld);
	    if (code != CSET_SWL) {
		SetLineDblCS(ld, CSET_SWL);
		changed = True;
	    }
	}
    }
    if (changed) {
	xtermRepaint(xw);
    }
#else
    (void) xw;
#endif
}
예제 #3
0
Value CsvUtil::getValue(int typeName, int property, const char *csvPath) {
	auto csvData = _dataMap.at(csvPath);
	if (csvData == nullptr) {
		this->loadFile(csvPath);
		csvData = _dataMap.at(csvPath);
	}
	ValueVector line = csvData->getLineData(typeName);
	return Value(line.at(property));
}
예제 #4
0
파일: testxmc.c 프로젝트: aosm/X11apps
/*
 * Force a glitch on cursor movement when we're in standout mode and not at the
 * end of a line.
 */
void
Jump_XMC(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    if (!screen->move_sgr_ok
	&& screen->cur_col <= LineMaxCol(screen,
					 getLineData(screen, screen->cur_row))) {
	Mark_XMC(xw, -1);
    }
}
예제 #5
0
ChartLine::ChartLine( ChartScene& scene, const QColor& color, float width, ChartLinePointsProvider* pointsProvider )
   : m_scene( scene )
   , m_color( color )
   , m_penWidth( width )
   , m_pen( QBrush( color ), width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin )
   , m_pointsProvider( pointsProvider )
   , m_points( NULL )
   , m_pointsCount( 0 )
{
   getLineData();
}
예제 #6
0
static void
repaint_line(XtermWidget xw, unsigned newChrSet)
{
    TScreen *screen = TScreenOf(xw);
    LineData *ld;
    int curcol = screen->cur_col;
    int currow = screen->cur_row;
    int width = MaxCols(screen);
    unsigned len = (unsigned) width;

    assert(width > 0);

    /*
     * Ignore repetition.
     */
    if (!IsLeftRightMode(xw)
	&& (ld = getLineData(screen, currow)) != 0) {
	unsigned oldChrSet = GetLineDblCS(ld);

	if (oldChrSet != newChrSet) {
	    TRACE(("repaint_line(%2d,%2d) (%s -> %s)\n", currow, screen->cur_col,
		   visibleDblChrset(oldChrSet),
		   visibleDblChrset(newChrSet)));
	    HideCursor();

	    /* If switching from single-width, keep the cursor in the visible part
	     * of the line.
	     */
	    if (CSET_DOUBLE(newChrSet)) {
		width /= 2;
		if (curcol > width)
		    curcol = width;
	    }

	    /*
	     * ScrnRefresh won't paint blanks for us if we're switching between a
	     * single-size and double-size font.  So we paint our own.
	     */
	    ClearCurBackground(xw,
			       currow,
			       0,
			       1,
			       len,
			       (unsigned) LineFontWidth(screen, ld));

	    SetLineDblCS(ld, newChrSet);

	    set_cur_col(screen, 0);
	    ScrnUpdate(xw, currow, 0, 1, (int) len, True);
	    set_cur_col(screen, curcol);
	}
    }
}
예제 #7
0
파일: tabs.c 프로젝트: mullikine/xterm278
/*
 * Tab to the next stop, returning true if the cursor moved
 */
Bool
TabToNextStop(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int saved_column = screen->cur_col;
    int next = TabNext(xw, xw->tabs, screen->cur_col);
    int max = LineMaxCol(screen, getLineData(screen, screen->cur_row));

    if (next > max)
	next = max;
    set_cur_col(screen, next);

    return (screen->cur_col > saved_column);
}
 void DirectionReader::parseWedge( const core::DirectionType& directionType)
 {
     const auto& wedge = *directionType.getWedge();
     const auto& attr = *wedge.getAttributes();
     const auto wedgeType = myConverter.convert( attr.type );
     const bool isSpreadSpecified = attr.hasSpread;
     const long double spread = attr.spread.getValue();
     auto positionData = getPositionData( attr );
     auto lineData = getLineData( attr );
     auto colorData = getColor( attr );
     
     if( attr.type == core::WedgeType::stop )
     {
         api::WedgeStop stop;
         if( attr.hasNumber )
         {
             stop.numberLevel = attr.number.getValue();
         }
         if( isSpreadSpecified )
         {
             stop.isSpreadSpecified = true;
             stop.spread = spread;
         }
         stop.positionData = positionData;
         myOutDirectionData.wedgeStops.emplace_back( std::move( stop ) );
         return;
     }
     else
     {
         api::WedgeStart start;
         if( attr.hasNumber )
         {
             start.numberLevel = attr.number.getValue();
         }
         if( isSpreadSpecified )
         {
             start.isSpreadSpecified = true;
             start.spread = spread;
         }
         start.wedgeType = wedgeType;
         start.positionData = positionData;
         start.lineData = lineData;
         start.colorData = colorData;
         myOutDirectionData.wedgeStarts.emplace_back( std::move( start ) );
     }
 }
예제 #9
0
bool readFileOfNumbersAndStrings(string source_file, vector<vector <string> > &dataVec, int &numOfRows, int &numOfCols, string dataPattern) {
	ifstream filein;
	filein.open(source_file.c_str(), ios::in);
	if (!filein.is_open())
	{
		cout << "Error opening file" << endl;
		return false;
	}

	//read each line get the tokens, then push each line to 2d vector according to the datapattern
	//after read the file, the 2d vector holds the data
	//dataVec[i] has the ith col in the file
	string delim = "\"";
	string str;
	int lastCols=0;
	numOfCols = 0, 
	numOfRows = 0;
	//init the first level of the 2d vector 
	dataVec.resize(dataPattern.length());
	
	while(getline(filein, str)) {
		numOfCols = 0;
		vector<string> linevec;
		if(!getLineData(str, delim, linevec, dataPattern)) return false;//read line
		

		for (int i=0;i<dataPattern.length();i++) {
			dataVec[i].push_back(linevec[i]);
			numOfCols++;
		}

		if (lastCols!=0 && lastCols!=numOfCols) {
			cout << "error: there should be the same number of columns on each row"<<endl;
			return false;
		}
		lastCols = numOfCols;
		numOfRows++;
	}
		return true;
}
예제 #10
0
/*
 * moves the cursor forward n, no wraparound
 */
void
CursorForward(XtermWidget xw, int n)
{
    TScreen *screen = TScreenOf(xw);
#if OPT_DEC_CHRSET
    LineData *ld = getLineData(screen, screen->cur_row);
#endif
    int next = screen->cur_col + n;
    int max;

    if (IsLeftRightMode(xw)) {
	max = screen->rgt_marg;
	if (screen->cur_col > max)
	    max = screen->max_col;
    } else {
	max = LineMaxCol(screen, ld);
    }

    if (next > max)
	next = max;

    set_cur_col(screen, next);
    ResetWrap(screen);
}
예제 #11
0
파일: mclist.cpp 프로젝트: A-And/coreclr
bool MCList::processArgAsMCL(char* input, int* count, int** list)
{
    // If it contains only '0-9', '-', ',' try to see it as a range list, else try to load as a file
    bool isRangeList = true;

    size_t len = strlen(input);

    for (unsigned int i = 0; (i < len) && isRangeList; i++)
    {
        if ((input[i] != '-') && (input[i] != ',') && (!isdigit((unsigned char)input[i])))
            isRangeList = false;
    }

    if (isRangeList)
    {
        // Count items
        *count              = 0;
        unsigned rangeStart = 0;
        bool     inRange    = false;
        unsigned scratch    = 0;
        bool     foundDigit = false;

        char* tail = input + len;

        for (char* head = input; head <= tail; head++)
        {
            scratch    = 0;
            foundDigit = false;
            while ((head <= tail) && (isdigit((unsigned char)*head)))
            {
                scratch    = (scratch * 10) + ((*head) - '0');
                foundDigit = true;
                head++;
            }
            if (foundDigit)
            {
                if (inRange)
                {
                    inRange = false;
                    if (rangeStart >= scratch)
                    {
                        LogError("Invalid range in '%s'", input);
                        return false;
                    }
                    (*count) += scratch - rangeStart;
                }
                else
                {
                    rangeStart = scratch;
                    (*count)++;
                }
            }
            if (*head == '-')
                inRange = true;
        }

        if (*count == 0)
        {
            LogError("Didn't find a list!");
            return false;
        }

        inRange    = false;
        rangeStart = 0;

        int* ll   = new int[*count];
        *list     = ll;
        int index = 0;
        ll[index] = 0;

        for (char* head = input; head <= tail; head++)
        {
            scratch    = 0;
            foundDigit = false;
            while ((head <= tail) && (isdigit((unsigned char)*head)))
            {
                scratch    = (scratch * 10) + ((*head) - '0');
                foundDigit = true;
                head++;
            }
            if (foundDigit)
            {
                if (inRange)
                {
                    inRange = false;
                    for (unsigned int i = rangeStart + 1; i <= scratch; i++)
                        ll[index++]     = i;
                }
                else
                {
                    rangeStart  = scratch;
                    ll[index++] = scratch;
                }
            }
            if (*head == '-')
                inRange = true;
        }
        if (inRange)
        {
            LogError("Found invalid external range in '%s'", input);
            return false;
        }
        goto checkMCL;
    }
    else
    {
        char* lastdot = strrchr(input, '.');
        if (lastdot != nullptr && _stricmp(lastdot, ".mcl") == 0)
        {
            // Read MCLFile
            if (!getLineData(input, count, list))
                return false;
            if (*count >= 0)
                goto checkMCL;
        }
        return false;
    }

checkMCL: // check that mcl list is increasing only
    int* ll = (*list);
    if (ll[0] == 0)
    {
        LogError("MCL list needs to start from 1!");
        return false;
    }
    for (int i = 1; i < *count; i++)
    {
        if (ll[i - 1] >= ll[i])
        {
            LogError("MCL list must be increasing.. found %d -> %d", ll[i - 1], ll[i]);
            return false;
        }
    }
    return true;
}
예제 #12
0
static void
dumpSvgLine(XtermWidget xw, int row, FILE *fp)
{
    TScreen *s = TScreenOf(xw);
    int inx = ROW2INX(s, row);
    LineData *ld = getLineData(s, inx);
    int col, sal, i;		/* sal: same attribute length */

    if (ld == 0)
	return;

    for (col = 0; col < MaxCols(s); col += sal) {
	XColor fgcolor, bgcolor;

	/* Count how many consecutive cells have the same color & attributes. */
	for (sal = 1; col + sal < MaxCols(s); ++sal) {
#if OPT_ISO_COLORS
	    if (ld->color[col] != ld->color[col + sal])
		break;
#endif
	    if (ld->attribs[col] != ld->attribs[col + sal])
		break;
	}

	fgcolor.pixel = xw->old_foreground;
	bgcolor.pixel = xw->old_background;
#if OPT_ISO_COLORS
	if (ld->attribs[col] & FG_COLOR) {
	    unsigned fg = extract_fg(xw, ld->color[col], ld->attribs[col]);
	    fgcolor.pixel = s->Acolors[fg].value;
	}
	if (ld->attribs[col] & BG_COLOR) {
	    unsigned bg = extract_bg(xw, ld->color[col], ld->attribs[col]);
	    bgcolor.pixel = s->Acolors[bg].value;
	}
#endif

	XQueryColor(xw->screen.display, xw->core.colormap, &fgcolor);
	XQueryColor(xw->screen.display, xw->core.colormap, &bgcolor);
	if (ld->attribs[col] & BLINK) {
	    /* White on red. */
	    fgcolor.red = fgcolor.green = fgcolor.blue = 65535u;
	    bgcolor.red = 65535u;
	    bgcolor.green = bgcolor.blue = 0u;
	}
#if OPT_WIDE_ATTRS
	if (ld->attribs[col] & ATR_FAINT) {
	    fgcolor.red = (unsigned short) ((2 * fgcolor.red) / 3);
	    fgcolor.green = (unsigned short) ((2 * fgcolor.green) / 3);
	    fgcolor.blue = (unsigned short) ((2 * fgcolor.blue) / 3);
	}
#endif
	if (ld->attribs[col] & INVERSE) {
	    XColor tmp = fgcolor;
	    fgcolor = bgcolor;
	    bgcolor = tmp;
	}

	/* Draw the background rectangle. */
	fprintf(fp, "  <rect x='%d' y='%d' ", bw + ib + col * CELLW, bw + ib
		+ row * CELLH);
	fprintf(fp, "height='%d' width='%d' ", CELLH, sal * CELLW);
	fprintf(fp, "fill='rgb(%.2f%%, %.2f%%, %.2f%%)'/>\n", RGBPCT(bgcolor));

	/* Now the <text>. */
	/*
	 * SVG: Rendering text strings into a given rectangle is a challenge.
	 * Some renderers accept and do the right thing with the 'textLength'
	 * attribute, while others ignore it. The only predictable way to place
	 * (even monospaced) text properly is to do it character by character.
	 */

	fprintf(fp, "  <g");
	if (ld->attribs[col] & BOLD)
	    fprintf(fp, " font-weight='bold'");
#if OPT_WIDE_ATTRS
	if (ld->attribs[col] & ATR_ITALIC)
	    fprintf(fp, " font-style='italic'");
#endif
	fprintf(fp, " fill='rgb(%.2f%%, %.2f%%, %.2f%%)'>\n", RGBPCT(fgcolor));

	for (i = 0; i < sal; ++i) {
	    IChar chr = ld->charData[col + i];

	    if (chr == ' ')
		continue;
	    fprintf(fp, "   <text x='%d' y='%d'>", bw + ib + (col + i) *
		    CELLW, bw + ib + row * CELLH + (CELLH * 3) / 4);
#if OPT_WIDE_CHARS
	    if (chr > 127) {
		/* Ignore hidden characters. */
		if (chr != HIDDEN_CHAR) {
		    Char temp[10];
		    *convertToUTF8(temp, chr) = 0;
		    fputs((char *) temp, fp);
		}
	    } else
#endif
		switch (chr) {
		case 0:
		    /* This sometimes happens when resizing... ignore. */
		    break;
		case '&':
		    fputs("&amp;", fp);
		    break;
		case '<':
		    fputs("&lt;", fp);
		    break;
		case '>':
		    fputs("&gt;", fp);
		    break;
		default:
		    fputc((int) chr, fp);
		}
	    fprintf(fp, "</text>\n");
	}
	fprintf(fp, "  </g>\n");

#define HLINE(x) \
  fprintf(fp, "  <line x1='%d' y1='%d' " \
                      "x2='%d' y2='%d' " \
                  "stroke='rgb(%.2f%%, %.2f%%, %.2f%%)'/>\n", \
    bw + ib + col * CELLW,         bw + ib + row * CELLH + CELLH - (x), \
    bw + ib + (col + sal) * CELLW, bw + ib + row * CELLH + CELLH - (x), \
    RGBPCT(fgcolor))

	/* Now the line attributes. */
	if (ld->attribs[col] & UNDERLINE) {
	    HLINE(4);
	}
#if OPT_WIDE_ATTRS
	if (ld->attribs[col] & ATR_STRIKEOUT) {
	    HLINE(9);
	}
	if (ld->attribs[col] & ATR_DBL_UNDER) {
	    HLINE(3);
	    HLINE(1);
	}
#endif
    }
}