Пример #1
0
void MYMENU_FormatCombineCells()
{
    // get the start/end info
    int start_row, start_col, end_row, end_col;
    get_selection( &start_row, &start_col, &end_row, &end_col );
    // get the left top cell
    CellInfo* info = get_cell_info( table, start_row, start_col );
    CellInfo* infocopy;
    if ( info == NULL ) {
        // empty cell, create a new one
        infocopy = create_cell_info();
        infocopy->combine_right = end_col - start_col;
        infocopy->combine_bottom = end_row - start_row;
    }
    else {
        // create a new cell copy
        infocopy = clone_cell_info( info );
        // modify the exist one
        infocopy->combine_right = end_col - start_col;
        infocopy->combine_bottom = end_row - start_row;
    }
    // history
    history_append( start_row, start_col );
    free_redo_history();
    // update
    insert_cell_info( table, start_row, start_col, infocopy );
    update_table_view();
}
Пример #2
0
void MYMENU_EditPaste()
{
    if ( editmode == 1 ) {
        SendMessageW( hEdit, WM_PASTE, 0, 0 );
    }
    else {
        // get the cell where to paste on
        int start_row = 0;
        int start_col = 0;
        int end_row, end_col;
        get_selection( &start_row, &start_col, &end_row, &end_col );
        // let us extract cells from stream
        int row = 0;
        int col = 0;
        CellInfo* info = iterate_stream_cell( &row, &col );
        // base row and col, used to form relative rows and cols
        int base_row = row;
        int base_col = col;
        while ( info != NULL ) {
            // history
            history_append( start_row + row - base_row, start_col + col - base_col );
            free_redo_history();
            insert_cell_info( table, start_row + row - base_row, start_col + col - base_col, info );
            info = iterate_stream_cell( &row, &col );
        }
        auto_adapt_layout( table );
        update_selection_rect();
        update_table_view();
    }
}
Пример #3
0
void MYMENU_FormatBGColor()
{
    CHOOSECOLOR cc;
    static COLORREF acrCustClr[16];// array of custom colors
    static DWORD rgbCurrent;// initial color selection

    ZeroMemory(&cc, sizeof(cc));
    cc.lStructSize = sizeof(cc);
    cc.hwndOwner = hwnd;
    cc.lpCustColors = (LPDWORD) acrCustClr;
    cc.rgbResult = rgbCurrent;
    cc.Flags = CC_FULLOPEN | CC_RGBINIT;

    if ( ChooseColor(&cc) ) {
        int row, col;
        CellInfo* info = iterate_selection( table, &row, &col );
        while ( info != NULL ) {
            // history
            history_append( row, col );
            free_redo_history();
            info->style.bg_rgb = cc.rgbResult;
            info = iterate_selection( table, &row, &col );
        }
        update_table_view();
    }
}
Пример #4
0
int read_movelines (char txt[128], int verbose) {
    char *movement = strtok(txt, " ");
    struct move move;
    int x=0;

    //movement = strtok(NULL, " "); 

        while ( movement != NULL) {

            if (parse_move(&move, movement, 1-machineplays)) {
                Vb printf("moving from input: %i%i %i%i\n",move.from[0],move.from[1],move.to[0],move.to[1]);
                move.casualty = board.squares[move.to[0]][move.to[1]]; 
                
                move_pc(&board, &move);

                history_append(&move);
                x++;
            }
        movement = strtok(NULL, " ");        
                
        }
    Vb printf("%i moves read.\n",x);

    
    
    return x;
}
Пример #5
0
Файл: cpu.c Проект: SiGe/argos
static void
cpu_save_snapshot_to_history(char const *data, uint64_t time, cpu_history *cpu) {
    char buf[32];
    uint64_t t1, t2;

    column(data, 1, buf, 32);
    t1 = strtoull(buf, 0, 10);
    history_append(cpu->user, time, t1);
    
    /* Get the system time */
    column(data, 3, buf, 32);
    t2 = strtoull(buf, 0, 10);
    history_append(cpu->sys, time, t2);
    history_append(cpu->cpu, time, t1+t2);

    /* Get the idle time */
    column(data, 4, buf, 32);
    t1 = strtoull(buf, 0, 10);
    history_append(cpu->idle, time, t1);

    /* Get the io_wait time */
    column(data, 5, buf, 32);
    t1 = strtoull(buf, 0, 10);
    history_append(cpu->iowait, time, t1);

    /* Get the steal time */
    column(data, 8, buf, 32);
    t1 = strtoull(buf, 0, 10);
    history_append(cpu->steal, time, t1);
}
Пример #6
0
void MYMENU_FormatAlignCenter()
{
    int row, col;
    CellInfo* info = iterate_selection( table, &row, &col );
    while ( info != NULL ) {
        // history
        history_append( row, col );
        free_redo_history();
        info->style.text_align = ALIGN_CENTER;
        info = iterate_selection( table, &row, &col );
    }
    update_table_view();
}
Пример #7
0
void MYMENU_FormatClearStyle()
{
    int row, col;
    CellInfo* info = iterate_selection( table, &row, &col );
    while ( info != NULL ) {
        // history
        history_append( row, col );
        free_redo_history();
        clear_style( &(info->style) );
        info = iterate_selection( table, &row, &col );
    }
    auto_adapt_layout( table );
    update_selection_rect();
    update_table_view();
}
Пример #8
0
void MYMENU_FormatSplitCells()
{
    int row, col;
    CellInfo* info = iterate_selection( table, &row, &col );
    while ( info != NULL ) {
        if ( info->combine_right != 0 || info->combine_bottom != 0 ) {
            // history
            history_append( row, col );
            free_redo_history();
            info->combine_right = 0;
            info->combine_bottom = 0;
        }
        info = iterate_selection( table, &row, &col );
    }
    update_table_view();
}
Пример #9
0
void MYMENU_EditDelete()
{
    if ( editmode == 1 ) {
        SendMessageW( hEdit, WM_CLEAR, 0, 0 );
    }
    else {
        int row, col;
        CellInfo* info = iterate_selection( table, &row, &col );
        while ( info != NULL ) {
            // history
            history_append( row, col );
            free_redo_history();
            delete_cell_info( table, row, col );
            info = iterate_selection( table, &row, &col );
        }
        auto_adapt_layout( table );
        update_selection_rect();
        update_table_view();
    }
}
Пример #10
0
Файл: cpu.c Проект: SiGe/argos
void cpu_snapshot_tick(cpu_snapshot *cpu) {
    snapshot *snap = 0;

    if (snapshot_create("/proc/stat", &snap) < 0) {
        fprintf(stderr, "Failed to save /proc/stat.\n");
        snapshot_delete(snap);
        return;
    }

    char const *data = snap->data;
    char buf[32];

    while (data) {
        uint64_t t1;
        column(data, 0, buf, 32);

        /* save the total number of jiffies spent in cpu user+system time */
        if (equal(buf, "cpu")) {
            cpu_save_snapshot_to_history(data, snap->time, cpu->main);
        } else if (startswith(buf, "cpu")) {
            int cpu_num = atoi(buf+3);
            cpu_save_snapshot_to_history(data, snap->time, cpu->cpus[cpu_num]);
        }

        /* save the number of context switches */
        if (equal(buf, "ctxt")) {
            column(data, 1, buf, 32);
            t1 = strtoull(buf, 0, 10);

            history_append(cpu->ctxt, snap->time, t1);
        }

        data = next_line(data);
    }

    snapshot_delete(snap);
}
Пример #11
0
void MYMENU_FormatFont()
{
    CHOOSEFONT cf;
    LOGFONT lf;
    CHARFORMAT2 fmt;
    HDC hDC = GetDC( hwnd );

    ZeroMemory(&cf, sizeof(cf));
    cf.lStructSize = sizeof(cf);
    cf.hwndOwner = hwnd;
    cf.lpLogFont = &lf;
    cf.Flags = CF_SCREENFONTS | CF_NOSCRIPTSEL | CF_INITTOLOGFONTSTRUCT | CF_EFFECTS;

    ZeroMemory(&fmt, sizeof(fmt));
    fmt.cbSize = sizeof(fmt);

    SendMessage( hEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt );
    lstrcpy(cf.lpLogFont->lfFaceName, fmt.szFaceName);
    cf.lpLogFont->lfItalic = (fmt.dwEffects & CFE_ITALIC) ? TRUE : FALSE;
    cf.lpLogFont->lfWeight = (fmt.dwEffects & CFE_BOLD) ? FW_BOLD : FW_NORMAL;
    cf.lpLogFont->lfUnderline = (fmt.dwEffects & CFE_UNDERLINE) ? TRUE : FALSE;
    cf.lpLogFont->lfStrikeOut = (fmt.dwEffects & CFE_STRIKEOUT) ? TRUE : FALSE;
    cf.lpLogFont->lfHeight = -MulDiv(fmt.yHeight / 20, GetDeviceCaps(hDC, LOGPIXELSY), 72);
    cf.rgbColors = fmt.crTextColor;
    unsigned int bg_rgb = fmt.crBackColor;

    ReleaseDC( hwnd, hDC );

    if(ChooseFont(&cf))
    {
        ZeroMemory(&fmt, sizeof(fmt));
        fmt.cbSize = sizeof(fmt);
        fmt.dwMask = CFM_FACE | CFM_BOLD | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR;
        fmt.yHeight = cf.iPointSize * 2;

        lstrcpy( fmt.szFaceName, cf.lpLogFont->lfFaceName );
        if(cf.nFontType & BOLD_FONTTYPE)
            fmt.dwEffects |= CFE_BOLD;
        if(cf.nFontType & ITALIC_FONTTYPE)
            fmt.dwEffects |= CFE_ITALIC;
        if(cf.lpLogFont->lfUnderline == TRUE)
            fmt.dwEffects |= CFE_UNDERLINE;
        if(cf.lpLogFont->lfStrikeOut == TRUE)
            fmt.dwEffects |= CFE_STRIKEOUT;

        fmt.crTextColor = cf.rgbColors;
        fmt.crBackColor = bg_rgb;

        if ( editmode == 1 ) {
            SendMessage( hEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt );
        }
        else {
            int row, col;
            CellInfo* info = iterate_selection( table, &row, &col );
            while ( info != NULL ) {
                // history
                history_append( row, col );
                free_redo_history();
                charformat2style( &(info->style), &fmt );
                info = iterate_selection( table, &row, &col );
            }
            auto_adapt_layout( table );
            update_selection_rect();
            update_table_view();
        }
    }
}