public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* [RFA] Multi-line tcl expressions in GUI console
@ 2000-12-01 13:16 Larry Smith
  2000-12-01 13:20 ` Syd Polk
  0 siblings, 1 reply; 2+ messages in thread
From: Larry Smith @ 2000-12-01 13:16 UTC (permalink / raw)
  To: insight

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" } {
+    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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFA] Multi-line tcl expressions in GUI console
  2000-12-01 13:16 [RFA] Multi-line tcl expressions in GUI console Larry Smith
@ 2000-12-01 13:20 ` Syd Polk
  0 siblings, 0 replies; 2+ messages in thread
From: Syd Polk @ 2000-12-01 13:20 UTC (permalink / raw)
  To: Larry Smith; +Cc: insight

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-12-01 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-01 13:16 [RFA] Multi-line tcl expressions in GUI console Larry Smith
2000-12-01 13:20 ` Syd Polk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).