Esempio n. 1
0
void SciDoc::moveDown() {
	if ( int_->curEdit_ == NULL ) return;

	if ( hasSelectedText() ) {
		int line1, line2, col1, col2;
		getSelection(line1, col1, line2, col2);

		int realLine2 = line2;
		if ( col2 == 0 )
			--line2;

		if ( line2 == lineCount() - 1 )
			return;

		int_->curEdit_->beginUndoAction();
		for (int line = line2 + 1; line >= line1 + 1; --line) {
			int_->curEdit_->setCursorPosition(line, 0);
			swapLines();
		}

		setSelection(line1 + 1, col1, realLine2 + 1, col2);
		int_->curEdit_->endUndoAction();
	}
	else {
		int line, col;
		int_->curEdit_->getCursorPosition(&line, &col);
		if ( line < lineCount() - 1 ) {
			int_->curEdit_->setCursorPosition(line + 1, 0);
			swapLines();
			int_->curEdit_->setCursorPosition(line + 1, col);
		}
	}
}
void Buffer::gotoBookmark(bool next) {
    // Try to find the bookmark, from the next/previous line
    int line = lineFromPosition(currentPos());
    int markerLine = -1;
    if (next) {
        line = (line == lineCount()) ? 0 : line + 1;
        markerLine = markerNext(line, 1 << Bookmark);
    } else {
        line = (line == 0 ? lineCount() : line - 1);
        markerLine = markerPrevious(line, 1 << Bookmark);
    }

     // Wrap search if a bookmark was not found.
    if (markerLine == -1) {
        if (next) {
            markerLine = markerNext(0, 1 << Buffer::Bookmark);
        } else {
            markerLine = markerPrevious(lineCount(), 1 << Buffer::Bookmark);
        }
    }

    // If the marker was found, go to the line.
    if (markerLine != -1) {
        gotoLine(markerLine);
    }
}
Esempio n. 3
0
Block *Block::takeLine(int line)
{
    if (line >= lineCount())
        return nullptr;
    m_changed = true;
    Block *to_return = new Block(m_screen);
    int start_index = line * m_width;
    int end_index = start_index + (m_width - 1);
    for (int i = 0; i < m_style_list.size(); i++) {
        ensureStyleAlignWithLines(i);
        TextStyleLine &current_style = m_style_list[i];
        if (current_style.start_index >= start_index && current_style.end_index <= end_index) {
            current_style.releaseTextSegment(m_screen);
            current_style.start_index -= start_index;
            current_style.end_index -= start_index;
            current_style.index_dirty = true;
            to_return->m_style_list.append(TextStyleLine(current_style, current_style.start_index,
                        current_style.end_index));
            m_style_list.remove(i);
            i--;
        } else if (current_style.start_index > end_index) {
            current_style.start_index -= (end_index + 1) - start_index;
            current_style.end_index -= (end_index + 1) - start_index;
            current_style.index_dirty = true;
            current_style.text_dirty = true;
        }
    }
    to_return->m_text_line = m_text_line.mid(start_index, m_width);
    m_text_line.remove(start_index, m_width);
    return to_return;
}
Esempio n. 4
0
File: block.cpp Progetto: ec1oud/yat
void Block::printStyleSpans(QDebug &debug) const
{
    debug << m_line << lineCount() << m_text_line.size() << (void *) this << '\t' << m_text_line;
    for (int i= 0; i < m_style_spans.size(); i++) {
        debug << m_style_spans.at(i);
    }
}
Esempio n. 5
0
File: block.cpp Progetto: ec1oud/yat
Block *Block::split(int line)
{
    if (line >= lineCount())
        return nullptr;
    m_changed = true;
    Block *to_return = new Block(m_screen);
    int start_index = line * m_width;
    for (int i = 0; i < m_style_spans.size(); i++) {
        ensureStyleAlignWithLines(i);
        TextStyleSpan &current_style = m_style_spans[i];
        if (current_style.start_index >= start_index) {
            current_style.start_index -= start_index;
            current_style.end_index -= start_index;
            current_style.index_dirty = true;
            current_style.text_dirty = true;
            current_style.index_dirty = true;
            to_return->m_style_spans.append(TextStyleSpan(current_style, current_style.start_index,
                        current_style.end_index));
            m_style_spans.remove(i);
            i--;
        }
    }
    to_return->m_text_line = m_text_line.mid(start_index, m_text_line.size() - start_index);
    m_text_line.remove(start_index, m_text_line.size() - start_index);
    return to_return;
}
Esempio n. 6
0
void SourceEditor::enableFolding()
{
    if (!foldingEnabled())
    {
        m_foldsData.resize(lineCount());

        GtkSourceView *view = gtkSourceView();
        GtkSourceGutter *gutter =
            gtk_source_view_get_gutter(view,
                                       GTK_TEXT_WINDOW_LEFT);
        m_foldsRenderer = gtk_source_gutter_renderer_pixbuf_new();
        gtk_source_gutter_insert(gutter,
                                 m_foldsRenderer,
                                 FOLD_POSITION);
        g_signal_connect(m_foldsRenderer, "activate",
                         G_CALLBACK(activateFold), this);
        g_signal_connect(m_foldsRenderer, "query-activatable",
                         G_CALLBACK(queryFoldActivatable), this);
        g_signal_connect(m_foldsRenderer, "query-data",
                         G_CALLBACK(queryFoldData), this);
        gtk_source_gutter_renderer_set_alignment_mode(
            m_foldsRenderer,
            GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_FIRST);
        gtk_source_gutter_renderer_set_size(m_foldsRenderer,
                                            measureLineHeight(view) - 2);
    }
}
Esempio n. 7
0
bool TextScrollModel::isHighlighted( int line ) const
{
  if ( line < 0 || line >= lineCount() ) return false;
  if ( d->data[line].pretty ) return true;
  if ( d->data[line].label.empty() ) return false;
  return true;  
}
Esempio n. 8
0
bool TextScrollModel::isCentered( int line ) const
{
  if ( line < 0 || line >= lineCount() ) {
    return false;
  }
  return d->data[line].pretty;
}
Esempio n. 9
0
ZString TextScrollModel::getLineData( int line ) const
{
  if ( line < 0 || line >= lineCount() ) {
    return ZString();
  }
  return d->data[line].label;
}
Esempio n. 10
0
ZString TextScrollModel::getLineMessage( int line ) const
{
  if ( line < 0 || line >= lineCount() ) {
    return ZString();
  }
  return d->data[line].message;
}
Esempio n. 11
0
void Block::printStyleList(QDebug &debug) const
{
    QString text_line = m_text_line;
    debug << "  " << m_line << lineCount() << m_text_line.size() << (void *) this << text_line << "\n"; debug << "\t";
    for (int i= 0; i < m_style_list.size(); i++) {
        debug << m_style_list.at(i);
    }
}
Esempio n. 12
0
AbstractScrollModel::Action TextScrollModel::getAction( int line ) const
{
  if ( line < 0 || line >= lineCount() ) return AbstractScrollModel::Close;

  if ( !d->data[line].label.empty() ) return AbstractScrollModel::SendMessage;

  return AbstractScrollModel::Close;
}
Esempio n. 13
0
	void TextEditor::scroll(float nbLines)
	{
		uint oldTopLine = pScrollPos.y;
		float newLineNb = ((float)pScrollPos.y > nbLines) ? (float)pScrollPos.y - nbLines : 0.0f;
		float maxLineNb = (float)lineCount();
		pScrollPos.y = (uint)Math::Min(maxLineNb - displayedLineCount(), newLineNb);
		if (oldTopLine != pScrollPos.y)
			invalidate();
	}
Esempio n. 14
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionHash(&argc, argv);
if (argc < 2)
    usage();
lineCount(argc-1, argv+1);
return 0;
}
Esempio n. 15
0
template<> bool
QConsoleWidget::_pf<bool, IsInEditorLastLine>(
        QConsoleWidget *  thisp) {
    auto doc_ = thisp->document();
    auto block_ = doc_->lastBlock();
    auto tpos = thisp->textCursor().position();
    if (block_.contains(tpos) == false) { return false; }
    auto blayout = block_.layout();
    if (blayout) {
        if (blayout->lineCount()) {
            auto line0 = blayout->lineAt(blayout->lineCount()-1);
            auto line1 = 
				blayout->lineForTextPosition(tpos - block_.position());
            return (line0.lineNumber() == line1.lineNumber());
        }
    }
    return false;
}
Esempio n. 16
0
int Buffer::getLineMarginWidth() {
    Configuration *configuration = Configuration::instance();
    int lineWidth = m_trackLineWidth ?
                lineCount() : configuration->lineMarginWidth();
    int width = ((int) std::log10(lineWidth)) + 1;
    QString text;
    text.fill('9', width).prepend('_');

    return textWidth(STYLE_LINENUMBER, text.toLatin1());
}
Esempio n. 17
0
void SciDoc::gotoLine(int line) {
	if ( int_->curEdit_ == NULL ) return;

	int lCount = lineCount();
	int_->curEdit_->ensureLineVisible( line >= 10 ? line-10 : 0 );
	int_->curEdit_->ensureLineVisible( line >= lCount - 10 ? lCount : line+10 );

	int_->curEdit_->setCursorPosition(line, 0);
	int_->curEdit_->setFocus();
}
Esempio n. 18
0
bool SciDoc::getTextLine(int line, QString& str) const {
	if ( int_->curEdit_ == NULL ) return false;

	if ( line >=0 && line < lineCount() ) {
		str = int_->curEdit_->text(line);
		return true;
	}
	else {
		return false;
	}
}
Esempio n. 19
0
Boolean MString::OK() const
{
    if (xmstring() == 0)
	return True;		// Null pointer

    // All of these must return some result.
    (void) isEmpty();
    (void) length();
    (void) lineCount();

    return True;
}
Esempio n. 20
0
void ScreenWindow::scrollTo( int line )
{
    //kDebug() << "ScreenWindow scrolled to " << line << ":" << this;
    if ( line < 0 )
       line = 0;

    if ( (lineCount() - windowLines()) < line )
       line = qMax(0,lineCount() - windowLines()); 

    const int delta = line - _currentLine;

    _currentLine = line;

    // keep track of number of lines scrolled by,
    // this can be reset by calling resetScrollCount()
    _scrollCount += delta;

	_bufferNeedsUpdate = true;

    emit scrolled(_currentLine);
}
void ScreenWindow::scrollTo( int line )
{
    int maxCurrentLineNumber = lineCount() - windowLines();
    line = qBound(0,line,maxCurrentLineNumber);

    const int delta = line - _currentLine;
    _currentLine = line;

    // keep track of number of lines scrolled by,
    // this can be reset by calling resetScrollCount()
    _scrollCount += delta;

    _bufferNeedsUpdate = true;

    emit scrolled(_currentLine);
}
Esempio n. 22
0
  /**
   * Construct a tile handler. This will determine a good chunk size to put
   *   into the output cube.
   *
   * @param dataFile The file with cube DN data in it
   * @param virtualBandList The mapping from virtual band to physical band, see
   *          CubeIoHandler's description.
   * @param labels The Pvl labels for the cube
   * @param alreadyOnDisk True if the cube is allocated on the disk, false
   *          otherwise
   */
  CubeTileHandler::CubeTileHandler(QFile * dataFile,
      const QList<int> *virtualBandList, const Pvl &labels, bool alreadyOnDisk)
      : CubeIoHandler(dataFile, virtualBandList, labels, alreadyOnDisk) {

    const PvlObject &core = labels.findObject("IsisCube").findObject("Core");

    if(core.hasKeyword("Format")) {
      setChunkSizes(core["TileSamples"], core["TileLines"], 1);
    }
    else {
      // up to 1MB chunks
      int sampleChunkSize =
          findGoodSize(512 * 4 / SizeOf(pixelType()), sampleCount());
      int lineChunkSize =
          findGoodSize(512 * 4 / SizeOf(pixelType()), lineCount());

      setChunkSizes(sampleChunkSize, lineChunkSize, 1);
    }
  }
Esempio n. 23
0
int main (int argc, char *argv[]) {
    FILE *source, *dest;
    pair currentPosition;
    int numLines, i;

    source = sourceIO(argc, argv);	// set the source using the correct filepath
    dest = destIO(argc, argv);		// set the destination filepath

    numLines = lineCount(source);	// get the number of lines in the source file
    source = sourceIO(argc, argv);	// resource the input stream;

    statement statements[numLines];

    parseStatements(source, statements);

    fprintf(dest, "# MIPS program automatically generated\n# from PostScript commands in the file %s\n", argv[1]);
    fprintf(dest, DATA_SEGMENT);
    fprintf(dest, WARN_BEGIN);
    fprintf(dest, "main:");

    // code generation takes place
    for (i = 0; i <= numLines; i++) {
        printf("Building move for line %d, %u(%d, %d)\n", i, statements[i].identity, statements[i].pair.x, statements[i].pair.y);
        currentPosition = generateNextMove(dest, statements[i], currentPosition);
    }

    fprintf(dest, "\t\t\tli\t\t$v0,10\n\t\t\tsyscall\n");
    fprintf(dest, WARN_END);

    // add the horiz and vert methods
    fprintf(dest, METHOD_SEGMENT);
    // add the diag method
    fprintf(dest, DIAG_SEGMENT);

    // clean up
    fclose(source);
    fclose(dest);
}
Esempio n. 24
0
void Block::removeLine(int line)
{
    if (line >= lineCount())
        return;

    m_changed = true;
    int start_index = line * m_width;
    int end_index = start_index + (m_width - 1);
    for (int i = 0; i < m_style_list.size(); i++) {
        ensureStyleAlignWithLines(i);
        TextStyleLine &current_style = m_style_list[i];
        if (current_style.start_index >= start_index && current_style.end_index <= end_index) {
            current_style.releaseTextSegment(m_screen);
            m_style_list.remove(i);
            i--;
        } else if (current_style.start_index > end_index) {
            current_style.start_index -= (end_index + 1) - start_index;
            current_style.end_index -= (end_index + 1) - start_index;
            current_style.index_dirty = true;
            current_style.text_dirty = true;
        }
    }
    m_text_line.remove(start_index, m_width);
}
Esempio n. 25
0
int main()
{
     FILE *pFile = NULL;
     int lineCnt = 0;
     int i = 0;
     ipList_t* ipList = NULL;

    /*thread pool 갯수 지정 */
     threadpool thpool = thpool_init(THREAD_CNT);

    /* 읽을 파일의 라인수를 체크 */
    lineCnt = lineCount(CHECKLIST_FILE_PATH);

    printf("lineCnt :[%d] \n",lineCnt);

    ipList = (ipList_t*)malloc(sizeof(ipList_t)*(lineCnt+10));
    memset(ipList,0x00, sizeof(ipList_t)*(lineCnt+10));
   
   
    pFile = fopen( CHECKLIST_FILE_PATH, "r" );
    
    if( pFile != NULL )
    {
        char strTemp[255];
        char *pStr;

        while( !feof( pFile ) )
        {
            char* ss = NULL;
            pStr = fgets( strTemp, sizeof(strTemp), pFile ); 
			
            printf( "pStr:[%s] \n", pStr );
            printf( "strTemp:[%s] \n", strTemp );

            if(pStr != NULL)
            {
                pStr = rtrim(pStr);
                char* trimStr;

                //strncpy((ipList+i)->ip, pStr, STR_LEN); //ipList+0 번째가 깨진다.
                strcpy((ipList+i)->ip, pStr);
                 i++;
                
            }
        }

        fclose( pFile );
    }

    for(i =0 ;i < lineCnt;i++)
    {
        printf("ipList[%d]:[%s] \n",i,(ipList+i)->ip);
        thpool_add_work(thpool, (void*)pingChk, (ipList+i)->ip);
    }

    

    thpool_wait(thpool);

    thpool_destroy(thpool);

    free(ipList);

#if 0
    pthread_t p_thread[THREAD_CNT]; 
    int thr_id; //쓰레드ID
    int status;

    //char p1[] = "thread_1";   // 1번 쓰레드 이름
    //char p2[] = "thread_2";   // 2번 쓰레드 이름
    //char pM[] = "thread_m";   // 메인 쓰레드 이름
 
        // 파일 읽기
        if(fRead() == ERROR)
        {
            printf("FRead Error \n");        }
        Fread();





    sleep(2);  // 2초 대기후 쓰레드 생성
 


    sys

    // ① 1번 쓰레드 생성
    // 쓰레드 생성시 함수는 t_function
    // t_function 의 매개변수로 p1 을 넘긴다.  
    thr_id = pthread_create(&p_thread[0], NULL, t_function, (void *)p1);

    // pthread_create() 으로 성공적으로 쓰레드가 생성되면 0 이 리턴됩니다
    if (thr_id < 0)
    {
        perror("thread create error : ");
        exit(0);
    }
 
    // ② 2번 쓰레드 생성
    thr_id = pthread_create(&p_thread[1], NULL, t_function, (void *)p2);
    if (thr_id < 0)
    {
        perror("thread create error : ");
        exit(0);
    }
 
    // ③ main() 함수에서도 쓰레드에서 돌아가고 있는 동일한 함수 실행
    //t_function((void *)pM);
 
    // 쓰레드 종료를 기다린다. 
    pthread_join(p_thread[0], (void **)&status);
    pthread_join(p_thread[1], (void **)&status);
 
    printf("언제 종료 될까요?\n");
 #endif

    return SUCCESS;
}
Esempio n. 26
0
/*
 * Main function of the program. First checks if a valid number of arguments is given. If there are more than 2 arguments and the first argument is not -p (where a 2nd argument HAS to be given) or there is an additional argument after the -p <word> arguments, an error is printed.
 * Otherwise, the program opens the test.dat file in read mode.
 * If the file cannot be found, an error is printed and the program exits.
 * Otherwise, the file is closed (for memory conservation) and the program loops through the command line arguments to evaluate which function should be called and executed.
 */
int main(int argc, char *argv[])
{
	int i;
	int functionCount = 0;
	if(argc == 1 || (argc > 2 && (strcmp(argv[1],"-p")!=0 || argv[3] != NULL))) /*If no input arguments are given, if there's more than 2 arguments given and the first argument is not a -p (meaning another argument has to be included with it) OR there's more than 3 arguments passed to the program:*/
	{
			fprintf(stderr,"Error: Invalid number of arguments passed.\n"); /*Standard error is printed and help function is run as dictated by instructions.*/
			help();
	}
	else /*If argument checks are OK, open the test.dat file in read only mode.*/
	{
		FILE *testdat = fopen("test.dat","r");
		if(testdat == NULL) /*If the test.dat file does not exist, an error is printed and program is terminated.*/
		{
			fprintf(stderr,"Error: File cannot be found.\n");
			exit(0);
		}
		else /*If the program can open the file, it closes it to save space.*/
		{
			fclose(testdat);
			for(i=0; i < argc; i++) /*Loops through each input argument*/
			{
				if(strcmp(argv[i],"-p") == 0) /*If argument is -p and a word is given after -p by the user, the test.dat file is opened and the prefix function is run.*/
				{
					if(argv[i+1] != NULL)
					{
						testdat = fopen("test.dat","r");
						functionCount++;
						prefix(argv[i+1], testdat);
					}
					else /*Otherwise, an error is given.*/
					{
						functionCount++;
						fprintf(stderr,"Error: Need to define an input word.\n");
					}
				}
				if(strcmp(argv[i],"-w") == 0) /*If argument is -w, the test.dat file is opened and the wordCount function is executed.*/
				{
					testdat = fopen("test.dat","r");
					functionCount++;
					wordCount(testdat);
				}
				if(strcmp(argv[i],"-l") == 0) /*If argument is -l, the test.dat file is opened and the lineCount function is executed.*/
				{
					testdat = fopen("test.dat","r");
					functionCount++;
					lineCount(testdat);
				}
				if(strcmp(argv[i],"-h") == 0) /*If argument is -h, the help function is executed.*/
				{
					functionCount++;
					help();
				}
			}
			if (functionCount == 0) /*If no valid input arguments are passed to the program,*/
			{
				fprintf(stderr,"Error: No valid input arguments given.\n");
				help();
			}
		}
	}
	return 0; /*In order to meet C standards, the main function must return an int. 0 indicates successful program execution.*/
}
Esempio n. 27
0
int QDeclarativeText::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 17)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 17;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 3: *reinterpret_cast< TextStyle*>(_v) = style(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = styleColor(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< bool*>(_v) = truncated(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumLineCount(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< TextElideMode*>(_v) = elideMode(); break;
        case 13: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 14: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 15: *reinterpret_cast< qreal*>(_v) = lineHeight(); break;
        case 16: *reinterpret_cast< LineHeightMode*>(_v) = lineHeightMode(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 2: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setStyle(*reinterpret_cast< TextStyle*>(_v)); break;
        case 4: setStyleColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 10: setMaximumLineCount(*reinterpret_cast< int*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setElideMode(*reinterpret_cast< TextElideMode*>(_v)); break;
        case 15: setLineHeight(*reinterpret_cast< qreal*>(_v)); break;
        case 16: setLineHeightMode(*reinterpret_cast< LineHeightMode*>(_v)); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        case 10: resetMaximumLineCount(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 17;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Esempio n. 28
0
void SciDoc::onLineCountChanged() {
	emit lineCountChanged(lineCount());
}
bool ScreenWindow::atEndOfOutput() const
{
    return currentLine() == (lineCount()-windowLines());
}
int ScreenWindow::currentLine() const
{
    return qBound(0,_currentLine,lineCount()-windowLines());
}