Ejemplo n.º 1
0
bool mainWidget::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: slotLoadMainConfig((const QString&)static_QUType_QString.get(_o+1)); break;
    case 1: slotFileOpen(); break;
    case 2: chooseOpenFile(); break;
    case 3: slotClickedListViewItem((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 4: slotFileSave(); break;
    case 5: aboutSlot(); break;
    case 6: slotReloadMainConfig(); break;
    case 7: slotAskForSave(); break;
    case 8: commentLine(); break;
    case 9: closeClicked(); break;
    case 10: languageChange(); break;
    default:
	return QMainWindow::qt_invoke( _id, _o );
    }
    return TRUE;
}
Ejemplo n.º 2
0
/*
remove comments
*/
void rcomment()
{
	printf("remove comments /* test */");
	int c, d;
	while ((c = getchar()) != EOF) {
		switch (c) {
			case '/':
				d = getchar();
				if (d == '/') commentLine();
				else if (d == '*') comment();
				else {
					putchar(c);
					putchar(d);
				}
				break;
			case '\'':
			case '"':
				quote(c);
				break;
			default:
				putchar(c);
		}
	}
}
Ejemplo n.º 3
0
void SciDoc::toggleCommentLines() {
//	LOGGER;

	JuffScintilla* edit = int_->curEdit_;
	if ( edit == NULL ) return;

	QString comment;
	QString s = syntax();
	if ( s == "C++" || s == "PHP" || s == "C#" || s == "Java" || s == "JavaScript" )
		comment = "//";
	else if ( s == "Bash" || s == "Python" || s == "CMake" || s == "Makefile" || s == "Perl")
		comment = "#";
	else if ( s == "Fortran" )
		comment = "!";
	else if ( s == "SQL")
		comment = "--";
	else if ( s == "Qore" || s == "Qorus")
		comment = "#";
	//	TODO : need to add more syntaxes

	if ( comment.isEmpty() )
		return;

	if ( edit->hasSelectedText() ) {
		int line1, col1, line2, col2, curLine, curCol;
		edit->getSelection(&line1, &col1, &line2, &col2);
		edit->getCursorPosition(&curLine, &curCol);

		QString str1 = edit->text(line1);
		QString ln = str1.simplified();
		bool toComment = true;
		if ( ln.startsWith(comment) ) {
			toComment = false;
		}

		if ( col2 == 0 )
			--line2;

		edit->beginUndoAction();
		for ( int line = line1; line <= line2; ++line ) {
			str1 = edit->text(line);
			if ( toComment ) {
				if ( !str1.simplified().startsWith(comment) )
					commentLine(edit, line, str1, comment);
			}
			else {
				if ( str1.simplified().startsWith(comment) )
					uncommentLine(edit, line, str1, comment);
			}
		}
		edit->endUndoAction();
		if ( curCol > 0 )
			edit->setCursorPosition(curLine, curCol + comment.length() * (toComment ? 1 : -1) );
		else
			edit->setCursorPosition(curLine, curCol);
	}
	else {
		int line1, col1;
		edit->getCursorPosition(&line1, &col1);
		QString str1 = edit->text(line1);

		QString ln = str1.simplified();
		if ( ln.startsWith(comment) ) {
			uncommentLine(edit, line1, str1, comment);
			edit->setCursorPosition(line1, col1 - comment.length());
		}
		else {
			commentLine(edit, line1, str1, comment);
			edit->setCursorPosition(line1, col1 + comment.length());
		}
	}
}