788 proc select_html_item {txt dir} {
790 set startpos "insert"
793 if {([
set retval [
inside_tag $txt -allow010 1]] eq "") || [
string match "001" [
lindex $retval 3]]} {
794 set retval [
get_tag $txt -dir $dir -type "??0"]
798 if {[
llength [
set selected [$txt tag ranges sel]]] != 2} {
802 if {$dir eq "next"} {
804 while {$retval ne ""} {
807 set end_name "[
lindex $retval 0]+[
expr [
string length [
lindex $retval 2]] + 1]c"
810 if {[$txt compare $startpos < $end_name]} {
812 $txt tag add sel "[
lindex $retval 0]+1c" $end_name
817 foreach {attr_name attr_name_start attr_value attr_value_start} [
get_tag_attributes $txt $retval] {
818 set attr_end [$txt index "$attr_value_start+[
expr [
string length $attr_value] + 1]c"]
819 if {[$txt compare $startpos > $attr_end]} {
822 if {[$txt compare $startpos < $attr_value_start]} {
824 $txt tag add sel $attr_name_start $attr_end
826 }
elseif {(($selected eq [list $attr_name_start $attr_end]) && ($attr_value ne "")) || ($selected eq "")} {
828 $txt tag add sel $attr_value_start "$attr_end-1c"
837 set retval [
get_tag $txt -dir $dir -type "??0" -start [
lindex $retval 1]]
843 while {$retval ne ""} {
845 set attr_name_start ""
847 foreach {attr_value_start attr_value attr_name_start attr_name} [
lreverse [
get_tag_attributes $txt $retval]] {
848 set attr_end [$txt index "$attr_value_start+[
expr [
string length $attr_value] + 1]c"]
849 if {($selected eq [list $attr_name_start $attr_end]) || [$txt compare $startpos < $attr_name_start]} {
852 if {($selected eq [list $attr_value_start [$txt index $attr_end-1c]]) || \
853 (($attr_value eq "") && [$txt compare $startpos > $attr_name_start])} {
855 $txt tag add sel $attr_name_start $attr_end
859 }
elseif {[$txt compare $startpos > $attr_value_start] && ($attr_value ne "")} {
861 $txt tag add sel $attr_value_start "$attr_end-1c"
866 set start_name [$txt index "[
lindex $retval 0]+1c"]
867 set end_name [$txt index "[
lindex $retval 0]+[
expr [
string length [
lindex $retval 2]] + 1]c"]
872 if {(($selected ne [list $start_name $end_name]) && [$txt compare $startpos > [
lindex $retval 0]]) || \
873 (($attr_name_start ne "") && ($selected eq [list $attr_name_start $attr_end]))} {
875 $txt tag add sel $start_name $end_name
880 set retval [
get_tag $txt -dir $dir -type "??0" -start [
lindex $retval 0]]