Changeset 2

Show
Ignore:
Timestamp:
01/25/06 14:55:17 (3 years ago)
Author:
krobillard
Message:

orca - Fixed read on Windows.
qt - Added append-text native.

Location:
trunk/orca
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/ChangeLog

    r1 r2  
    44V0.0.23 - ?? January 2005 
    55 
     6    * Foreach no longer creates a new context. Use 'rebol in config.r to 
     7       get the old behavior. 
    68    * Script header is now required. 
    79    * Implemented do/args. 
  • trunk/orca/files.c

    r1 r2  
    248248    if( a1->type == OT_FILE ) 
    249249    { 
     250        int n; 
    250251        const char* fn; 
    251252        OString* str = orSTRING(a1); 
     
    254255 
    255256        fn = str->charArray + a1->series.index; 
    256         if( orIsDir( fn ) ) 
     257        n = orIsDir( fn ); 
     258        if( n < 0 ) 
     259        { 
     260            goto read_error; 
     261        } 
     262        else if( n == 1 ) 
    257263        { 
    258264            orReadDir( fn ); 
     
    280286                FileHandle fp; 
    281287                OString* buf; 
    282                 int n; 
     288                int err; 
    283289                int size; 
    284290                int skip = 0; 
     
    323329 
    324330                    n = fileRead( fp, buf->buf, size ); 
     331                    err = fileError( fp ); 
    325332                    fileClose( fp ); 
    326333 
    327                     if( n != size ) 
     334                    if( err ) 
    328335                    { 
     336read_error: 
    329337                        orErrorT( OR_ERROR_ACCESS, "read failed on %s", fn ); 
    330338                        return; 
    331339                    } 
    332340 
    333                     buf->used = size; 
     341                    buf->used = n; 
    334342                    orResultSeries( orRefineSet(REF_READ_BINARY) ? 
    335343                                    OT_BINARY : OT_STRING, 
  • trunk/orca/qt/qorca.cpp

    r1 r2  
    99#include <QTabWidget> 
    1010#include <QMessageBox> 
     11#include <QTextCursor> 
    1112#include "qorca.h" 
    1213#include "cbparse.h" 
     
    791792#define REF_RF_SAVE    a1+1 
    792793#define REF_RF_DIR     a1+2 
     794#define REF_RF_INIT    a1+3 
     795#define REF_RF_PATH    a1+4 
    793796 
    794797static void requestFileNative( OValue* a1 ) 
    795798{ 
    796799    QString fn; 
     800    QString dir; 
    797801    OString* str; 
    798802    const char* cp; 
    799803 
     804    if( orRefineSet( REF_RF_INIT ) ) 
     805    { 
     806        OValue* ref = REF_RF_PATH; 
     807        str = orSTRING( ref ); 
     808        orCTermStr( str ); 
     809        dir = orStrChars( str, ref ); 
     810    } 
     811    else 
     812    { 
     813        dir = qEnv.filePath; 
     814    } 
     815 
    800816    str = orSTRING(a1); 
    801     cp = str->charArray + a1->series.index; 
     817    orCTermStr( str ); 
     818    cp = orStrChars( str, a1 ); 
    802819 
    803820    if( orRefineSet( REF_RF_DIR ) ) 
    804821    { 
    805         fn = QFileDialog::getExistingDirectory(0, QString(cp), qEnv.filePath); 
     822        fn = QFileDialog::getExistingDirectory(0, QString(cp), dir ); 
    806823    } 
    807824    else if( orRefineSet( REF_RF_SAVE ) ) 
    808825    { 
    809         fn = QFileDialog::getSaveFileName( 0, QString(cp), qEnv.filePath ); 
     826        fn = QFileDialog::getSaveFileName( 0, QString(cp), dir ); 
    810827    } 
    811828    else 
    812829    { 
    813         fn = QFileDialog::getOpenFileName( 0, QString(cp), qEnv.filePath ); 
     830        fn = QFileDialog::getOpenFileName( 0, QString(cp), dir ); 
    814831    } 
    815832 
     
    967984 
    968985 
     986static void appendTextNative( OValue* a1 ) 
     987{ 
     988    WIDPool::REC* rec = qEnv.pool.record( a1->integer ); 
     989    if( rec ) 
     990    { 
     991        const OValue* a2 = a1 + 1; 
     992 
     993        switch( rec->type ) 
     994        { 
     995            case WT_LineEdit: 
     996            { 
     997                QString cur; 
     998                QString txt; 
     999                valueToQString( a2, txt ); 
     1000                cur = ((QLineEdit*) rec->widget)->text(); 
     1001                cur.append( txt ); 
     1002                ((QLineEdit*) rec->widget)->setText( cur ); 
     1003            } 
     1004                break; 
     1005 
     1006            case WT_TextEdit: 
     1007            { 
     1008                QString txt; 
     1009                QTextCursor cursor; 
     1010 
     1011                valueToQString( a2, txt ); 
     1012 
     1013                QTextEdit* edit = (QTextEdit*) rec->widget; 
     1014 
     1015                cursor = edit->textCursor(); 
     1016                cursor.movePosition( QTextCursor::End ); 
     1017                cursor.insertText( txt ); 
     1018 
     1019                //edit->insertPlainText( txt ); 
     1020                //edit->append( txt );  // Adds linefeed before text. 
     1021            } 
     1022                break; 
     1023 
     1024            default: 
     1025                break; 
     1026        } 
     1027    } 
     1028} 
     1029 
     1030 
    9691031static void messageNative( OValue* a1 ) 
    9701032{ 
     
    10171079  "dialog: native [layout [block!]]\n" 
    10181080  "widget: native [layout [block!]]\n" 
    1019   "request-file: native [title [string!] /save /dir]\n" 
     1081  "request-file: native [title [string!] /save /dir /init path]\n" 
    10201082  "enable:   native [wid [integer!]]\n" 
    10211083  "disable:  native [wid [integer!]]\n" 
    10221084  "widget-value: native [wid [integer!]]\n" 
    10231085  "set-widget-value: native [wid [integer!] val]\n" 
     1086  "append-text: native [wid [integer!] val]\n" 
    10241087  "watch-dir: native [dir [string! file!] handler [block!]]\n" 
    10251088  "message: native [title [string!] msg [string!] /warn]\n" 
     
    10871150    orNative( (void*) widgetValueNative,    "widget-value" ); 
    10881151    orNative( (void*) setWidgetValueNative, "set-widget-value" ); 
     1152    orNative( (void*) appendTextNative,     "append-text" ); 
    10891153    orNative( (void*) messageNative,        "message" ); 
    10901154#ifdef DIR_WATCHER 
  • trunk/orca/unix/os.h

    r1 r2  
    4949#define fileWrite(fh,buf,len)   fwrite(buf,1,len,fh) 
    5050#define fileSeek(fh,off)        fseek(fh,off,SEEK_SET) 
     51#define fileError(fh)           ferror(fh) 
    5152 
    5253#ifdef __cplusplus 
  • trunk/orca/win32/os.h

    r1 r2  
    4949#define fileWrite(fh,buf,len)   fwrite(buf,1,len,fh) 
    5050#define fileSeek(fh,off)        fseek(fh,off,SEEK_SET) 
     51#define fileError(fh)           ferror(fh) 
    5152 
    5253#ifdef __cplusplus