U_CFUNC int32_t removeCmtText(UChar* source, int32_t srcLen, UErrorCode* status){ srcLen = trim(source, srcLen, status); UnicodeString patString("^\\s*?\\*\\s*?"); // remove pattern like " * " at the begining of the line srcLen = removeText(source, srcLen, patString, UREGEX_MULTILINE, UnicodeString(), status); return removeText(source, srcLen, UnicodeString("[ \\r\\n]+"), 0, UnicodeString(" "), status);// remove new lines; }
U_CFUNC int32_t trim(UChar *src, int32_t srcLen, UErrorCode *status){ srcLen = removeText(src, srcLen, UnicodeString("^[ \\r\\n]+ "), 0, UnicodeString(), status); // remove leading new lines srcLen = removeText(src, srcLen, UnicodeString("^\\s+"), 0, UnicodeString(), status); // remove leading spaces srcLen = removeText(src, srcLen, UnicodeString("\\s+$"), 0, UnicodeString(), status); // remvoe trailing spcaes return srcLen; }
bool KileScriptDocument::truncate(int line, int column) { QString textline = m_document->line(line); if ( textline.isEmpty() || textline.length()<column ) { return false; } return removeText( KTextEditor::Range(line,column,line,textline.length()) ); }
void TextGraphics::initTextItem() { rot = false; firstRot = true; setZValue(TEXT_Z_VALUE); actionRemove = new QAction(tr("Retirer"), this); connect(actionRemove, SIGNAL(triggered()), this, SLOT(removeText())); item = new QGraphicsTextItem(this); refreshItemText(); item->setFont(QFont("Times", 48, QFont::Bold)); setFlag(ItemIsMovable); setFlag(ItemIsFocusable); setFlag(ItemIsSelectable); }
ImageTextEditor::ImageTextEditor( QImage& i, QWidget *parent, const char *name, WFlags f ) : QDialog(parent,name,TRUE,f), image(i) { QVBoxLayout* vbox = new QVBoxLayout(this,8); vbox->setAutoAdd(TRUE); QGrid* controls = new QGrid(3,QGrid::Horizontal,this); controls->setSpacing(8); QLabel* l; l=new QLabel("Language",controls); l->setAlignment(AlignCenter); l=new QLabel("Key",controls); l->setAlignment(AlignCenter); (void)new QLabel("",controls); // dummy languages = new QComboBox(controls); keys = new QComboBox(controls); QPushButton* remove = new QPushButton("Remove",controls); newlang = new QLineEdit(controls); newkey = new QLineEdit(controls); QPushButton* add = new QPushButton("Add",controls); text = new QMultiLineEdit(this); QHBox* hbox = new QHBox(this); QPushButton* cancel = new QPushButton("Cancel",hbox); QPushButton* ok = new QPushButton("OK",hbox); connect(add,SIGNAL(clicked()), this,SLOT(addText())); connect(remove,SIGNAL(clicked()), this,SLOT(removeText())); connect(ok,SIGNAL(clicked()), this,SLOT(accept())); connect(cancel,SIGNAL(clicked()), this,SLOT(reject())); connect(languages,SIGNAL(activated(int)), this,SLOT(updateText())); connect(keys,SIGNAL(activated(int)), this,SLOT(updateText())); imageChanged(); }
KateLayoutCache::KateLayoutCache(KateRenderer* renderer, QObject* parent) : QObject(parent) , m_renderer(renderer) , m_startPos(-1,-1) , m_viewWidth(0) , m_wrap(false) , m_acceptDirtyLayouts (false) { Q_ASSERT(m_renderer); /** * connect to all possible editing primitives */ connect(&m_renderer->doc()->buffer(), SIGNAL(lineWrapped(KTextEditor::Cursor)), this, SLOT(wrapLine(KTextEditor::Cursor))); connect(&m_renderer->doc()->buffer(), SIGNAL(lineUnwrapped(int)), this, SLOT(unwrapLine(int))); connect(&m_renderer->doc()->buffer(), SIGNAL(textInserted(KTextEditor::Cursor,QString)), this, SLOT(insertText(KTextEditor::Cursor,QString))); connect(&m_renderer->doc()->buffer(), SIGNAL(textRemoved(KTextEditor::Range,QString)), this, SLOT(removeText(KTextEditor::Range))); }
bool KileScriptDocument::removeText(const KTextEditor::Cursor& from, const KTextEditor::Cursor& to) { return removeText(KTextEditor::Range(from, to)); }
bool KileScriptDocument::removeText(int fromLine, int fromColumn, int toLine, int toColumn) { return removeText(KTextEditor::Range(fromLine, fromColumn, toLine, toColumn)); }
void genericAction(char *tmpBuffer, int size, char c) { if(isControl()) { toggleControl(); setPressedChar(c); // control character switch(c) { case 'x':// cut // make sure highlight bounds are correct if(beginHighlight == -1 || endHighlight == -1) { return; } if(beginHighlight > endHighlight) { quickSwap(&beginHighlight, &endHighlight); } // perform cut setClipboardRange(tmpBuffer, beginHighlight, endHighlight); removeText(tmpBuffer, size); moveKBCursorAbsolute(beginHighlight); // reset the edit mode clearFakeHighlight(); select = 0; break; case 'c':// copy // make sure highlight bounds are correct if(beginHighlight == -1 || endHighlight == -1) { return; } if(beginHighlight > endHighlight) { quickSwap(&beginHighlight, &endHighlight); } // perform copy setClipboardRange(tmpBuffer, beginHighlight, endHighlight); // reset the edit mode clearFakeHighlight(); select = 0; break; case 'v':// paste if(beginHighlight != -1 && endHighlight != -1) { if(beginHighlight > endHighlight) { quickSwap(&beginHighlight, &endHighlight); } // we need to overwrite, but first check to make sure we don't overdo it if(strlen(tmpBuffer) - (endHighlight - beginHighlight) + strlen(getClipboard()) > size) { // after removing the current text and adding the new text, we are going over the size return; } // remove the current text removeText(tmpBuffer, size); moveKBCursorAbsolute(beginHighlight); clearFakeHighlight(); select = 0; // cursor is now where we want to add the new text // we know also that there is enough room, so just insert the text // ensure we are inserting, even if overwrite uint16 tInsert = insert; insert = 1; char *tAdd = getClipboard(); // loop and add chars while(*tAdd != 0) { insertChar(tmpBuffer, size, *tAdd); tAdd++; } // reset insert insert = tInsert; } else { if(strlen(tmpBuffer) + strlen(getClipboard()) > size) { // after adding the new text, we are going over the size return; } clearFakeHighlight(); select = 0; // add the text char *tAdd = getClipboard(); // loop and add chars while(*tAdd != 0) { insertChar(tmpBuffer, size, *tAdd); tAdd++; } } break; } } else { if(getKBCursor() < 0) { moveKBCursorAbsolute(0); } else if(getKBCursor() >= size) { moveKBCursorAbsolute(size - 1); } if(beginHighlight != -1 && endHighlight != -1) { if(beginHighlight > endHighlight) { quickSwap(&beginHighlight, &endHighlight); } // we have to clear out the data before performing the action removeText(tmpBuffer, size); // move the cursor moveKBCursorAbsolute(beginHighlight); // reset the edit mode clearFakeHighlight(); select = 0; if(c == BSP || c == DEL) { // we've done the work required, exit return; } } if(c == BSP) { // backspace if(getKBCursor() == 0) // handle backspacing nothing { return; } int z; for(z=getKBCursor()-1;z<=size;z++) { tmpBuffer[z] = tmpBuffer[z+1]; } moveKBCursorRelative(CURSOR_BACKWARD); } else if(c == DEL) { // del if(tmpBuffer[getKBCursor()] == 0) // handle deleting nothing { return; } moveKBCursorRelative(CURSOR_FORWARD); int z; for(z=getKBCursor()-1;z<=size;z++) { tmpBuffer[z] = tmpBuffer[z+1]; } moveKBCursorRelative(CURSOR_BACKWARD); } else { // normal add insertChar(tmpBuffer, size, c); } tmpBuffer[size] = 0; } }