Esempio n. 1
0
static void figlist_toc_tabs( char * fill, uint32_t size )
{

    /* Set tab char to "$" */

    tab_char = '$';
    add_to_sysdir( "$tb", tab_char );
    add_to_sysdir( "$tab", tab_char );

    /********************************************************/
    /* Set the tab stops                                    */
    /* the one-column shift is normal                       */
    /* g_page_left is added back in when tabbing is done    */
    /********************************************************/

    user_tabs.current = 2;
    user_tabs.tabs[0].column = g_page_right - tab_col - g_page_left - size;
    user_tabs.tabs[0].fill_char = fill[0];
    user_tabs.tabs[0].alignment = al_right;

    user_tabs.tabs[1].column = g_page_right - tab_col - g_page_left;
    user_tabs.tabs[1].fill_char = ' ';
    user_tabs.tabs[1].alignment = al_right;

    return;    
}
Esempio n. 2
0
void    scr_cw( void )
{
    char        *   pa;
    char        *   p;
    int             len;

    p = scan_start;
    while( *p && *p != ' ' ) {          // over cw
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start
        p++;
    }
    pa = p;

    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    if( len > 2 ) {
        xx_line_err( err_inv_cw_sep, pa );
        return;
    } else if( len > 0 ) {             // 1 char or 2 hex characters
        CW_sep_char = parse_char( pa, len );
    } else {
        CW_sep_char = '\0';
    }
    add_to_sysdir( "$cw", CW_sep_char );
    scan_restart = pa + len;
    return;
}
Esempio n. 3
0
void    scr_ti( void )
{
    char        *   p;

    p = scan_start;
    while( *p && *p != ' ' ) {          // over cw
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start
        p++;
    }

    cop_ti_table( p );
    add_to_sysdir( "$tiset", in_esc );  // put in dictionary

    scan_restart = scan_stop + 1;
    return;
}
Esempio n. 4
0
void    scr_dc( void )
{
    char        *   pa;
    char        *   p;
    char            c;
    int             len;
    int             k;
    char    string[2] = { 0, 0 };
    int             opt;
    static const char   options[5] [5] = { "cw", "gml", "tb", "stop" };
                                        // please add new options at end
    int const   max_opt = sizeof( options) / sizeof( options[0] );

    p = scan_start;
    while( *p && *p != ' ' ) {          // over dc
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start = option
        p++;
    }
    pa = p;
    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    opt = 0;
    if( len > 0 ) {
        for( k = 0; k < max_opt; k++ ) {
            if( !strnicmp( pa, options[k], len ) ) {
                opt = k + 1;
                break;
            }
        }
    }
    if( opt == 0 ) {                   // omitted / unknown / not implemented
        dc_opt_warn_len( pa, len );
        return;
    }
    while( *p && *p == ' ' ) {          // next word start = option value
        p++;
    }
    pa = p;
    c = '\0';
    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    if( len == 1 ) {
        c = *pa;
    }
    switch( opt ) {
    case 1 :                            // CW option
        if( len > 2 ) {
            if( len == 3 ) {
                if( strnicmp( pa, "OFF", len ) ) {
                    xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                    return;
                }
            } else {
                xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                return;
            }
        } else {
            c = parse_char( pa, len );
        }
        scan_restart = pa + len;
        CW_sep_char = c;
        add_to_sysdir( "$cw", CW_sep_char );
        break;
    case 2 :                            // GML option
        if( len > 2 ) {
            if( len == 3 ) {
                if( strnicmp( pa, "OFF", len ) ) {
                    xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                    return;
                }
                c = ' ';                    // OFF is blank
            } else {
                xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                return;
            }
        } else {
            c = parse_char( pa, len );
        }
        scan_restart = pa + len;
        GML_char = c;
        string[0] = c;
        add_symvar( &global_dict, "gml", string, no_subscript,
                    predefined );
        add_to_sysdir( "$gml", GML_char );
        break;
    case 3 :                            // TB option
        if( len > 2 ) {
            if( len == 3 ) {
                if( strnicmp( pa, "OFF", len ) ) {
                    xx_line_err_len( err_dc_not_off, pa, len );  // only OFF is valid
                    return;
                }
                c = 0x09;               // OFF is 0x09
            } else {
                xx_line_err_len( err_dc_not_off, pa, len );  // only OFF is valid
                return;
            }
        } else {
            c = parse_char( pa, len );
        }
        scan_restart = pa + len;
        tab_char = c;
        string[0] = c;
        add_to_sysdir( "$tb", tab_char );
        add_to_sysdir( "$tab", tab_char );
        break;
    case 4 :                            // STOP option

/***************************************************************************/
/*  when the documentation refers to "script", this may be quite literal:  */
/*  setting STOP to OFF has no effect when WSCRIPT is specificed           */
/*  whether ".dc stop" with a list of characters has any effect is unknown */
/*  so doing nothing is the appropriate implementation, at least for now   */
/*                                                                         */
/*  the only use is ".dc stop off" found in                                */
/*        docs\doc\whelp\whelp.gml line 765                                */
/***************************************************************************/

        scan_restart = pa + len;
        break;

    default:                            // unknown / unimplemented option
        dc_opt_warn_len( pa, len );
        break;
    }
    return;
}
Esempio n. 5
0
void    scr_tb( void )
{
    bool            relative;
    char        *   p;
    char        *   pa;
    char        *   pb;
    char            quote;
    condcode        cc;
    getnum_block    t_pos;
    int             i;
    int             len;

    p = scan_start;
    while( *p && (*p != ' ') ) {            // over tb
        p++;
    }
    while( *p && (*p == ' ') ) {            // first token
        p++;
    }
    pa = p;
    while( *p && (*p != ' ') ) {            // token end
        p++;
    }
    len = p - pa;

    if( (len > 0) &&  !memicmp( pa , "set", len ) ) {
        while( *p && (*p == ' ') ) {        // tab char
            p++;
        }
        pa = p;
        while( *p && (*p != ' ') ) {        // end tab char
            p++;
        }
        len = p - pa;
        if( len == 0 ) {
            tab_char = 0x09;                // reset to default value
        } else if( len == 1 ) {
            tab_char = *pa;                 // set to specified char
        } else {
            xx_line_err( err_tab_char, pa );
        }
        add_to_sysdir( "$tb", tab_char );
        add_to_sysdir( "$tab", tab_char );
        while( *p && (*p == ' ') ) {        // end of line
            p++;
        }
        pa = p;
        while( *p && (*p != ' ') ) {        // end of line
            p++;
        }
        len = p - pa;                       // should be "0"
        if( len != 0 ) {
            xx_line_err( err_tab_char, pa );
        }
    } else {
        user_tabs.current = 0;              // clear user_tabs
        p = pa;                             // reset to start of first tab

        while( *p ) {                       // tab stop start
            if( user_tabs.current == user_tabs.length) {
                user_tabs.length += TAB_COUNT;  // add space for new tab stops
                user_tabs.tabs = mem_realloc( user_tabs.tabs, user_tabs.length *
                                            sizeof( tab_stop ) );
            }
            i = user_tabs.current;          // initialize (not done elsewhere)
            user_tabs.tabs[i].column = 0;
            user_tabs.tabs[i].fill_char = ' ';
            user_tabs.tabs[i].alignment = al_left;
            quote = ' ';
            pa = p;

            // Parse fill chars/strings

            if( (*p != '+') && !isdigit(*p) ) { // potential fill char
                if( (*p == '\'') || (*p == '"') || (*p == '/') ) {
                    quote = *p;                 // initial quote found
                    p++;                        // should be fill char
                    if( !*p || (*p == ' ') ||
                        (*p == '+') || isdigit(*p) ) { // ' " or / only before tab stop position
                        xx_line_err( err_right_delim, pa );
                        continue;
                    }
                }
                user_tabs.tabs[i].fill_char = *p;
                pb = p;                 // save position if not fill char
                p++;                    // should be end delimiter
                if( !*p ) {             // 'c "c or /c only
                    xx_line_err( err_right_delim, pa );
                    continue;
                }
                    
                /* fill strings are not allowed -- yet */

                if( ((quote == ' ') && (*p == '/')) ||
                                       ((quote != ' ') && (*p == quote)) ) {
                    p++;                // final quote found
                } else {
                    if( quote != ' ' ) {// quoted value started
                        while( *p ) {   // find final quote
                            if( *p == quote ) {
                                break;
                            }
                            p++;
                        }
                        if( *p == quote ) { // found: fill string
                            xx_line_err( err_tab_fill_string, pa );
                            user_tabs.tabs[i].fill_char = ' ';
                        } else if( *p ) {   // not found: format error
                            xx_line_err( err_right_delim, pa );
                            user_tabs.tabs[i].fill_char = ' ';
                        }
                    } else {                // format error
                        xx_line_err( err_inv_text_before_tab, pa );
                        user_tabs.tabs[i].fill_char = ' ';
                        p = pb;             // restore position: not fill char
                    }
                }
            }

            // Parse the tab stop position

            while( *p && (*p == ' ') ) {
                p++;
            }
            pa = p;                             // tab position start

            t_pos.ignore_blanks = false;
            t_pos.argstart = p;
            while( *p && (*p != ' ') ) {        // tab position end plus 1
                p++;
            }
            if( *p && (p > pa) ) {              // as needed by getnum
                p--;                            // *p is last character of tab stop
            }
            while( (p != pa) && !isdigit( *p ) ) { // back up over alignment 
                p--;
            }
            pb = p + 1;
            t_pos.argstop = p;
            cc = getnum( &t_pos );
            p = pb;                             // alignment start
            if( t_pos.num_sign == ' ' ) {
                relative = false;
            } else {
                if( t_pos.num_sign == '+' ) {
                    relative = true;
                } else {
                    xx_line_err( err_inv_tab_stop, pa );
                }                    
            }
            if( cc == notnum ) {
                xx_line_err( err_inv_text_before_tab, pa );
            } else {
                if( t_pos.result <= 0 ) {
                    if( relative ) {
                        xx_line_err( err_tab_stop_order, pa );
                    } else {
                        xx_line_err( err_inv_tab_stop, pa );
                    }
                } else {
                    if( relative && ( i > 0) ) {
                        t_pos.result *= tab_col;
                        user_tabs.tabs[i].column = user_tabs.tabs[i-1].column +
                                                   t_pos.result;
                    } else {
                        t_pos.result --;
                        t_pos.result *= tab_col;
                        user_tabs.tabs[i].column = t_pos.result;
                    }
                }
                if( !relative && (i > 0) ) {
                    if( user_tabs.tabs[i].column <= user_tabs.tabs[i-1].column ) {
                        xx_line_err( err_tab_stop_order, pa );
                    }
                }
                user_tabs.current++;
            }

            // Parse the alignment 

            user_tabs.tabs[i].alignment = al_left;
            if( *p && (*p != ' ') ) {           // space ends tab stop

            /* alignment characters are not allowed -- yet */

                pa = p;                         // potential alignment start
                if( (*p == 'c') || (*p == 'C') ) {                       
                    user_tabs.tabs[i].alignment = al_center;
                    p++;
                } else if( (*p == 'l') || (*p == 'L') ) {                       
                    user_tabs.tabs[i].alignment = al_left;
                    p++;
                } else if( (*p == 'r') || (*p == 'R') ) {                       
                    user_tabs.tabs[i].alignment = al_right;
                    p++;
                } else if( *p == '\'' ) {       // possible alignment character
                    p++;
                    if( !*p || (*p != ' ') ) {  // not end of tab stop
                        if( !*p ) {             // ' only
                            xx_line_err( err_right_delim, pa );
                        }
                        p++;
                        if( !*p ) {             // 'c only
                            xx_line_err( err_right_delim, pa );
                        } else if( *p == '\'' ) {   // definite alignment character
                            xx_line_err( err_tab_align_char, pa );
                        } else {                // 'cc with or without more text
                            xx_line_err( err_right_delim, pa );
                        }                    
                    } else {                    // something else
                        xx_line_err( err_inv_text_after_tab, pa );
                    }
                    p++;
                } else {                        // something else
                    xx_line_err( err_inv_text_after_tab, pa );
                    p++;
                }
            }
            if( *p != ' ' ) {
                while( *p && (*p != ' ') ) {    // find end of tab stop
                    p++;
                }
            }
            while( *p && (*p == ' ') ) {        // find next tab position
                p++;
            }
        }
    }

    scan_restart = scan_stop + 1;
    return;
}