GDB (API)
/home/stan/gdb/src/gdb/gdbtk/library/editor.tcl
Go to the documentation of this file.
00001 # Editor
00002 # Copyright (C) 2001 Red Hat, Inc.
00003 #
00004 # This program is free software; you can redistribute it and/or modify it
00005 # under the terms of the GNU General Public License (GPL) as published by
00006 # the Free Software Foundation; either version 2 of the License, or (at
00007 # your option) any later version.
00008 #
00009 # This program is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 # GNU General Public License for more details.
00013 
00014 # ----------------------------------------------------------------------
00015 # Implements a set of editor commands
00016 # ----------------------------------------------------------------------
00017 
00018 namespace eval Editor {
00019   namespace export edit
00020 
00021   proc edit {loc_info} {
00022     global external_editor_command
00023 
00024     if {[info exists external_editor_command]} {
00025       if {[catch {uplevel \#0 "$external_editor_command edit $loc_info"} \
00026        err]} {
00027   tk_dialog .warn-sn "Edit" $err error 0 Ok
00028       }
00029       return
00030     }
00031 
00032     lassign $loc_info baseName fnName fileName lineNum addr pc
00033 
00034     set newCmd [pref get gdb/editor]
00035     if {! [string compare $newCmd ""]} {
00036       tk_dialog .warn "Edit" "No editor command specified" error 0 Ok
00037     }
00038 
00039     # Replace %s with file name and %d with line number.
00040     regsub -all -- %s $newCmd $fileName newCmd
00041     regsub -all -- %d $newCmd $lineNum newCmd
00042 
00043     if {[catch "exec $newCmd &" err]} {
00044       tk_dialog .warn "Edit" $err error 0 Ok
00045     }
00046   }
00047 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines