예제 #1
0
TEditor::TEditor( const TRect& bounds,
                  TScrollBar *aHScrollBar,
                  TScrollBar *aVScrollBar,
                  TIndicator *aIndicator,
                  size_t aBufSize ) :
    TView( bounds ),
    hScrollBar( aHScrollBar ),
    vScrollBar( aVScrollBar ),
    indicator( aIndicator ),
    bufSize( aBufSize ),
    canUndo( True ),
    selecting( False ),
    overwrite( False ),
    autoIndent( False ) ,
    lockCount( 0 ),
    keyState( 0 )
{
    growMode = gfGrowHiX | gfGrowHiY;
    options |= ofSelectable;
    eventMask = evMouseDown | evKeyDown | evCommand | evBroadcast;
    showCursor();
    initBuffer();
    if( buffer != 0 )
        isValid = True;
    else
    {
        editorDialog( edOutOfMemory );
        bufSize = 0;
        isValid = False;
    }
    setBufLen(0);
}
void *TEditor::read( ipstream& is )
{
    TView::read( is );
    int temp;
    is >> hScrollBar >> vScrollBar >> indicator
       >> bufSize >> temp;
    canUndo = Boolean(temp);
    selecting = False;
    overwrite = False;
    autoIndent = False; 
    lockCount = 0;
    keyState = 0;
    initBuffer();
    if( buffer != 0 )
        isValid = True;
    else
        {
        TEditor::editorDialog( edOutOfMemory, 0 );
        bufSize = 0;
        }
    lockCount = 0; 
    lock();
    setBufLen( 0 );
    return this;
}
예제 #3
0
파일: TFILEDTR.cpp 프로젝트: gdobra/tvision
Boolean TFileEditor::loadFile()
{
    ifstream f( fileName, ios::in | ios::binary );
    if( !f )
        {
        setBufLen( 0 );
        return True;
        }
    else
        {
        streampos crtpos = f.tellg();
        f.seekg(0, ios_base::end);
        long fSize = f.tellg();
        f.seekg(crtpos);
        if ( setBufSize(ulong(fSize)) == false )
            {
            editorDialog( edOutOfMemory );
            return False;
            }
        else
            {
            if ( fSize > INT_MAX )
            {
               f.read( &buffer[bufSize - ulong(fSize)], INT_MAX );
               f.read( &buffer[bufSize - ulong(fSize) + INT_MAX],
                                ulong(fSize - INT_MAX) );

            }
            else
               f.read( &buffer[bufSize - ulong(fSize)], ulong(fSize) );
            if( !f )
                {
                editorDialog( edReadError, fileName );
                return False;
                }
            else
                {
                setBufLen(ulong(fSize));
                return True;
                }
            }
        }
}
예제 #4
0
Boolean TFileEditor::loadFile()
{
    ifstream f( fileName, ios::in | ios::binary );
    if( !f )
        {
        setBufLen( 0 );
        return True;
        }
    else
        {
        long fSize = filelength( f.rdbuf()->fd() );
        if( fSize > (UINT_MAX-0x1F) || setBufSize(ushort(fSize)) == False )
            {
            editorDialog( edOutOfMemory );
            return False;
            }
        else
            {
            if ( fSize > INT_MAX )
            {
               f.read( &buffer[bufSize - size_t(fSize)], INT_MAX );
               f.read( &buffer[bufSize - size_t(fSize) + INT_MAX],
                                size_t(fSize - INT_MAX) );

            }
            else
               f.read( &buffer[bufSize - size_t(fSize)], size_t(fSize) );
            if( !f )
                {
                editorDialog( edReadError, fileName );
                return False;
                }
            else
                {
                setBufLen(size_t(fSize));
                return True;
                }
            }
        }
}