This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] Multi-line tcl expressions in GUI console




Larry Smith wrote:
> 
> This patch allows the user to enter multi-line tcl expressions
> when using the "tk" command.  It uses [info complete $cmd] to
> determine if the command is complete, and if it is not, inserts
> the continuation character "\" and allows the user to continue
> on the next line, until the expression is finally complete and
> ready to be evaluated.
> 
> 2000-12-01  Larry Smith <lsmith@redhat.com>
> 
>         * console.itb (invoke): Added logic to allow user to build
>         up multiline "tk" commands based on results from checking
>         command with [info complete $cmd]s.
> 
> Index: console.itb
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtk/library/console.itb,v
> retrieving revision 1.4
> diff -u -r1.4 console.itb
> --- console.itb 2000/11/01 22:15:37     1.4
> +++ console.itb 2000/12/01 21:11:17
> @@ -379,8 +379,19 @@
>  body Console::invoke {} {
>    global gdbtk_state
> 
> +  set text [$_twin get {cmdmark + 1 char} end ]
> +
> +  if { "[string range $text 0 1]" == "tk" } {

You don't need all of those quotes:

    if { [string range $text 0 1] == "tk" } {

is ok. However, == compares of string are frought with peril. I prefer
string compare:

    if { [string compare [string range $text 0 1] "tk"] == 0 } {


> +    if {! [info complete $text] } {
> +      $_twin insert {insert lineend} " \\\n"
> +      $_twin see insert
> +      return
> +    } else {
> +    }
> +  }
> +
>    incr _invoking
> -  set text [$_twin get {cmdmark + 1 char} {cmdmark lineend}]
> +
>    if {$text == ""} {
>      set text [lindex $_history 0]
>      $_twin insert {insert lineend} $text

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]