TABLE OF CONTENTS


::pwtk::gp::term_usable

SYNOPSIS

proc ::pwtk::gp::term_usable {term} {

PURPOSE

Return a Gnuplot name for the terminal, derived from $term, that is supported by Gnuplot.

This proc is typically used internally by PWTK.

RETURN VALUE

Name of the Gnuplot terminal that exists. In particular, it returns $term if the Gnuplot terminal $term exists, otherwise returns some terminal that exists ("dumb" if anything else fails).

The terminal search follows the logic:

If all these fail, return any or empty (=default) terminal

SOURCE

    variable supported_terminals
    variable gp

    set term [pwtk2gp $term]
    set warning {The requested Gnuplot terminal \"$term\" is either not supported by PWTK or\ndoes not exist in Gnuplot. Using the \"$t\" terminal instead.}
    
    if { [term_ok $term] } {
        return $term
    } else {
        # if we have a win-terminal & no DISPLAY, use the dumb txt.terminal
        if { $term in $gp(win.terminals) \
                 && $::tcl_platform(platform) eq "unix" && ![info exists ::env(DISPLAY)] } {
            if { $term eq {} } {
                set term win
            }
            ::pwtk::warning "cannot use the $term terminal: no \$DISPLAY environment variable, using the dump terminal instead"
            return dumb
        }
        # get a usable file.terminal for a file.terminal,
        # win.terminal for a win.terminal, ..., or any usable terminal
        foreach type {file. win. txt. ""} {
            if { $term in $gp(${type}terminals) && [info exists gp(${type}supported_terminals)] } {
                # $term is a $type type terminal, use the first avaiable terminal
                set t [lindex $gp(${type}supported_terminals) 0]
                if { $term ne {} } {
                    # empty $term stands for a window terminal; do not print warning
                    ::pwtk::warning [subst $warning]
                }
                return $t
            }            
        }
        # no usable terminals found, return {} (i.e. empty terminal)
        set t {}
        ::pwtk::warning [subst $warning]
        return $t
    }
}