1 # Midnight Commander Tk code.
2 # Copyright (C) 1995, 1996, 1997 Miguel de Icaza
6 # Fix the internal viewer
7 # Missing commands: mc_file_info, mc_open_with
8 # The default buttons have a problem with the new frame around them:
9 # they don't display the focus.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 wm title .
"Midnight Commander (TK edition)"
31 proc create_top_menu
{} {
36 frame .mbar
-relief raised
-bd 2
38 pack .mbar
-side top
-fill x
44 proc create_menu
{str topmenu
} {
48 menubutton .mbar.
$topmenu -text $str -underline 0 -menu .mbar.
$topmenu.
menu
49 pack .mbar.
$topmenu -side left
50 menu .mbar.
$topmenu.
menu -tearoff $setup(tearoff
)
51 set top_menus
"$top_menus $topmenu"
54 proc create_mentry
{topmenu
entry cmd idx
} {
55 .mbar.
$topmenu.
menu add command
-label "$entry" -command "$cmd $idx"
58 proc add_separator
{topmenu
} {
59 .mbar.
$topmenu.
menu add separator
65 proc newbutton
{name cmd
text isdef
} {
67 frame $name -relief sunken
-bd 1
68 set name
"$name.button"
70 button $name -text "$text" -command $cmd -justify left
72 pack $name -padx 1m
-pady 1m
82 canvas $win -height $setup(heightc
) -width 250 -relief sunken
-border 2
83 $win create rectangle
0 0 0 0 -tags gauge
-fill black
-stipple gray50
85 # So that we can tell the C code, which is the gauge size currently
86 bind $win <Configure
> "x$win %w"
89 # Used to show the gauge information
90 proc gauge_shown
{win
} {
91 # $win configure -relief sunken -border 2
94 # Used to hide the gauge information.
95 proc gauge_hidden
{win
} {
96 # $win configure -relief flat -border 0
97 $win coords gauge
0 0 0 0
103 proc view_size
{cmd w h
} {
106 $cmd dim
[expr $w/$setup(widthc
)] [expr $h/$setup(heightc
)]
109 proc newview
{is_panel container winname cmd
} {
112 # FIXME: The trick to get the window without too much
113 # movement/flicker is to use an extra frame, and use the placer
114 # like it was done in WInfo.
116 set width
[expr [winfo width
$container]/$setup(widthc
)]
117 set height
[expr [winfo height
$container]/$setup(heightc
)]
122 frame $winname.v.status
123 eval text $winname.v.view
$setup(view_normal
) -font $setup(panelfont
)
125 # Create the tag names for the viewer attributes
126 eval $winname.v.view tag configure bold
$setup(view_bold
)
127 eval $winname.v.view tag configure underline
$setup(view_underline
)
128 eval $winname.v.view tag configure mark
$setup(view_mark
)
129 eval $winname.v.view tag configure normal
$setup(view_normal
)
131 # Make the status fields
132 label $winname.v.status.
filename
133 label $winname.v.status.column
134 label $winname.v.status.size
135 label $winname.v.status.flags
137 pack $winname.v.status.
filename -side left
138 pack $winname.v.status.column
-anchor w
-side left
-fill x
-expand 1
139 pack $winname.v.status.size
-anchor w
-side left
-fill x
-expand 1
140 pack $winname.v.status.flags
-anchor w
-side left
-fill x
-expand 1
142 # Pack the main components
143 pack $winname.v.status
-side top
-fill x
144 pack $winname.v.view
-side bottom
-expand 1 -fill both
145 pack $winname.v
-expand 1 -fill both
147 bindtags $winname.v.view
"all . $winname.v.view"
148 bind $winname.v.view
<Configure
> "view_size $cmd %w %h"
151 $winname.v.view configure
-width $width -height $height
156 proc view_update_info
{win fname col size flags
} {
157 $win.v.status.
filename configure
-text "File: $fname"
158 $win.v.status.column configure
-text "Column: $col"
159 $win.v.status.size configure
-text "$size bytes"
160 $win.v.status.flags configure
-text "$flags"
164 # Hack: remove all the text on the window and then insert
165 # new lines. Maybe the newlines
166 proc cleanview
{win
} {
168 $win insert
1.0 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
174 proc newradio
{name
} {
180 proc radio_item
{idx
text cmd act
} {
182 radiobutton $last_radio.
$idx -text "$text" -variable v
$last_radio -value $idx -command "$cmd select $idx"
184 $last_radio.
$idx select
186 pack $last_radio.
$idx -side top
-anchor w
194 proc entry_save_sel
{win
} {
197 if [$win selection present
] {
199 set sel
(first
) [$win index sel.first
]
200 set sel
(last
) [$win index sel.last
]
206 proc entry_restore_sel
{win
} {
210 $win selection from
$sel(first
)
211 $win selection to
$sel(last
)
215 proc entry_click
{win x
} {
217 set p
[$win index
@$x]
223 proc entry_move
{win x
} {
225 set p
[$win index
@$x]
226 $win selection from
$sel(from
)
231 proc bind_entry
{win
} {
232 bind $win <1> "entry_click $win %x"
233 bind $win <B1-Motion
> "entry_move $win %x"
236 proc newinput
{name
text} {
237 entry $name -relief sunken
-background white
-foreground black
238 $name insert
0 "$text"
239 bindtags $name "all . $name "
246 proc newcheck
{name cmd
text act
} {
247 checkbutton $name -text "$text" -command "$cmd"
248 if $act { $name select
}
254 # window is the container name and widget name: .left.o2
255 # container is the container name: .left
257 proc info_entry
{win name
text} {
258 frame $win.b.finfo.
$name
259 label $win.b.finfo.
$name.
label -text "$text"
260 label $win.b.finfo.
$name.
info
261 grid $win.b.finfo.
$name.
label -row 0 -column 0 -sticky we
262 grid $win.b.finfo.
$name.
info -row 0 -column 1 -sticky w
263 grid columnconfigure
$win.b.finfo.
$name 0 -minsize 100
266 proc newinfo
{container window version
} {
269 set width
[winfo width
$container]
270 set height
[winfo height
$container]
272 frame $window -width $width -height $height \
273 -borderwidth [expr $setup(widthc
)/2]
277 frame $window.b.finfo
-relief groove
-borderwidth 2
278 frame $window.b.fs
-relief groove
-borderwidth 2
280 label $window.b.v.version
-text " The Midnight Commander $version " \
282 pack $window.b.v.version
-fill x
284 info_entry
$window fname
"File:"
285 info_entry
$window location
"Location:"
286 info_entry
$window mode
"Mode:"
287 info_entry
$window links
"Links:"
288 info_entry
$window owner
"Owner:"
289 info_entry
$window size
"Size:"
290 info_entry
$window created
"Created:"
291 info_entry
$window modified
"Modified:"
292 info_entry
$window access
"Access:"
294 pack $window.b.finfo.fname
\
295 $window.b.finfo.location
$window.b.finfo.mode
$window.b.finfo.links
\
296 $window.b.finfo.owner
$window.b.finfo.size
$window.b.finfo.created
\
297 $window.b.finfo.modified
$window.b.finfo.access
\
300 label $window.b.fs.fsys
301 label $window.b.fs.dev
302 label $window.b.fs.type
304 frame $window.b.fs.free
305 label $window.b.fs.free.
label
306 newcanvas
$window.b.fs.free.
canvas
308 pack $window.b.fs.free.
label -side left
309 pack $window.b.fs.free.
canvas -side left
311 frame $window.b.fs.freeino
312 label $window.b.fs.freeino.
label
313 newcanvas
$window.b.fs.freeino.
canvas
314 pack $window.b.fs.freeino.
label -side left
315 pack $window.b.fs.freeino.
canvas -side left
317 pack $window.b.fs.fsys
\
318 $window.b.fs.dev
$window.b.fs.type
\
320 $window.b.fs.freeino
-side top
-anchor w
-padx $setup(widthc
)
322 pack $window.b.v
-side top
-anchor w
-fill x
-expand 1
324 pack $window.b.fs
-side bottom
-anchor w
-fill x
-expand 1
326 pack $window.b.finfo
-side top
-anchor w
\
331 pack $window -fill both
-expand 1
333 place $window.b
-in $window -relx 0 -rely 0 -relheight 1 -relwidth 1
336 proc info_bar
{win percent
} {
338 set w
[winfo width
$win]
339 set s
[expr (100-$percent)*$w/100]
341 $win coords bar
0 0 $s 50
342 # puts stderr "Width: $w $s\n\r"
345 proc info_none
{win
} {
346 $win coords bar
0 0 0 0
350 proc newcanvas
{win
} {
352 canvas $win -height $setup(heightc
) -relief sunken
-border 2
353 $win create rectangle
0 0 0 0 -tags bar
-fill black
-stipple gray50
356 proc infotext
{win
text} {
357 $win configure
-text $text
360 proc xinfotext
{win
text} {
361 $win.
info configure
-text $text
363 # w containes the window name *and* the .b frame (like: .left.o2.b)
364 # FIXME: We should also display the rdev information
374 have_space avail percent total
375 have_ino nfree inoperc inotot
} {
378 # Set all the text information
380 xinfotext
$w.finfo.fname
"$fname"
381 xinfotext
$w.finfo.location
"${dev}h:${ino}h"
382 xinfotext
$w.finfo.mode
"$mode ($mode_oct)"
383 xinfotext
$w.finfo.links
"$links"
384 xinfotext
$w.finfo.owner
"$owner/$group"
386 xinfotext
$w.finfo.size
"$size ($blocks blocks)"
388 xinfotext
$w.finfo.size
"$size"
390 xinfotext
$w.finfo.created
"$create"
391 xinfotext
$w.finfo.modified
"$modify"
392 xinfotext
$w.finfo.access
"$access"
394 infotext
$w.fs.fsys
"Filesystem:\t$fsys"
395 infotext
$w.fs.dev
"Device:\t\t$dev"
396 infotext
$w.fs.type
"Type:\t\t$type"
398 infotext
$w.fs.free.
label \
399 "Free Space $avail ($percent%) of $total"
400 info_bar
$w.fs.free.
canvas $percent
402 infotext
$w.fs.free.
label "No space information"
403 info_none
$w.fs.free.
canvas
406 infotext
$w.fs.freeino.
label \
407 "Free inodes $nfree ($inoperc%) of $inotot"
408 info_bar
$w.fs.freeino.
canvas $inoperc
410 infotext
$w.fs.freeino.
label "No inode information"
411 info_none
$w.fs.freeino.
canvas
418 proc listbox_sel
{win item
} {
419 $win selection clear
0 end
420 $win selection set $item
427 proc panel_select
{w pos cback
} {
428 $w.m.p.panel tag add selected
$pos.0 "$pos.0 lineend"
429 $w.m.p.panel see
$pos.0
430 $cback top
[$w.m.p.panel index
@0,0]
433 proc panel_scroll
{win cback args
} {
434 eval "$win yview $args"
435 $cback top
[$win index
@0,0]
438 proc cmd_sort_add
{name
menu cmd
} {
439 $menu add command
-label $name -command "$cmd sort $name"
442 proc panel_setup
{which cmd
} {
446 set m
$which.cwd.
menu
447 menubutton $which.cwd
-text "loading..." -bd 1 -relief raised
\
448 -menu $m -indicatoron 0
450 menu [set mm
$m.sort
] -tearoff 0
451 $m add command
-label "Reverse sort order" -command "$cmd reverse"
452 $m add cascade
-label "Sort" -menu $mm
453 cmd_sort_add
"Name" $mm $cmd
454 cmd_sort_add
"Extension" $mm $cmd
455 cmd_sort_add
"Size" $mm $cmd
456 cmd_sort_add
"Modify Time" $mm $cmd
457 cmd_sort_add
"Access Time" $mm $cmd
458 cmd_sort_add
"Change Time" $mm $cmd
459 cmd_sort_add
"Inode" $mm $cmd
460 cmd_sort_add
"Type" $mm $cmd
461 cmd_sort_add
"Links" $mm $cmd
462 cmd_sort_add
"NGID" $mm $cmd
463 cmd_sort_add
"NUID" $mm $cmd
464 cmd_sort_add
"Owner" $mm $cmd
465 cmd_sort_add
"Group" $mm $cmd
466 cmd_sort_add
"Unsorted" $mm $cmd
468 $m add command
-label "Refresh" -command "$cmd refresh"
470 $m add command
-label "Set mask" -command "$cmd setmask"
471 $m add command
-label "No mask" -command "$cmd nomask"
475 scrollbar $which.m.scroll
-width 3m
477 frame $which.m.p
-relief sunken
-borderwidth 2
479 if $setup(with_sortbar
) {
480 canvas $which.m.p.types
\
482 -back $setup(def_back
) \
483 -highlightthickness 0 -height 0
484 pack $which.m.p.types
-side top
-fill x
487 scrollbar $which.m.p.scroll
-width 3m
-orient horizontal
489 # The file listing panel
490 text $which.m.p.panel
-width $setup(cols
) -yscroll "$which.m.scroll set" \
491 -fore $setup(def_fore
) -back $setup(def_back
) \
492 -wrap none
-height $setup(lines
) -font $setup(panelfont
) \
493 -relief flat
-borderwidth 0 -highlightthickness 0 \
494 -xscroll "$which.m.p.scroll set"
496 bindtags $which.m.p.panel
"all . $which.m.p.panel"
498 proc x
$which.m.p.panel
{x
} "$cmd \$x"
500 pack $which.m.p.panel
-side top
-fill both
-expand 1
501 pack $which.m.p.scroll
-side top
-fill x
502 pack $which.m.p
-side left
-fill both
-expand 1
504 pack $which.m.scroll
-side right
-fill y
505 pack $which.cwd
-side top
-anchor w
506 pack $which.m
-side top
-fill both
-expand 1
507 pack $which.mini
-side top
-fill x
509 pack $which -fill both
-expand 1
511 config_colors
$which.m.p.panel
515 # Draging the panels:
516 # mc_x and mc_y contains the last positions where the mouse was
517 # mc_repeat contains the id of the after command.
519 proc panel_cancel_repeat
{} {
522 after cancel
$mc_repeat
526 proc panel_drag
{w cmd n
} {
531 if {$mc_y >= [winfo height
$w]} {
532 $w yview scroll
1 units
533 } elseif
{$mc_y < 0} {
534 $w yview scroll
-1 units
538 $cmd top
[$w index
@0,0]
539 $cmd motion
$n [$w index
@$mc_x,$mc_y]
540 set mc_repeat
[after 50 panel_drag
$w $cmd $n]
544 # This routine passes the size of the text widget back to the C code
547 proc panel_size
{cmd panel w h
} {
550 set setup
(real_height
) $h
551 set setup
(real_width
) $w
553 if $setup(with_icons
) {
554 set setup
(height
) [expr $h-setup
(iconheight
)]
555 set setup
(width
) [expr $w-$setup(iconwidth
)]
556 set setup
(lines
) [expr $setup(height
)/$setup(heightc
)]
557 set setup
(cols
) [expr $setup(width
)/$setup(widthc
)]
561 set setup
(lines
) [expr $h/$setup(heightc
)]
562 set setup
(cols
) [expr $w/$setup(widthc
)]
568 # Called on the first idle loop to configure the sizes of the thing
570 proc panel_conf
{panel cmd
} {
573 set font [lindex [$panel configure
-font] 4]
574 set fontinfo
[$cmd fontdim
$font $panel]
576 set setup
(heightc
) [lindex $fontinfo 0]
577 set setup
(widthc
) [lindex $fontinfo 1]
579 bind $panel <Configure
> "panel_size $cmd $panel %w %h"
583 # Manage the bar that keeps the sort orders
585 proc panel_reset_sort_labels
{win
} {
586 # $win.m.p.types delete all
589 proc panel_sort_label_start
{win
} {
590 # $win.m.p.types delete all
594 # This right now uses a canvas, creates labels and places them
595 # on the canvas. The button emulation is done with a manual
599 proc panel_add_sort
{win text_len
text pos end_pos tag
} {
602 if {$setup(with_sortbar
) == 0} return
604 catch { destroy $win.m.p.types.
$pos }
605 label $win.m.p.types.
$pos -text $text -borderwidth 2 \
606 -font $setup(panelfont
) -relief raised
608 $win.m.p.types create window
$pos 0 -window $win.m.p.types.
$pos -anchor nw
609 $win.m.p.types configure
-height [expr $setup(heightc
)+8]
610 $win.m.p.types create line
$end_pos 1 $end_pos [expr $setup(heightc
)-1] -fill gray
612 # Simulate the button.
613 bind $win.m.p.types.
$pos <Button-1
> "
614 $win.m.p.types.$pos configure -relief sunken
616 after 100 { $win.m.p.types.$pos configure -relief raised }
621 # Called back from the action menu
623 proc popup_add_action
{filename cmd idx
} {
625 menu [set m .m.action
] -tearoff 0
626 .m add cascade
-foreground $setup(action_foreground
) -label "$filename" -menu $m
627 $m add command
-label "Info" -command "mc_file_info \"$filename\""
628 $m add command
-label "Open with..." -command "mc_open_with \"$filename\""
630 $m add command
-label "Copy..." -command "$cmd invoke %d Copy"
631 $m add command
-label "Rename, move..." -command "$cmd invoke %d Move"
632 $m add command
-label "Delete..." -command "$cmd invoke %d Delete"
634 $m add command
-label "Open" -command "$cmd invoke %d Open"
635 $m add command
-label "View" -command "$cmd invoke %d View"
638 proc start_drag
{mode panel_cmd W x y X Y
} {
643 set drag_text
[$panel_cmd dragtext
[$W index
@$x,$y]]
644 set drag_text
"$mode $drag_text"
646 catch {destroy .drag
}
648 wm overrideredirect .drag
1
650 label .drag.
text -text "$drag_text"
653 wm geometry .drag
+$X+$Y
656 proc drag_test
{token
} {
657 if {[winfo children
$token] == ""} {
658 label $token.value
-text "Zonzo"
661 $token.value configure
-text Hla
665 proc mc_drag_target
{} {
668 set data
$DragDrop(text)
671 proc mc_drag_send
{} {
676 # Mouse bindings for the panels
678 proc panel_bind
{the_panel panel_cmd
} {
681 set pn
"$the_panel.m.p.panel"
683 bind $pn <Button-1
> "
684 $panel_cmd mdown 2 \[%W index @%x,%y]
687 bind $pn <ButtonRelease-1
> "
689 $panel_cmd mup 2 \[%W index @%x,%y]"
691 bind $pn <Double-1
> "
693 $panel_cmd double 2 \[%W index @%x,%y]"
695 bind $pn <B1-Motion
> "
698 $panel_cmd motion 2 \[%W index @%x,%y]
701 bind $pn <B1-Leave
> "
704 panel_drag %W $panel_cmd 2
707 bind $pn <B1-Enter
> panel_cancel_repeat
709 if $setup(b2_marks
) {
710 bind $pn <Button-2
> "
711 $panel_cmd mdown 1 \[%W index @%x,%y]"
713 bind $pn <ButtonRelease-2
> "
714 $panel_cmd mup 1 \[%W index @%x,%y]
718 bind $pn <B2-Motion
> "
721 $panel_cmd motion 1 \[%W index @%x,%y]
724 bind $pn <B2-Leave
> "
727 panel_drag %W $panel_cmd 1
731 # blt_drag&drop source $pn config -button 2 -packagecmd drag_test \
733 # blt_drag&drop source $pn handler text dd_send_file
737 bind $pn <Button-3
> "
738 $panel_cmd mdown 2 \[%W index @%x,%y]
741 $panel_cmd load \[%W index @%x,%y] %X %Y
743 catch {tk_popup .m %X %Y}
746 bind $pn <B2-Enter
> panel_cancel_repeat
748 $the_panel.m.scroll configure
\
749 -command "panel_scroll $pn $panel_cmd"
750 $the_panel.m.p.scroll configure
\
752 panel_conf
$pn $panel_cmd
755 proc panel_info
{item
} {
761 proc panel_mark
{tag panel n
} {
763 $panel tag add
$tag "${n}.0" "${n}.0 lineend"
766 # op is add or remove
767 proc panel_mark_entry
{win op line
} {
768 $win.m.p.panel tag
$op marked
$line.0 "$line.0 lineend"
771 proc panel_unmark_entry
{win line
} {
772 $win.m.p.panel tag remove selected
$line.0 "$line.0 lineend"
779 # Configure the panel tags
780 proc config_colors
{which
} {
783 # se -- selected file
784 $which tag configure selected
-back $setup(panelcolor
,selected_back
)
786 foreach v
{marked directory executable regular selected
} {
787 $which tag configure
$v -fore $setup(panelcolor
,$v)
789 $which tag configure directory
-font $setup(paneldir
)
791 $which tag
raise marked
794 proc tclerror
{msg
} {
795 puts stderr
"TkError: [$msg]\n\r"
799 # FIXME: This is not finished, have to deal with activefore, activeback
800 # highlight{fore,back}
802 proc error_colors
{wins
} {
805 foreach widget
$wins {
806 catch "$widget configure -foreground $setup(errorfore)"
807 catch "$widget configure -background $setup(errorback)"
816 proc layout_midnight
{} {
822 # we want to make the prompt and the input line sunken
823 # so we sunk the frame, and set a borderwidth for it
824 # while removing the sunken attribute set by the newinput
825 .p.i0 configure
-relief flat
826 .p configure
-relief sunken
-borderwidth 2
827 pack .p.l5
-side left
828 pack .p.i0
-side left
-expand 1 -fill x
-anchor e
829 pack .n4
-side bottom
-fill x
830 pack .p
-side bottom
-fill x
833 pack .left
-side top
-side left
-fill both
-expand 1
834 pack .right
-side top
-side right
-fill both
-expand 1
838 proc layout_query
{} {
842 set t
[llength $wlist]
844 pack .query.l1
-side top
-pady 2m
-padx 2m
845 pack .query.b0
-side right
-ipadx 2m
-padx 4m
-pady 2m
-expand 1
847 pack .query.l1
-side top
-pady 2m
-padx 2m
849 for {set b
2} {$b != 1} {incr b
} {
853 pack .query.b
$b -side right
-ipadx 2m
-padx 4m
-pady 2m
-expand 1
858 proc layout_listbox
{} {
859 scrollbar .
listbox.s
-width 3m
-command {.
listbox.x0 yview
}
860 .
listbox.x0 configure
-yscroll {.
listbox.s
set}
861 pack .
listbox.s
-fill y
-side right
862 pack .
listbox.x0
-expand 1 -fill both
-padx 4m
-pady 4m
-side left
865 proc layout_quick_confirm
{} {
866 pack .quick_confirm.c.c1 .quick_confirm.c.c2 .quick_confirm.c.c3
\
868 pack .quick_confirm.b.b0 .quick_confirm.b.b4
-side left
-padx 4m
-expand 1
870 pack .quick_confirm.c
-side top
-pady 4m
871 pack .quick_confirm.b
-side top
-pady 2m
874 proc layout_quick_file_mask
{} {
876 # puts stderr "$wlist"
879 .quick_file_mask configure
-borderwidth 5m
881 pack .quick_file_mask.b.b1 .quick_file_mask.b.b2
\
882 -side left
-expand 1 -padx 4m
884 pack .quick_file_mask.l3
-side top
-anchor w
-expand 1
885 pack .quick_file_mask.s.i5
-fill x
-expand 1 -anchor w
886 pack .quick_file_mask.s.c6
-anchor e
-padx 4m
-pady 1m
887 pack .quick_file_mask.s
-expand 1 -fill x
-side top
889 pack .quick_file_mask.d.l7
-pady 4m
890 pack .quick_file_mask.d
-side top
-anchor w
891 pack .quick_file_mask.i4
-expand 1 -fill x
-side top
893 pack .quick_file_mask.t.c8 .quick_file_mask.t.c0
-side top
-anchor e
894 catch {pack .quick_file_mask.t.c9
-side top
-anchor e
}
896 pack .quick_file_mask.t
-side top
-anchor e
897 frame .quick_file_mask.space
-height 4m
898 pack .quick_file_mask.space
-side top
899 pack .quick_file_mask.b
-fill x
-expand 1 -side top
902 proc layout_quick_vfs
{} {
904 # puts stderr "$wlist"
905 pack .quick_vfs.t.l1
-side left
906 pack .quick_vfs.t.i2
-side left
-expand 1 -fill x
-padx 2m
907 pack .quick_vfs.t.l3
-side left
909 pack .quick_vfs.l.l4
-side top
-anchor w
910 pack .quick_vfs.l.r5
-side left
-anchor w
911 pack .quick_vfs.l.i6
-side right
-anchor se
912 pack .quick_vfs.b.b7 .quick_vfs.b.b0
-padx 4m
-side left
-expand 1
914 pack .quick_vfs.t
-side top
-expand 1 -fill x
-pady 4m
-padx 4m
915 pack .quick_vfs.l
-side top
-expand 1 -fill x
-padx 4m
916 pack .quick_vfs.b
-side top
-expand 1 -fill x
-padx 4m
-pady 4m
919 proc layout_dbits
{} {
920 pack .dbits.r1
-anchor w
-padx 4m
-pady 4m
-side top
921 pack .dbits.b0
-side top
924 proc layout_chown
{} {
927 pack .chown.b.b8 .chown.b.b0
-side left
-padx 4m
-expand 1
929 # May be invoked with different number of buttons
930 # There is already a problem: the cancel button is
931 # not close to the ok button, I will have to look into this.
933 pack .chown.b.b9 .chown.b.b10 .chown.b.b11
\
934 -side left
-padx 4m
-expand 1
936 label .chown.l.fname
-text {File name
}
937 label .chown.l.owner
-text {Owner name
}
938 label .chown.l.group
-text {Group name
}
939 label .chown.l.size
-text {Size
}
940 label .chown.l.perm
-text {Permission
}
943 .chown.l.fname .chown.l.l7
\
944 .chown.l.owner .chown.l.l6
\
945 .chown.l.group .chown.l.l5
\
946 .chown.l.size .chown.l.l4
\
947 .chown.l.perm .chown.l.l3
-side top
-anchor w
-padx 2m
949 foreach i
{l3 l4 l5 l6 l7
} {
950 .chown.l.
$i configure
-fore $setup(high
)
952 pack .chown.l.l3 .chown.l.l4 .chown.l.l5 .chown.l.l6 .chown.l.l7
\
953 -side top
-pady 1m
-padx 4m
-anchor w
955 # Configure the listboxes
956 scrollbar .chown.f.s
-width 3m
-command {.chown.f.x2 yview
}
957 .chown.f.x2 configure
-yscroll {.chown.f.s
set}
958 label .chown.f.l
-text {Group name
}
959 pack .chown.f.l
-side top
-anchor w
960 pack .chown.f.x2
-side left
-fill y
-expand 1
961 pack .chown.f.s
-side right
-fill y
-expand 1
963 scrollbar .chown.g.s
-width 3m
-command {.chown.g.x1 yview
}
964 .chown.g.x1 configure
-yscroll {.chown.g.s
set}
965 label .chown.g.l
-text {User name
}
966 pack .chown.g.l
-side top
-anchor w
967 pack .chown.g.x1
-side left
-fill y
-expand 1
968 pack .chown.g.s
-side right
-fill y
-expand 1
970 .chown.b configure
-relief sunken
971 pack .chown.b
-side bottom
-pady 4m
-fill x
972 pack .chown.g .chown.f
-side left
-padx 4m
-pady 4m
-expand 1 -fill y
973 pack .chown.l
-side right
-padx 4m
976 proc layout_chmod
{} {
978 # puts stderr "$wlist \n\r"
979 pack .chmod.c.c5 .chmod.c.c6 .chmod.c.c7 .chmod.c.c8 .chmod.c.c9
\
981 .chmod.c.c11 .chmod.c.c12 .chmod.c.c13 .chmod.c.c14 .chmod.c.c15
\
982 .chmod.c.c16
-side top
-anchor w
984 pack .chmod.b.b17 .chmod.b.b0
-side left
-padx 4m
-pady 4m
-side left
986 pack .chmod.b.b18 .chmod.b.b19 .chmod.b.b19 .chmod.b.b20
\
987 .chmod.b.b21
-side left
-padx 4m
-pady 4m
-side left
990 label .chmod.l.msg
-text {Use
"t" or Insert to
\nmark attributes
}
991 label .chmod.l.fname
-text {Name
}
992 label .chmod.l.perm
-text {Permission
(octal
)}
993 label .chmod.l.owner
-text {Owner name
}
994 label .chmod.l.group
-text {Group name
}
997 .chmod.l.fname .chmod.l.l4
\
998 .chmod.l.perm .chmod.l.l1
\
999 .chmod.l.owner .chmod.l.l3
\
1000 .chmod.l.group .chmod.l.l2 .chmod.l.msg
-side top
-anchor w
-padx 2m
1001 pack .chmod.b
-side bottom
1002 pack .chmod.l
-side right
-padx 4m
-anchor n
-pady 4m
1003 pack .chmod.c
-side left
-padx 4m
-pady 4m
1006 proc layout_view
{} {
1009 pack [lindex $wlist 0] -side bottom
-fill x
1010 pack [lindex $wlist 1] -side top
-expand 1 -fill both
1013 proc layout_replace
{} {
1016 error_colors
"$wlist .replace"
1023 if [regexp ^.replace.p.l
$a] {
1025 } elseif
[regexp ^.replace.p
$a] {
1026 set plist
"$plist $a"
1027 } elseif
[regexp ^.replace.a.l
$a] {
1029 } elseif
[regexp ^.replace.a
$a] {
1030 set alist
"$alist $a"
1031 } elseif
[regexp ^.replace.i
$a] {
1032 set ilist
"$ilist $a"
1033 } elseif
[regexp ^.replace.b
$a] {
1040 # puts stderr "$wlist\n\r"
1041 # puts stderr "alist: $alist\n\rplist: $plist\n\rilist: $ilist\n\r"
1042 # puts stderr "plabel: $plabel\n\rfname: $fname"
1044 pack $fname -side top
-fill x
-anchor w
-pady 6m
-padx 12m
1045 pack $abortbutton -side bottom
-anchor e
-padx 8m
-pady 4m
1047 eval pack $ilist -side top
-anchor w
1048 pack .replace.i
-padx 10m
-pady 2m
-anchor w
1050 pack $plabel -side left
-anchor w
-padx 10m
1051 eval pack $plist -side left
-anchor e
-fill x
1052 pack .replace.p
-side top
-fill x
-padx 10m
1054 pack $alabel -side left
-anchor w
-padx 10m
1055 eval pack $alist -side left
-anchor e
-fill x
1056 pack .replace.a
-side top
-fill x
-padx 10m
1059 proc layout_complete
{} {
1062 eval pack $wlist -side top
1065 proc layout_opwin
{} {
1069 pack .opwin.b.b0 .opwin.b.b14
-side left
-expand 1
1070 pack .opwin.f0.l1 .opwin.f0.l2
-side left
-anchor w
1071 pack .opwin.f1.l3 .opwin.f1.l4
-side left
-anchor w
1073 foreach a
{.opwin
.2.l11 .opwin
.1.l8 .opwin
.0.l5
} {
1074 $a configure
-width 8
1076 pack .opwin
.2.l11 .opwin
.2.g13
-side left
-fill x
1077 pack .opwin
.1.l8 .opwin
.1.g10
-side left
-fill x
1078 pack .opwin
.0.l5 .opwin
.0.l6
-side left
-fill x
1080 pack .opwin.b
-side bottom
-pady 4m
-fill x
1081 pack .opwin.f0
-side top
-padx 10m
-anchor w
1082 pack .opwin.f1
-side top
-padx 10m
-pady 4m
-anchor w
1083 pack .opwin
.0 .opwin
.1 .opwin
.2 -side top
-padx 4m
1086 proc dummy_layout
{name
} {
1087 eval "proc layout_$name {} {
1089 # puts stderr \"\$wlist \\n\"
1090 eval pack \$wlist -side top}"
1093 # the achown commands will have to be rewriten
1094 # to use only widgets and no writing callbacks.
1103 proc layout_quick_input
{} {
1106 # puts stderr "$wlist \n\r"
1107 .quick_input.i1 configure
-width 60
1108 label .quick_input.dummy
1109 pack .quick_input.b.b2 .quick_input.b.b3
-side left
-padx 4m
-expand 1
1110 pack .quick_input.b
-side bottom
-pady 4m
1111 pack .quick_input.dummy
-side top
1112 pack .quick_input.l0
-side top
-expand 1 -ipadx 2m
-ipady 2m
1113 pack .quick_input.i1
-side bottom
-fill x
-padx 4m
1116 proc create_drop_target
{name icon
} {
1117 toplevel .drop-
$name
1119 button .drop-
$name.b
-text "Drop target"
1121 wm group .drop-
$name .
1122 wm overrideredirect .drop-
$name 1
1123 wm withdraw .drop-
$name
1124 wm deiconify .drop-
$name
1125 wm geometry .drop-
$name +0+0
1126 # blt_drag&drop target .drop-$name.b handler file mc_drag_target
1127 # blt_drag&drop target .drop-$name.b handler text mc_drag_target
1131 # Creates the container
1133 proc create_container
{container
} {
1135 pack $container -fill both
-expand 1
1139 # Removes all of the widgets in a container (.left or .right)
1141 proc container_clean
{container
} {
1142 set widgets
[winfo children
$container]
1144 foreach widget
$widgets {
1150 # Setups the binding called after the layout procedure
1152 proc bind_setup
{win
} {
1154 bindtags $win {all
$win}
1155 wm protocol
$win WM_DELETE_WINDOW
"tkmc e scape"
1159 proc keyboard_bindings
{} {
1160 # Remove the Tab binding.
1163 bind all
<KeyPress
> "tkmc r %A"
1165 # Remove the Alt-key binding and put a sensible one instead
1166 bind all
<Alt-KeyPress
> "tkmc a %A"
1167 bind all
<Control-KeyPress
> "tkmc c %A"
1168 bind all
<Meta-KeyPress
> "tkmc a %A"
1170 foreach i
{Left Right Up Down End R13 Home F27 F29 Prior
\
1171 Next F35 Return KP_Enter Delete Insert BackSpace
\
1172 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10
} {
1173 bind all
<Key-
$i> "tkmc k %K"
1177 # Centers a window based on .
1178 proc center_win
{win
} {
1179 global center_toplevels
1181 wm transient
$win [winfo toplevel [winfo parent
$win]]
1186 if {$center_toplevels} {
1187 set ch
[winfo reqheight
$win]
1188 set cw
[winfo reqwidth
$win]
1190 set geo
[split [wm geometry .
] +x
]
1191 set pw
[lindex $geo 0]
1192 set ph
[lindex $geo 1]
1193 set px
[lindex $geo 2]
1194 set py
[lindex $geo 3]
1196 set x
[expr $px+(($pw-$cw)/2)]
1197 set y
[expr $py+(($ph-$ch)/2)]
1199 wm geometry
$win +$x+$y
1203 tkwait visibility
$win
1207 # Busy window handling
1210 $w configure
-cursor watch
1215 # Color configurations
1220 proc color_model
{} {
1223 # gray85 is the background for the new tk4
1224 proc gray_colors
{base
} {
1229 # set setup(def_back) [tkDarken $base 90]
1230 # set setup(def_fore) black
1231 # set setup(selected) [tkDarken $base 110]
1232 # set setup(marked) SlateBlue
1233 # set setup(high) $setup(def_back)
1236 set dark_color
[tkDarken
$base 90]
1237 set setup
(def_back
) [tkDarken
$base 110]
1238 set setup
(selected
) NavyBlue
1239 set setup
(selected_fg
) white
1241 set dark_color
$base
1242 set setup
(def_back
) #d9d9d9
1243 set setup
(selected
) white
1244 set setup
(selected_fg
) black
1246 set setup
(def_fore
) black
1247 set setup
(high
) yellow
1253 set setup
(panelcolor
,marked
) yellow
1254 set setup
(panelcolor
,directory
) blue
1255 set setup
(panelcolor
,executable
) red
1256 set setup
(panelcolor
,regular
) black
1257 set setup
(panelcolor
,selected_back
) white
1258 set setup
(panelcolor
,selected
) black
1262 set setup
(view_bold
) "-fore yellow -back $dark_color"
1263 set setup
(view_underline
) "-fore red -back $dark_color"
1264 set setup
(view_mark
) "-fore cyan -back $dark_color"
1265 set setup
(view_normal
) "-fore black -back $dark_color"
1267 # The percentage bars on info:
1268 set setup
(percolor
) "blue"
1270 # The sort bar colors
1271 set setup
(sort_fg
) $setup(def_fore
)
1272 set setup
(sort_bg
) $setup(def_back
)
1273 set setup
(with_sortbar
) 1
1275 # We use BLT only for drag and drop, if this is not available,
1276 # then we use the 2nd button for regular file marking.
1279 set setup
(b2_marks
) 0
1281 set setup
(b2_marks
) 1
1285 set setup
(errorfore
) white
1286 set setup
(errorback
) red
1290 proc bisque_colors
{} {
1293 set setup
(def_back
) bisque3
1294 set setup
(def_fore
) black
1295 set setup
(selected
) bisque2
1296 set setup
(marked
) SlateBlue
1297 set setup
(high
) gray
1300 proc sanity_check
{} {
1301 if [catch {bindtags .
}] {
1302 puts stderr
"The Midnight Commander requires Tk 4.0 beta 3 or 4\n\r"
1303 puts stderr
"You can get it from: ftp://ftp.smli.com/pub/tcl"
1310 # Until I figure out how to remove specific bindings from a widget
1311 # I remove all of the classes bindings.
1313 #bind Text <Enter> {}
1314 #bind Text <FocusIn> {}
1316 # bind Entry <Enter> {}
1317 # bind Entry <FocusIn> {}
1321 set setup
(tearoff
) 0
1322 set setup
(action_foreground
) blue
1325 set setup
(with_icons
) 0
1327 set setup
(heightc
) 0
1328 set setup
(real_width
) 0
1330 # Determine Tk version
1331 set beta_4
![catch tk_bisque]
1333 tk_setPalette gray85
1343 set center_toplevels
1
1344 #set center_toplevels 0
1346 # button .testbutton [lindex [.testbutton configure -font] 3]
1347 #set setup(panelfont) lucidasanstypewriter-bold-14
1348 set setup
(panelfont
) lucidasanstypewriter-14
1349 set setup
(paneldir
) lucidasanstypewriter-bold-14
1350 set setup
(font) "-*-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*"
1354 # This variable if set, will make the program load gui.*.tcl files
1355 # instead of the gui.tcl file created during instalaltion.
1356 set use_separate_gui_files
0
1358 if [file exist ~
/.mc
/tkmc
] {source ~
/.mc
/tkmc
}
1361 # option add *font $setup(font) userDefault
1362 # option add *Menu*activeBackground NavyBlue
1363 # option add *Menu*activeForeground white
1364 # option add *Menubutton*activeBackground NavyBlue
1365 # option add *Menubutton*activeForeground white
1366 # option add *Button*activeBackground NavyBlue
1367 # option add *Button*activeForeground white
1368 ## set setup(panelfont) $setup(font)
1371 proc run_gui_design
{root
} {
1374 create_workspace
$root
1375 gui_design
$root $components
1378 source $LIBDIR/gd.tcl
1380 set tk_strictMotif
1
1383 create_drop_target Hola Zonzo