Boolean TEditor::insertFrom( TEditor *editor ) { return insertBuffer( editor->buffer, editor->bufPtr(editor->selStart), editor->selEnd - editor->selStart, canUndo, isClipboard() ); }
Boolean TFileEditor::saveAs() { Boolean res = False; if( editorDialog( edSaveAs, fileName ) != cmCancel ) { fexpand( fileName ); message( owner, evBroadcast, cmUpdateTitle, 0 ); res = saveFile(); if( isClipboard() == True ) *fileName = EOS; } return res; }
void TEditor::updateCommands() { setCmdState( cmUndo, Boolean( delCount != 0 || insCount != 0 ) ); if( isClipboard() == False ) { setCmdState(cmCut, hasSelection()); setCmdState(cmCopy, hasSelection()); setCmdState(cmPaste, Boolean(clipboard != 0 && (clipboard->hasSelection())) ); } setCmdState(cmClear, hasSelection()); setCmdState(cmFind, True); setCmdState(cmReplace, True); setCmdState(cmSearchAgain, True); }
/*! Insert a Block into the document Uses appropriate function for clipboard or file */ bool IE_Imp_Text::_insertBlock() { bool ret = false; m_bBlockDirectionPending = true; m_bFirstBlockData = true; if (isClipboard ()) // intentional - don't append style // information { ret = appendStrux(PTX_Block, NULL); } else { // text gets applied in the Normal style const gchar * propsArray[3]; propsArray[0] = "style"; propsArray[1] = "Normal"; propsArray[2] = 0; ret = appendStrux(PTX_Block, static_cast<const gchar **>(&propsArray[0])); } if(!isPasting()) { pf_Frag * pf = getDoc()->getPieceTable()->getFragments().getLast(); UT_return_val_if_fail( pf->getType() == pf_Frag::PFT_Strux, false); m_pBlock = (pf_Frag_Strux *) pf; UT_return_val_if_fail( m_pBlock->getStruxType() == PTX_Block, false); } else { PL_StruxDocHandle sdh = NULL; if(getDoc()->getStruxOfTypeFromPosition(getDocPos(), PTX_Block,&sdh)) { m_pBlock = static_cast<pf_Frag_Strux *>(const_cast<void *>(sdh)); } else { m_pBlock = NULL; } } return ret; }
Boolean TEditor::insertBuffer( char *p, ushort offset, ushort length, Boolean allowUndo, Boolean selectText ) { selecting = False; ushort selLen = selEnd - selStart; if( selLen == 0 && length == 0 ) return True; ushort delLen = 0; if( allowUndo == True ) if( curPtr == selStart ) delLen = selLen; else if( selLen > insCount ) delLen = selLen - insCount; long newSize = long(bufLen + delCount - selLen + delLen) + length; if( newSize > bufLen + delCount ) if( newSize > 0xFFE0l || setBufSize(ushort(newSize)) == False ) { editorDialog( edOutOfMemory ); return False; } ushort selLines = countLines( &buffer[bufPtr(selStart)], selLen ); if( curPtr == selEnd ) { if( allowUndo == True ) { if( delLen > 0 ) memmove( &buffer[curPtr + gapLen - delCount - delLen], &buffer[selStart], delLen ); insCount -= selLen - delLen; } curPtr = selStart; curPos.y -= selLines; } if( delta.y > curPos.y ) { delta.y -= selLines; if( delta.y < curPos.y ) delta.y = curPos.y; } if( length > 0 ) memmove( &buffer[curPtr], &p[offset], length ); ushort lines = countLines( &buffer[curPtr], length ); curPtr += length; curPos.y += lines; drawLine = curPos.y; drawPtr = lineStart(curPtr); curPos.x = charPos(drawPtr, curPtr); if( selectText == False ) selStart = curPtr; selEnd = curPtr; bufLen += length - selLen; gapLen -= length - selLen; if( allowUndo == True ) { delCount += delLen; insCount += length; } limit.y += lines - selLines; delta.y = max(0, min(delta.y, limit.y - size.y)); if( isClipboard() == False ) modified = True; setBufSize(bufLen + delCount); if( selLines == 0 && lines == 0 ) update(ufLine); else update(ufView); return True; }