home *** CD-ROM | disk | FTP | other *** search
- # Copyright 1994 Z-Code Software, a division of Network Computing Devices, Inc.
- # All rights reserved.
-
- function zmenu_fwd_add_comments () {
- ask -i __comment "$__ask_add_comment"
- if $status == 0
- mail -C "$__comment" -resend
- unset __comment
- endif
- }
-
- function zmenu_send_and_close () {
- compcmd send
- if $status == 0
- dialog -close
- endif
- }
-
- function zmenu_insert_file () {
- ask -f __file "$__ask_file_read"
- if $status == 0
- if $1 == replace
- textedit set-item compose-body
- textedit delete-all
- endif
- compcmd insert-file "$__file"
- unset __file
- endif
- }
-
- function zmenu_insert_indented_file () {
- ask -f __file "$__ask_file_read"
- if $status == 0
- set __pfx=''
- if $?indent_str != 0
- set __pfx="$indent_str"
- endif
- if "x$__pfx" == "x"
- ask -i __pfx "$__ask_indent_with"
- else
- ask -i __pfx -d "$__pfx" "$__ask_indent_with"
- endif
- if $status == 0
- if $1 == replace
- textedit set-item compose-body
- textedit delete-all
- endif
- textedit set-item compose-body
- textedit get-cursor-position __indentstart
- compcmd insert-file "$__file"
- textedit get-cursor-position __indentend
- textedit set-selection-position $__indentstart $__indentend
- textedit indent "$__pfx"
- endif
- unset __file __pfx
- endif
- }
-
- function clear_output () {
- textedit set-item output-text
- textedit delete-all
- }
-
- set __save_file=''
- function zmenu_save_to_file () {
- if "x$__save_file" != "x"
- ask -f __save_file -d "$__save_file" "$__ask_file_write"
- else
- ask -f __save_file "$__ask_file_write"
- endif
- if $status == 0
- compcmd save-to-file "$__save_file"
- if $status == 0
- eval echo "$__info_saved_to"
- endif
- endif
- }
-
- set __draft_file=''
- function zmenu_save_draft () {
- if "x$__draft_file" != "x"
- ask -f __draft_file -d "$__draft_file" "$__ask_draft_write"
- else
- ask -f __draft_file "$__ask_draft_write"
- endif
- if $status == 0
- compcmd save-draft "$__draft_file"
- if $status == 0
- eval echo "$__info_saved_draft"
- endif
- endif
- }
-
- function zmenu_next_ref_subj () {
- msg_list . | set __msgno
- set __subj="$[%S]"
- if "x$__subj" == "x"
- eval error $__err_no_subject
- unset __msgno __subj
- return
- endif
- search +2 -1 -r .-$ -s -n -e "$__subj"$
- if "x$output" == "x"
- eval error "$__err_no_next_about"
- else
- if "$output" == "$__msgno"
- eval error "$__err_no_next_about"
- unset __msgno __subj
- else
- msg_list - $output | display
- endif
- endif
- # unset __msgno __subj
- }
-
- function zmenu_prev_ref_subj () {
- msg_list . | set __msgno
- set __subj="$[%S]"
- if "x$__subj" == "x"
- eval error "$__err_no_subject"
- unset __msgno __subj
- return
- endif
- search -2 +1 -r ^-. -s -n -e "$__subj"$
- if "x$output" == "x"
- eval error "$__err_no_prev_about"
- else
- if $output == $__msgno
- eval error "$__err_no_prev_about"
- else
- msg_list - $output | display
- endif
- endif
- # unset __msgno __subj
- }
-
- function zmenu_all_ref_subj () {
- msg_list . | set __msgno
- if "x$[%S]" == "x"
- eval error "$__err_no_subject"
- unset __msgno
- return
- endif
- unset __msgno
- search -s -n -e "$[%S]"$
- }
-
- function zmenu_next_ref_auth () {
- msg_list . | set __msgno
- set __auth="$[%a]"
- search +2 -1 -r .-$ -n -f "$__auth"
- if $output == $__msgno
- eval error "$__err_no_next_from"
- else
- msg_list - $output | display
- endif
- # unset __msgno __auth
- }
-
- function zmenu_prev_ref_auth () {
- msg_list . | set __msgno
- set __auth="$[%a]"
- search -2 +1 -r ^-. -n -f "$__auth"
- if $output == $__msgno
- eval error "$__err_no_prev_from"
- else
- msg_list - $output | display
- endif
- # unset __msgno __auth
- }
-
- function zmenu_all_ref_auth () {
- search -n -f "$[%a]"
- }
-
- function zmenu_next_ref_msgid () {
- msg_list . | set __msgno
- set __mid="$[%i]"
- if "x$__mid" == "x"
- eval error "$__err_no_message_id"
- unset __msgno __mid
- return
- endif
- search +1 -r .-$ -h references,in-reply-to -n -e "$__mid"
- if "x$output" == x
- error "$__err_no_next_ref"
- else
- msg_list - $output | display
- endif
- # unset __msgno __mid
- }
-
- function zmenu_prev_ref_msgid () {
- if "x$[%?references?]" == x
- error "$__err_no_prev_ref"
- return
- endif
- set __msgidlist=
- foreach i ($[%?references?]) 'set __msgidlist += $i"\|"'
- set __msgidlist += NONEXISTENT
- search -1 -r ^-. -h message-id "$__msgidlist"
- if "x$output" == x
- error "$__err_no_prev_ref"
- else
- msg_list - $output | display
- endif
- }
-
- function zmenu_all_ref_msgid () {
- msg_list . | set __msgno
- set __mid="$[%i]"
- if "x$__mid" == "x"
- eval error "$__err_no_message_id"
- unset __msgno __mid
- return
- endif
- unset __msgno __mid
- search -n -h references,in-reply-to -e "$[%i]"
- msg_list . $output
- }
-
- function zmenu_all_ref_thread () {
- set __mid="$[%i]" __ref="$[%?references?]"
- if "x$__mid" != "x"
- set __msgidlist="$__mid"'\|'
- endif
- if x"$__ref" != x
- foreach i ($[%?references?]) 'set __msgidlist += $i"\|"'
- endif
- set __msgidlist += NONEXISTENT
- if "$__msgidlist" == NONEXISTENT
- eval error "$__err_no_message_id"
- unset __ref __mid __msgidlist
- return
- endif
- search -h message-id,references "$__msgidlist"
- }
-
- function zmenu_all_ref_mark () {
- msg_list `:m`
- }
-
- function zmenu_all_ref_priority () {
- if "x$[%?priority?]" == "x"
- msg_list . | set __msgno
- error "$__err_no_priority"
- unset __msgno
- return
- endif
- search -p "$[%?priority?]"
- }
-
- function zmenu_next_ref_mark () {
- msg_list .-$ {.} | :m
- if "x$output" == x
- error "$__err_no_next_mark"
- else
- search +1 -r $output | display
- endif
- }
-
- function zmenu_prev_ref_mark () {
- msg_list ^-. {.} | :m
- if "x$output" == x
- error "$__err_no_prev_mark"
- else
- search -1 -r $output | display
- endif
- }
-
- function zmenu_next_ref_priority () {
- if "x$[%?priority?]" == "x"
- msg_list . | set __msgno
- eval error "$__err_no_priority"
- unset __msgno
- return
- endif
- set __pri="$[%?priority?]"
- search -r .-$ {.} -p $__pri +1
- if "x$output" == x
- eval error "$__err_no_next_priority"
- else
- display $output
- endif
- }
-
- function zmenu_prev_ref_priority () {
- if "x$[%?priority?]" == "x"
- msg_list . | set __msgno
- eval error "$__err_no_priority"
- unset __msgno
- return
- endif
- set __pri="$[%?priority?]"
- search -r ^-. {.} -p $__pri -1
- if "x$output" == x
- eval error "$__err_no_prev_priority"
- else
- display $output
- endif
- }
-
- function zmenu_all_ref_priority () {
- if "x$[%?priority?]" == "x"
- msg_list . | set __msgno
- eval error "$__err_no_priority"
- unset __msgno
- return
- endif
- search -p $[%?priority?]
- }
-
- function zmenu_msg_pri_other () {
- ask -input __pri "$__ask_pri_other"
- if $status == 0
- mark -"$__pri"
- endif
- }
-
- function zmenu_comp_pri_other () {
- ask -input __pri "$__ask_pri_other"
- if $status == 0
- set compose_state += pri_"$__pri"
- endif
- }
-
- function zmenu_comp_body_textedit () {
- textedit set-item compose-body
- textedit $*
- }
-
- function zmenu_comp_body_textcopy () {
- textedit set-item compose-body
- textedit get-selection-position __start __end
- if $__start == $__end
- if ! $?compose_state:(edit_headers)
- error -p "$__err_no_selection"
- else
- zmenu_comp_header_textcopy $*
- endif
- else
- textedit $*
- endif
- }
-
- function zmenu_comp_body_paste () {
- textedit set-item compose-body
- textedit paste-replace
- }
-
- function zmenu_comp_header_textcopy () {
- textedit set-item compose-header
- textedit get-selection-position __start __end
- if $__start == $__end
- error -p "$__err_no_selection"
- else
- textedit $*
- endif
- }
-
- function zmenu_msg_body_textedit () {
- textedit set-item message-body
- textedit $*
- }
-
- function zmenu_msg_body_textcopy () {
- textedit set-item message-body
- textedit get-selection-position __start __end
- if $__start == $__end
- zmenu_msg_header_textcopy $*
- else
- textedit $*
- endif
- }
-
- function zmenu_msg_header_textcopy () {
- textedit set-item message-header
- textedit get-selection-position __start __end
- if $__start == $__end
- error -p "$__err_no_selection"
- else
- textedit $*
- endif
- }
-
- set __pipe_cmd=''
- function zmenu_comp_pipe () {
- textedit set-item compose-body
- textedit get-selection-position __start __end
- if "x$__pipe_cmd" != "x"
- ask -i __pipe_cmd -d "$__pipe_cmd" "$__ask_pipe_to_shell"
- else
- ask -i __pipe_cmd "$__ask_pipe_to_shell"
- endif
- if $status == 0
- textedit set-item compose-body
- #if $__start == $__end
- # textedit select-all
- #else
- textedit set-selection-position $__start $__end
- #endif
- textedit pipe "$__pipe_cmd"
- endif
- }
-
- function zmenu_comp_indent () {
- set __pfx=''
- textedit set-item compose-body
- textedit get-selection-position __indentstart __indentend
- if $?indent_str != 0
- eval -h set __pfx="'$indent_str'"
- endif
- if "x$__pfx" == "x"
- ask -i __pfx "$__ask_indent_with"
- else
- ask -i __pfx -d "$__pfx" "$__ask_indent_with"
- endif
- if $status == 0
- textedit set-selection-position $__indentstart $__indentend
- textedit indent "$__pfx"
- unset __pfx
- endif
- }
-
- function zmenu_comp_done () {
- if $?compose_state:(active) == 0
- dialog -close
- return
- endif
- ask -m -d "$__choice_cc_send" -i __action "$__ask_comp_cancel" "$__choice_cc_continue" "$__choice_cc_discard" "$__choice_cc_send"
- if $status == 0
- if "x$__action" == "x$__choice_cc_send"
- compcmd send
- endif
- if "x$__action" == "x$__choice_cc_discard"
- compcmd quit
- endif
- # Used "Done". If not autodismiss, close window anyway.
- if $?autodismiss
- # Check for either set to nothing, or set to "compose"
- # Have to do this so we don't close the wrong dialog!
- if $?autodismiss:(compose)
- return 0
- endif
- if X"$autodismiss" == X
- return 0
- endif
- endif
- if $?compose_state:(active) == 0
- dialog -close
- endif
- endif
- }
-
- function zmenu_set_tmpdir() {
- unset __tmpdir
- if $?tmpdir
- if "x$tmpdir" != x
- set __tmpdir = "$tmpdir"
- return
- endif
- endif
- set __tmpdir = /tmp
- }
-
- function zmenu_comp_print () {
- zmenu_set_tmpdir
- ## To print both message and headers:
- # if $compose_state:(edit_headers)
- # textedit set-item compose-header
- # textedit save-to-file $__tmpdir/zmsg$$ # Write headers
- # compcmd save-to-file $__tmpdir/zmsg$$ # Append body
- # else
- compcmd write-to-file $__tmpdir/zmsg$$ # Write body
- # endif
- ##
- if $status != 0
- return
- endif
- lpr $__tmpdir/zmsg$$
- remove -f $__tmpdir/zmsg$$
- }
-
- function zmenu_toolbar_include() {
- if !$compose_state:(active)
- error "$__err_no_compose"
- return
- endif
- ask -m -i __userChoice "$__ask_include" "$__choice_message" "$__choice_file"
- if $status != 0
- return -1
- endif
- if "$__userChoice" == "$__choice_file"
- ask -f __userChoice2 "$__ask_file_include"
- if $status != 0
- return -1
- endif
- compcmd insert-file "$__userChoice2"
- else
- compcmd include-message
- endif
- }
-
- function zmenu_toolbar_send() {
- if $?compose_state:(active)
- compcmd send
- else
- error "$__err_no_compose"
- endif
- }
-
-
- function zmenu_include_message_at_cursor() {
- textedit set-item compose-body
- textedit text-deselect
- textedit text-open-line
- textedit text-forward-char
- textedit text-get-cursor-position __current_cursor
- textedit text-end
- textedit text-get-cursor-position __old_end_of_file
- compcmd include-message
- if $status != 0
- textedit text-set-cursor-position $__current_cursor
- textedit text-delete-backward-char
- return
- endif
- textedit text-set-cursor-position $__old_end_of_file
- textedit text-start-selecting
- textedit text-end
- textedit text-cut-selection
- textedit text-deselect
- textedit text-set-cursor-position $__current_cursor
- textedit text-paste
- }
-
- function zbutton_read () {
- msg_list | set __msg_list
- if "x$__msg_list" !~ "x*[-,]*"
- type
- else
- error -p $__err_read_multiple
- endif
- }
-
- function zbutton_reuse () {
- zmenu_set_tmpdir
- textedit set-item compose-body
- textedit save-to-file $__tmpdir/zmsg$$
- if $status != 0
- return
- endif
- textedit set-item subject-header-field
- textedit get-text __subj
- # if the above operation did not succeed, Edit Headers must be set
- if $status == 0
- if "x$__subj" == "x"
- mail -edit_hdrs! -file $__tmpdir/zmsg$$
- else
- mail -edit_hdrs! -subject "$__subj" -file $__tmpdir/zmsg$$
- endif
- else
- mail -edit_hdrs -draft $__tmpdir/zmsg$$
- endif
- remove -f $__tmpdir/zmsg$$
- }
-
- function zmenu_edit_signature () {
- set __sigstrname = ~/.sigstring
- set __sigfilename = ~/.signature
- if $?autosign
- if "X$autosign" =~ 'X\\*'
- sh echo "$autosign" > $__sigstrname
- set autosign = $__sigstrname
- else
- if "X$autosign" =~ 'X\[*\]'
- sh echo "$autosign" > $__sigstrname
- set autosign = $__sigstrname
- endif
- endif
- endif
- if ! $?autosign
- set autosign = $__sigfilename
- endif
- if X"$autosign" == X
- set __sigfile = $__sigfilename
- else
- set __sigfile = "$autosign"
- endif
- if ! -e $__sigfile
- if $?realname
- sh echo "$realname" > "$__sigfile"
- else
- sh echo > "$__sigfile"
- endif
- endif
- page -e "$__sigfile"
- unset __sigfile __sigstrname __sigfilename
- }
-
- function zmenu_view_only_selected () {
- msg_list | set __mlist
- flags +H *{$__mlist}
- unset __mlist
- msg_list .
- }
-
- function zmenu_unhide_all () {
- flags -H *
- unset hidden
- msg_list .
- }
-
- function zmenu_paste_indented () {
- set __pfx=''
- if $?indent_str != 0
- set __pfx="$indent_str"
- endif
- if "x$__pfx" == "x"
- ask -i __pfx "$__ask_indent_with"
- else
- ask -i __pfx -d "$__pfx" "$__ask_indent_with"
- endif
- if $status == 0
- textedit set-item compose-body
- textedit get-cursor-position __indentstart
- textedit paste
- textedit get-cursor-position __indentend
- if x$__indentstart == x$__indentend
- error -p "$__err_clipboard_empty"
- else
- textedit set-selection-position $__indentstart $__indentend
- textedit indent "$__pfx"
- endif
- endif
- unset __pfx
- }
-
- function zmenu_paste_fill () {
- textedit set-item compose-body
- textedit get-cursor-position __indentstart
- textedit paste
- textedit get-cursor-position __indentend
- if x$__indentstart == x$__indentend
- error -p "$__err_clipboard_empty"
- else
- textedit set-selection-position $__indentstart $__indentend
- textedit fill
- endif
- }
-
- function zmenu_remove_folder () {
- ask -f __file -d +/ "$__ask_folder_remove"
- if $status == 0
- rmfolder "$__file"
- unset __file
- endif
- }
-
- function zmenu_merge_folder () {
- ask -f __file -d +/ "$__ask_folder_merge"
- if $status == 0
- merge "$__file"
- unset __file
- endif
- }
-
- function zmenu_sort_by () {
- sort $*
- if $?main_state:(folder_has_messages)
- redraw .
- endif
- }
-
- function zmenu_full_headers () {
- if ! $?display_headers
- set display_headers = unignored
- endif
- display
- }
-
- function capture_name() {
- zmenu_set_tmpdir
- set "$1" = "$__tmpdir/mail-capture-$$-$__media_counter"
- arith __media_counter = "$__media_counter" + 1
- }
-
- function capture_create() {
- sh "rm -f $1"
- sh "capture -fixedMode -$2 -nofork -fixedFile $1"
- }
-
- function capture_attach() {
- if -e "$1"
- compcmd attach-file "$1" "$2"
- endif
- }
-
- function capture_tiff() {
- if -e "$1"
- capture_name __tiff_file
- sh "imgcopy -ftiff $1 $__tiff_file"
- sh "rm -f $1 &"
- capture_attach "$__tiff_file" image/tiff
- endif
- }
-
- function capture_video() {
- capture_name __capture_file
- capture_create "$__capture_file" "video -movieCompression MVC2"
- capture_attach "$__capture_file" video/x-sgi-movie
- }
-
-
- function capture_still() {
- capture_name __capture_file
- capture_create "$__capture_file" still
- capture_tiff "$__capture_file"
- }
-
- function capture_audio() {
- sh apanel -nodisplay -source mic &
- capture_name __capture_file
- capture_create "$__capture_file" audio
-
- if -e "$__capture_file"
- capture_name __mulaw_file
- set __mulaw_file=$__mulaw_file.au
- sh "sfconvert $__capture_file $__mulaw_file -quiet -outputraw channels 1 rate 8000 mulaw > /dev/null"
- sh "rm -f $__capture_file &"
- capture_attach "$__mulaw_file" audio/basic
- endif
- }
-
- function capture_screen() {
- capture_name __capture_file
- capture_create "$__capture_file" snapshot
- capture_tiff "$__capture_file"
- }
-
- function exit_hook() {
- zmenu_set_tmpdir
- sh "rm -f $tmpdir/mail-capture-$$-* &"
- }
-
- set __media_counter=0
-
-
- button -name Read zbutton_read
- button -name Delete delete
- button -name Undelete undelete
- button -name Save dialog Save
- button -name Print 'lpr'
- button -n -name Compose mail
- button -name Reply replysender
- button -name Forward 'mail -f'
- button -n -name Update update
-
-