Exemple #1
0
static void sendNewColour( NewColourOps op )
{
    type_style  *mod_style;

    if( BAD_ID( mod_wid ) ) {
        return;
    }

    if( mod_wid == GetToolbarWindow() ) {
        sendNewColourToolbar();
    } else if( mod_wid == current_window_id ) {
        sendNewColourCurrentWindow( op );
    } else {
        mod_style = WIN_TEXT_STYLE( WINDOW_FROM_ID( mod_wid ) );
        if( op == NC_FORE ) {
            mod_style->foreground = INDEX_FROM_XY( cursx, cursy );
        } else {
            mod_style->background = INDEX_FROM_XY( cursx, cursy );
        }
        StatusWndChangeSysColors( RGBValues[statusw_info.text_style.background],
                                  RGBValues[statusw_info.text_style.foreground],
                                  GetSysColor( COLOR_BTNHIGHLIGHT ),
                                  GetSysColor( COLOR_BTNSHADOW ) );
        ReDisplayScreen();
    }
}
Exemple #2
0
static void putMessage( void )
{
    if( needsRedisplay ) {
        ReDisplayScreen();
        needsRedisplay = FALSE;
    }
    Message1( msgString );
}
Exemple #3
0
static void sendNewColourCurrentWindow( NewColourOps op )
{
    /* the edit window has various components in the form of syntax
       elements - figure which we are on & mod SETypes
    */
    int             row, col;
    syntax_element  style;
    vi_color        color;
    syntax_element  i;
    linenum         line_num;

    ScreenToClient( mod_wid, &m_pt );
    ClientToRowCol( mod_wid, m_pt.x, m_pt.y, &row, &col, DIVIDE_BETWEEN );

    /* someone is base 0, someone else isn't.  bummer.
     * also col may not be valid, check this
    */
    if( col < 1 ) {
        return;
    }
    col--;

    // SStyle expect real not virtual columns!
    // Hmmm.
    line_num = (linenum)(LeftTopPos.line + row - 1);
    col = RealCursorPositionOnLine( line_num, col );


    style = SSGetStyle( row, col );
    if( style == SE_UNPARSED ) {
        // for some reason, area was not defined
        return;
    }

    color = INDEX_FROM_XY( cursx, cursy );
    if( CtrlDown() ) {
        // affect all foregrounds/backgrounds
        for( i = 0; i < SE_NUMTYPES; i++ ) {
            // doesn't make sense to change selection
            if( i == SE_SELECTION ) {
                continue;
            }
            if( op == NC_FORE ) {
                SEType[i].foreground = color;
            } else {
                SEType[i].background = color;
            }
        }
    } else {
        if( op == NC_FORE ) {
            SEType[style].foreground = color;
        } else {
            SEType[style].background = color;
        }
    }
    ReDisplayScreen();
}
Exemple #4
0
/*
 * SetUpFont - set up a font, once it has been selected
 */
void SetUpFont( LOGFONT *l, font_type index )
{
    info        *cinfo;
    font        *f;

    f = &Fonts[index];

    customFont( f, l );
    for( cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) {
        DCResize( cinfo );
    }
    ResizeRoot();
    ResetExtraRects();
    if( EditFlags.WindowsStarted ) {
        ReDisplayScreen();
    }

} /* SetUpFont */
Exemple #5
0
static void postSpawn( long rc )
{
    restorePrompt();
    VarAddGlobalLong( "Sysrc", rc );
    UpdateCurrentDirectory();

#ifndef __WIN__
    ResetColors();
    // if( (EditFlags.PauseOnSpawnErr && rc != 0 ) ||
    //          !EditFlags.SourceScriptActive ) {
    if( EditFlags.PauseOnSpawnErr && rc != 0 ) {
        MyPrintf( "[%s]\n", MSG_PRESSANYKEY );
        GetNextEvent( false );
    }
    ResetSpawnScreen();
    if( !EditFlags.LineDisplay ) {
        ReDisplayScreen();
    }
#endif
    EditFlags.ClockActive = clockActive;
}
Exemple #6
0
/*
 * Set - set editor control variable
 */
vi_rc Set( char *name )
{
    char        fn[MAX_STR];
    vi_rc       rc = ERR_NO_ERR;
    int         j, i;
#ifndef VICOMP
#ifndef __WIN__
    int         tmp, tc;
    char        **vals = NULL;
    char        **list;
    int         longest;
#endif
#endif

    /*
     * get item to set
     */
#ifndef VICOMP
    msgFlag = FALSE;
    if( !EditFlags.ScriptIsCompiled ) {
#endif
        RemoveLeadingSpaces( name );
        j = strlen( name );
        for( i = 0; i < j; i++ ) {
            if( name[i] == '=' || name[i] == ',' ) {
                name[i] = ' ';
            }
        }
#ifndef VICOMP
    }
#endif

    if( NextWord1( name, fn ) <=0 ) {
#ifndef VICOMP
        if( !EditFlags.WindowsStarted ) {
            return( ERR_NO_ERR );
        }
#ifndef __WIN__
        tc = getSetInfo( &vals, &list, &longest );
        tmp = setw_info.y2;
        i = setw_info.y2 - setw_info.y1 + 1;
        if( setw_info.has_border ) {
            i -= 2;
        }
        if( tc < i ) {
            setw_info.y2 -= (i - tc);
        }
        rc = SelectItemAndValue( &setw_info, "Settings", list,
                          tc, SettingSelected, 1, vals, longest + 3 );
        setw_info.y2 = tmp;
        MemFreeList( tc, vals );
        MemFreeList( tc, list );
        ReDisplayScreen();
#endif
#endif /* VICOMP */
        return( rc );
    } else {
#ifndef VICOMP
        if( !EditFlags.Starting) {
            msgFlag = TRUE;
        }
#endif
        do {
#ifndef VICOMP
            if( !EditFlags.ScriptIsCompiled ) {
#endif
                if( tolower( fn[0] ) == 'n' && tolower( fn[1] ) == 'o' ) {
                    EliminateFirstN( fn, 2 );
                    i = -1;
                } else {
                    i = 1;
                }
                j = Tokenize( SetTokens1, fn, FALSE );
                if( j == TOK_INVALID ) {
                    j = Tokenize( SetTokens2a, fn, FALSE );
                    if( j == TOK_INVALID ) {
                        j = Tokenize( SetTokens2, fn, FALSE );
                        if( j == TOK_INVALID ) {
                            return( ERR_INVALID_SET_COMMAND );
                        }
                    }
                    j += SET1_T_;
                }
                j *= i;
#ifndef VICOMP
            } else {
                j = atoi( fn );
            }
#endif
            i = TRUE;
            rc = processSetToken( j, name, &i, FALSE );
            if( rc > ERR_NO_ERR ) {
                break;
            }
            RemoveLeadingSpaces( name );
        } while( NextWord1( name, fn ) > 0 );
#ifndef VICOMP
        if( msgFlag ) {
            putMessage();
        }
#endif
        return( rc );
    }

} /* Set */
Exemple #7
0
/*
 * ProcessEx - process an ex command
 */
vi_rc ProcessEx( linenum n1, linenum n2, bool n2f, int tkn, const char *data )
{
    vi_rc       rc = ERR_INVALID_COMMAND, i;
    char        word[MAX_STR];
    linenum     addr, tlines;
    fcb         *cfcb;
    line        *cline;
    fcb_list    fcblist;

    GetNextWord1( data, word );
    data = word;
    if( GetAddress( &data, &addr ) != ERR_NO_ERR ) {
        addr = -1;
    }
    tlines = n2 - n1 + 1;

    switch( tkn ) {
    case EX_T_APPEND:
        if( !EditFlags.ExMode ) {
            return( ERR_ONLY_VALID_IN_EX_MODE );
        }
        if( !n2f ) {
            rc = Append( n1, true );
        }
        break;
    case EX_T_CHANGE:
        if( !EditFlags.ExMode ) {
            return( ERR_ONLY_VALID_IN_EX_MODE );
        }
        StartUndoGroup( UndoStack );
        rc = DeleteLineRange( n1, n2, 0 );
        if( rc != ERR_NO_ERR ) {
            EndUndoGroup( UndoStack );
            break;
        }
        rc = Append( n1 - 1, false );
        if( rc != ERR_NO_ERR ) {
            EndUndoGroup( UndoStack );
            break;
        }
        break;
    case EX_T_COPY:
        if( addr < 0 || IsPastLastLine( addr ) ) {
            return( ERR_INVALID_ADDRESS );
        }
        i = GetCopyOfLineRange( n1, n2, &fcblist );
        if( i ) {
            break;
        }
        rc = InsertLines( addr, &fcblist, UndoStack );
        GoToLineNoRelCurs( addr );
        if( rc == ERR_NO_ERR ) {
            Message1( strCmmsg, tlines, "copied", addr );
        }
        break;
    case EX_T_INSERT:
        if( !EditFlags.ExMode ) {
            return( ERR_ONLY_VALID_IN_EX_MODE );
        }
        if( !n2f ) {
            rc = Append( n1 - 1, true );
        }
        break;
    case EX_T_JOIN:
        if( SaveAndResetFilePos( n1 ) != ERR_NO_ERR ) {
            rc = ERR_NO_SUCH_LINE;
            break;
        }
        if( tlines == 1 ) {
            n2 = n1 + 1;
            tlines = 2;
        }
        SetRepeatCount( tlines - 1 );
        rc = JoinCurrentLineToNext();
        RestoreCurrentFilePos();
        GoToLineNoRelCurs( n1 );
        if( rc == ERR_NO_ERR ) {
            Message1( "lines %l to %l joined", n1, n2 );
        }
        break;
    case EX_T_LIST:
        if( !EditFlags.ExMode ) {
            return( ERR_ONLY_VALID_IN_EX_MODE );
        }
        for( rc = CGimmeLinePtr( n1, &cfcb, &cline ); rc == ERR_NO_ERR; rc = CGimmeNextLinePtr( &cfcb, &cline ) ) {
            if( EditFlags.LineNumbers ) {
                MyPrintf( "%M %s\n", n1, cline->data );
            } else {
                MyPrintf( "%s\n", cline->data );
            }
            if( n1 >= n2 ) {
                break;
            }
            n1++;
        }
        break;
    case EX_T_MARK:
        rc = SetGenericMark( n1, 1, C2VIKEY( word[0] ) );
        break;
    case EX_T_MOVE:
        if( addr < 0 || IsPastLastLine( addr ) ) {
            return( ERR_INVALID_ADDRESS );
        }
        SavebufNumber = WORK_SAVEBUF;
        StartUndoGroup( UndoStack );
        rc = DeleteLineRange( n1, n2, SAVEBUF_FLAG );

        if( SavebufNumber != WORK_SAVEBUF ) {
            /* if this changes, the command will fail
             * this could be caused by checking out a read-only file
             * so fix the deleted text and give an error message
             */
            DoUndo();
            return( ERR_INVALID_COMMAND );
        }
        if( rc != ERR_NO_ERR ) {
            EndUndoGroup( UndoStack );
            break;
        }
        if( addr > n2 ) {
            addr -= tlines;
        } else if( addr >= n1 && addr <= n2 ) {
            addr = n1;
        }
        rc = InsertLines( addr, &WorkSavebuf->u.fcbs, UndoStack );
        EndUndoGroup( UndoStack );
        GoToLineNoRelCurs( addr );
        if( rc == ERR_NO_ERR ) {
            Message1( strCmmsg, tlines, "moved", addr );
        }
        break;
    case EX_T_UNDO:
        rc = DoUndo();
        break;
    case EX_T_UNDO_DMT:
        rc = DoUndoUndo();
        break;
    case EX_T_EQUALS:
        Message1( "%l", n1 );
        rc = ERR_NO_ERR;
        break;
    case EX_T_VERSION:
        rc = DoVersion();
        break;
    case EX_T_VISUAL:
    case EX_T_VISUAL_DMT:
        if( EditFlags.LineDisplay ) {
            ScreenPage( -1 );
            EditFlags.ExMode = false;
            EditFlags.LineDisplay = false;
            EditFlags.ClockActive = true;
            ReDisplayScreen();
            DoVersion();
        }
        if( word[0] != '\0' ) {
            rc = EditFile( word, ( tkn == EX_T_VISUAL_DMT ) );
        } else {
            rc = ERR_NO_ERR;
        }
        break;
    }
    return( rc );

} /* ProcessEx */