###############################################################################
#
#                           Module for rtin
#
#       Notice: The dotfile generated tinrc will contain no comments
#
###############################################################################


###############################################################################
#			    
proc internal {} {
    # Internal behaviour
    Desc "Options for the rtin newsreader"
    ShortDesc "Options that configures rtins internal behaviour"
    
    CheckBox autosavebox\
	-text "Use auto-save"\
	-default 1\
        -help "If this option is selected, then rtin will Automatically save "\
	"articles/threads by the ``Archive-name:'' line in the article header "\
	"and post process them if process type is not set to None."

    CheckBox batchsavebox\
	-text "Specify batch-save"\
	-default 0\
	-help "A command line feature. If selected, articles/threads "\
	"will be saved in batch mode when save option -S"\
	"or mail option -M is specified on the command line."

    CheckBox edoffsetbox\
	-text "Specify start editor offset"\
	-default 1\
	-help "If selected, editor will be started with cursor position into the file"\
	"otherwise the cursor will be positioned at the first line."

    Entry edformat\
	-text "Specify default editor format"\
	-default "%E +%N %F"\
        -help "Specify prefered editor with option for where to position curser and in which file"\
	"Format of editor line including parameters"\
	"%E Editor  %F Filename  %N Linenumber."\
	"Authors default uses Emacs, just using %E implies vi as default. If you want to use Emacs, "\
	"just replace %E with emacs."\
	-packEntry:side right
    
    CheckBox inews\
	-text "Use builtin inews"\
	-default 1\
	-help "Choose whether to use the builtin mini inews or "\
	"an external inews program. Inews is a user friendly news-posting front-end for relaynews, "\
	"if you don't know if you have an inews program avaiable just use the builtin mini inews in rtin."

    CheckBox slowspeed\
	-text "Speed up display on slow terminals"\
	-default 0\
	-help "If selected, rtin will strip blanks from end of lines to "\
	"speedup display on slow terminals, preferable on modem "\
	"connections."
    
    CheckBox beginner\
	-text "Show minimenu with commands"\
	-default 1\
	-help "If selected, rtin will show a mini menu of useful commands at each level, "\
	"preferable for new users."

    CheckBox keypad\
	-text "Use scroll keys on keypad "\
	-default 0\
	-help "Use scroll keys on keypad, only on supported terminals. If not selected and "




    Save {
	if $autosavebox {
	    print -file resfile "auto_save=ON" 
	} else {
	    print -file resfile "auto_save=OFF" }
	
	if $batchsavebox {
	    print -file resfile "batch_save=ON" 
	} else {
	    print -file resfile "batch_save=OFF" }

	if $edoffsetbox {
	    print -file resfile "start_editor_offset=ON" 
	} else {
	    print -file resfile "start_editor_offset=OFF" }

	print -file resfile "default_editor_format=$edformat"

	if $inews {
	    print -file resfile "use_builtin_inews=ON" 
	} else {
	    print -file resfile "use_builtin_inews=OFF" }

	if $slowspeed {
	    print -file resfile "slow_speed_terminal=ON" 
	} else {
	    print -file resfile "slow_speed_terminal=OFF" }
	
	if $beginner {
	    print -file resfile "beginner_level=ON" 
	} else {
	    print -file resfile "beginner_level=OFF" }

	if $keypad {
	    print -file resfile "use_keypad=ON" 
	} else {
	    print -file resfile "use_keypad=OFF" }
    }
}

proc reading {} {
    # Reading options
    Desc "Options concerning the reading of newsarticles"
    ShortDesc "Options that configures what to do, reading newsarticles"

    CheckBox markread\
        -text "Specify mark saved read"\
	-default 1\
	-help "If selected, rtin will mark articles that are saved as read."

    Radio killlevel\
        -text "Specify kill level"\
	-default removed after kill\
        -entries {"mark as read" "removed after kill"}\
        -help "If option 1 is selected, killed articles are simply marked as being read"\
	"if option 2 is selected, killed articles are removed and never seen again." \
	-packFrame:pady 5\
        -label:anchor w

    Radio inversdrawarrow\
        -default use inverse video\
	-entries {"use inverse video" "draw arrow at selected article"}\
	-help "Use inverse video for page headers or use -> characters for selection"
    
    Radio printheader\
        -text "Choose how articles header is to be printed"\
        -default Subject: & From: lines\
	-entries {"Full mail header" "Subject: & From: lines"}\
	-help "Print all of mail header in article (subject, received
	from, date, message-id etc.) or just the 'Subject:' & 'From:' lines."\
	-packFrame:pady 5\
	-label:anchor w

    Radio posunread\
        -text "Place cursor at"\
	-default first enread article\
	-entries {"first enread article" "last article"}\
        -help "Choose whether rtin is suposed to place cursor at first unread article in group"\
	"or at the last article when entering a newsgroup."\
	-packFrame:pady 5\
	-label:anchor w

    Radio pagescroll\
        -text "Specify scroll level"\
        -default full page scroll\
	-entries {"full page scroll" "half page scroll"}\
	-help "If selected, rtin will scroll full page of groups/articles otherwise half a page"\
	-packFrame:pady 5\
	-label:anchor w

    CheckBox catchup\
        -text "Mark read groups as read"\
	-default 0\
	-help "If selected, ask user if read groups should all be"\
	"marked read, implying that if all articles are read then the"\
	"articles is deleted upon leaving the newsgroup.  That is when"\
	"reentering the newsgroup only new articles can be read."

    CheckBox confirm\
        -text "Ask for confirm"\
	-default 1\
	-help "If selected, confirm certain commands with y/n before executing."

    Entry maxname\
	-text "Maximum newsgroup namelength"\
	-default "132"\
	-help "Maximum length of the names of newsgroups displayed. The"\
	"description of the groups will start after the"\
	"newsgroups name supplied up with blank characters upto"\
	"the specified namelength if there is a groupname present"\
	"with longer name than the specified namelength. However"\
	"if you .newsrc file (the list of your subscribed groups)"\
	"only contains groups with small names then the"\
	"groupdescription will appear just after the groupname"\
	"seperated with a blank character."\
	-packEntry:side right

    CheckBox showdesc\
        -text "Show description of group"\
	-default 1\
        -help "If selected, show group description text after newsgroup name at"\
	"group selection level."

    Radio showauthor\
        -text "Show author of article"\
        -default full name\
	-entries {"none" "address" "full name" "both"}\
        -help "Specify how to show author of article in from field you have the following options"\
	"display 0) none 1) address 2) full name 3) both. The numbers should be interpreted as"\
	"button numbers starting from the left."\
	-packFrame:pady 5\
	-label:anchor w

    CheckBox prompt\
	-text "Reading prompt"\
	-default 1\
	-help "If selected, 'Reading...' will be displayed when reading "\
	"article from NNTP server."

    CheckBox thread\
	-text "Thread all articles in group"\
	-default 1\
	-help "If selected, follow ups to articles are threaded"\
	"(stacked in one posting), otherwise all follow ups are"\
	"displayed as stand alone articles (can be time saving)"


    CheckBox tabx\
	-text "TAB after X command"\
	-default 0\
	-help "If selected, a TAB command will be automatically done after the X"\
        "command. The X command will Mark all unread articles that have not been selected"\
	"as read, redo screen to reflect changes and put index at the first thread to begin"\
	"reading. Pressing 'X' again will toggle back to the way it was before."\
	"The '~' command will clear the toggle effect and undo all selections on all articles. It clears the"\
	"toggle effect of 'X' command. Thus after first doing a 'X', one can then do '~' to reset"\
	"articles. Thus, one can iteratively whittle down uninteresting threads."

    CheckBox tabgoto\
	-text "TAB command to go to next unread article"\
	-default 1\
	-help "If this option is selected, pressing TAB inside rtin will goto next unread"\
	"article at article viewer level (just read 'goto next unread article')."


    Save {
	if $markread {
	    print -file resfile "mark_saved_read=ON" 
	} else {
	    print -file resfile "mark_saved_read=OFF" }

	print -file resfile "kill_level=$killlevel(index)"

	if {$inversdrawarrow(name)=="use inverse video"} {	
	    print -file resfile "draw_arrow=OFF"
	    print -file resfile "inverse_okay=ON" 
	} else {
	    print -file resfile "draw_arrow=ON"
	    print -file resfile "inverse_okay=OFF" }

	if {$printheader(name)!="Subject: & From: lines"} {
	    print -file resfile "print_header=ON" 
	} else {
	    print -file resfile "print_header=OFF" }

	if {$posunread(name)=="first enread article"} {
	    print -file resfile "pos_first_unread=ON" 
	} else {
	    print -file resfile "pos_first_unread=OFF" }

	if {$pagescroll(index)==0} {
	    print -file resfile "full_page_scroll=ON" 
	} else {
	    print -file resfile "full_page_scroll=OFF" }

	if $catchup {
	    print -file resfile "catchup_read_groups=ON" 
	} else {
	    print -file resfile "catchup_read_groups=OFF" }
	
	if $confirm {
	    print -file resfile "confirm_action=ON" 
	} else {
	    print -file resfile "confirm_action=OFF" }

	print -file resfile "groupname_max_length=$maxname" 

	if $showdesc {
	    print -file resfile "show_description=ON" 
	} else {
	    print -file resfile "show_description=OFF" }

	print -file resfile "show_author=$showauthor(index)" 

	if $thread {
	    print -file resfile "thread_articles=ON" 
	} else {
	    print -file resfile "thread_articles=OFF" }

	if $prompt {
	    print -file resfile "display_reading_prompt=ON" 
	} else {
	    print -file resfile "display_reading_prompt=OFF" }

	if $tabgoto {
	    print -file resfile "tab_goto_next_unread=ON" 
	} else {
	    print -file resfile "tab_goto_next_unread=OFF" }

	if $tabx {
	    print -file resfile "tab_after_X_selection=ON" 
	} else {
	    print -file resfile "tab_after_X_selection=OFF" }
    } 
}

proc posting {} {
    # Options for posting and saving articles
    Desc "Options concerning posting and saving articles"
    ShortDesc "posting and saving articles"

    Menu postprocess\
        -text "Post process type "\
	-default none\
	-entries {"none" "unshar" "uudecode" "uudecode & list zoo"\
		      "uudecode & extract zoo" "uudecode & list zip"\
		      "uudecode & extract zip"}\
	-help "Type of post processing to perform after saving articles."\
	"For help on uudecode, zoo and zip, see manual pages. That is 'man uudecode, etc,'"
    
    CheckBox unlink\
	-text "Remove ~/.article after posting"\
	-default 1\
	-help "If this option is selected, rtin will remove ~/.article after posting - that is the article produced "\
	"by the editor when posting."
    
    CheckBox unreadgroup\
	-text "Show only subscribed groups that contain unread articles"\
	-default 0\
	-help "Choose if only subscribed groups that contain unread articles"\
	"are to be displayed or not."

    Radio unread\
	-text "Specify how articles are to be shown"\
	-default show only new/unread articles\
	-entries {"show only new/unread articles" "show all articles"}\
	-help "Choose if only new/unread articles or if all articles "\
	"are to be shown."\
	-packFrame:pady 5\
	-label:anchor w

    Menu sort\
	-text "Specify which field to sort articles by"\
	-default Date, ascending\
	-entries {"nothing" "Subject, descending" "Subject, ascending"\
		      "From, descending" "From, ascending" "Date, descending"\
		      "Date, ascending"}\
        -help "Specify how to sort articles, the default value, 'Date, ascending' means "\
	"that new articles are displayed at the end of the article list."
    

    Entry newsquote\
	-text "News quote line"\
	-default "%F wrote:"\
	-help "Specify how to quote articles when following up an articled\n Format of"\
	"quote line when mailing/posting/followingup"\
	"an article is \n%A Address  %D Date  %F Addr+Name %G Groupname  %M MessageId"\
	"%N Name.\nThe default value '%F wrote', expands to 'Addr+Name wrote'"\
	-packEntry:side right

    
    Entry mailquote\
	-text "Mail quote line"\
	-default "In article %M you wrote:"\
	-help "Specify how to quote articles when mailing article. \nFormat of quote line when "\
	"mailing/posting/followingup"\
	"an article \n%A Address  %D Date  %F Addr+Name"\
	"%G Groupname  %M MessageId  %N Name."\
	-packEntry:side right

    CheckBox autocc\
	-text "Use automatic Cc when mailing an article"\
	-default 0\
	-help "If selected, rtin will automatically put your name in the Cc: (carbon copy)"\
	"field when mailing an article. That is, rtin will mail the article you send to yourself aswell."

    Save {
	print -file resfile "post_process_type=$postprocess(index)"

	if $unlink {
	    print -file resfile "unlink_article=ON" 
	} else {
	    print -file resfile "unlink_article=OFF" }
	
	if $unreadgroup {
	    print -file resfile "show_only_unread_groups=ON" 
	} else {
	    print -file resfile "show_only_unread_groups=OFF" }

	if {$unread(name)=="show only new/unread articles"} {
	    print -file resfile "show_only_unread=ON"
	} else {
	    print -file resfile "show_only_unread=OFF" }

	print -file resfile "sort_article_type=$sort(index)"

	print -file resfile "news_quote_format=$newsquote"

	print -file resfile "mail_quote_format=$mailquote"

        if $autocc {
	    print -file resfile "auto_cc=ON" 
	} else {
	    print -file resfile "auto_cc=OFF" }
    }
}

proc directory {} {
    # Directory options etc.
    Desc "Options for placing articles, printing etc."
    ShortDesc "Options for mail directories etc."

    Entry savedir\
	-text "News directory"\
	-default "~/News"\
	-help "directory where articles/threads are saved."\
	-packEntry:side right

    Entry maildir\
	-text "Mail directory"\
	-default "~/Mail"\
	-help "directory where articles/threads are saved in mailbox format."\
	-packEntry:side right

    Entry printer\
	-text "Printer path"\
	-default "/usr/ucb/lpr"\
	-help "Path for the lpr program, check with < which lpr > to get"\
	"your path, if in doubt."\
	-packEntry:side right

    Entry signature\
	-text "Signature path"\
	-default "~/.Sig"\
	-help "Signature path (random signatures)/file to be used when "\
	"posting/replying to messages.\nTin will recognize a signature in either \$HOME/.signature or"\
	"\$HOME/.Sig.   If \$HOME/.signature exists, then the signature will be pulled into the editor"\
	"for mail commands. A signature in \$HOME/.signature will not be pulled into the editor"\
        "for posting commands since inews will append the signature itself. A signature in"\
	"\$HOME/.Sig will be pulled into the editor for both posting and mailing commands.\nIn"\
	"the signaturefile use NAMES in front of names and email, SNAIL for mail address and PHONE for phone number."\
	"For help on random signatures, see the manual pages for rtin."\
	-packEntry:side right

    CheckBox mmdf\
	-text "Save in MMDF style mailbox"\
	-default 0\
	-help "Save mail to a MMDF style mailbox, for help on MMDF ask your system advisor. Don't think "\
	"much about this option, unless you are using SCO Unix, where MMDF is default."

    Save {
	print -file resfile "default_savedir=$savedir"

	print -file resfile "default_maildir=$maildir"

	print -file resfile "default_printer=$printer"

	print -file resfile "default_sigfile=$signature"

	if $mmdf {
	    print -file resfile "save_to_mmdf_mailbox=ON" 
	} else {
	    print -file resfile "save_to_mmdf_mailbox=OFF" }
    }
}

proc special {} {
    # Special characters etc.
    Desc "Options quoting articles, auto selected etc."
    ShortDesc "Special options"

    Entry reread\
	-text "Reread the active file after"\
	-textafter " seconds"\
	-default 600\
	-help "Time interval in seconds between rereading the active file. That is the file representing "\
	"new articles and other newsgroup informaton. The default is 10 minutes."\
	-packEntry:side right

    Entry quote\
	-text "Quote characters"\
	-default "_"\
	-help "Characters used in quoting to followups and replys."\
	"'_' is synonym for ' ' (blank)"\
	-packEntry:side right\
	-width 2

    Entry unreadmark\
	-text "Unread article character"\
	-default "+"\
	-help "Character used to show that an article was unread."\
	-packEntry:side right\
	-width 2

    Entry hot\
	-text "Autoselected article chracter"\
	-default "*"\
	-help "Character used to show that an article was auto-selected (hot)."\
	-packEntry:side right\
	-width 2

    Entry return\
	-text "Returning article character"\
	-default "--"\
	-help "Character indicating that an article will return."\
	-packEntry:side right\
	-width 2

    Change {
	if {$changeElm=="quote"} {
	    set quote [string index $quote [expr [string length $quote] - 1]]
	}
	if {$changeElm=="unreadmark"} {
	    set unreadmark [string index $unreadmark [expr [string length $unreadmark] - 1]]
	}
	if {$changeElm=="hot"} {
	    set hot [string index $hot [expr [string length $hot] - 1]]
	}
	if {$changeElm=="return"} {
	    set return [string index $return [expr [string length $return] - 1]]
	}
    }	

    Save {
	print -file resfile "reread_active_file_secs=$reread"
	
	print -file resfile "quote_chars=$quote"

	print -file resfile "unread_art_mark=$unreadmark"

	print -file resfile "hot_art_mark=$hot"

	print -file resfile "return_art_mark=$return"
    }
}

proc display {} {
    # Display options
    Desc "Display options"
    ShortDesc "Display options"

    CheckBox showline\
	-text "Last line of previous page shown as first line of next page"\
	-default 0\
	-help "Show the last line of the previous page as the first"\
	"line of the next page."

    CheckBox redraw\
	-text "Force screen redraw"\
	-default 0\
	-help "If selected, a screen redraw will be done after certain "\
	"external commands."
    
    Save {
	if $showline {
	    print -file resfile "show_last_line_prev_page=ON" 
	} else {
	    print -file resfile "show_last_line_prev_page=OFF" }

	if $redraw {
	    print -file resfile "force_screen_redraw=ON" 
	} else {
	    print -file resfile "force_screen_redraw=OFF" }
    }
}

proc default {} {
    # Default action-prompt strings
    Desc "default action/prompt strings, no values needed, since rtin asks"\
	"for a value when needed"
    ShortDesc "default action/prompt strings"

    Entry spooldir\
	-text "Spool dir alias"\
	-default "news"\
	-help "Default spool dir, if this default value doesn't work, "\
	"ask your system maneger for help."\
	-packEntry:side right

    Entry authorsearch\
	-text "Author search"\
	-help "What name to search for with the rtin a or A command, see rtin manual "\
	"pages for more or just try pressing a or A inside rtin."\
	-packEntry:side right

    Entry gotogroup\
	-text "Default goto group"\
	-help "What group to go to pressing g in rtin, for more help see "\
	"the rtin manual pages or try it out."\
	-packEntry:side right

    Entry groupsearch\
	-text "Default group search"\
	-help "What group to search for pressing / or ? in rtin, for more "\
	"help see the rtin manual pages or try it out."\
	-packEntry:side right

    Entry subjectsearch\
	-text "Default subject search"\
	-help "What subject to search for pressing / or ? in rtin, for more "\
	"help see the rtin manual pages or try it out."\
	-packEntry:side right

    Entry artsearch\
	-text "Default article search"\
	-help "What article to search for pressing / or ? in rtin, for more "\
	"help see the rtin manual pages or try it out."\
	-packEntry:side right

    Entry crosspost\
	-text "Default group to crosspost in"\
	-help "What newsgroup in which to crosspost postings."\
	-packEntry:side right

    Entry mailaddr\
	-text "Default mailaddress"\
	-help "Default mailaddress when mailing article."\
	-packEntry:side right

    Entry movegroup\
	-text "Default move group"\
	-help "Default group to move to when pressing m in rtin (every newsgroup have a number "\
	"in rtin, pressing m will give the highlighted newsgroup a new user specified number, for more "\
	"help see the rtin manual pages or try it out."\
	-packEntry:side right

    Entry pipe\
	-text "Default pipe command"\
	-help "Default pipe command, when piping articles into command."\
	-packEntry:side right

    Entry postgroup\
	-text "Default newsgroup to post in"\
	-help "Default group in which to post article."\
	-packEntry:side right

    Entry postsubject\
	-text "Default subject when posting article"\
	-help "Default subject when posting article."\
	-packEntry:side right

    Entry regexp\
	-text "Default regular expression"\
	-help "Default regular expression, used in = command, see the rtin manual "\
	"pages."\
	-packEntry:side right

    Entry savefile\
	-text "Default filename when saving article"\
	-help "Default filename when saving article, that is a full pathname."\
	-packEntry:side right

    Entry pattern\
	-text "Default select pattern"\
	-help "Default select pattern when selecting articles, that is you can select articles with a certain "\
	"pattern for more help see the rtin manual pages."\
	-packEntry:side right

    Entry shell\
	-text "Default shell command"\
	-help "Default shell command."\
	-packEntry:side right


    Save {
	print -file resfile "default_spooldir_alias=$spooldir"

	print -file resfile "default_author_search=$authorsearch"

	print -file resfile "default_goto_group=$gotogroup"

	print -file resfile "default_group_search=$groupsearch"

	print -file resfile "default_subject_search=$subjectsearch"

	print -file resfile "default_art_search=$artsearch"

	print -file resfile "default_crosspost_group=$crosspost"

	print -file resfile "default_mail_address=$mailaddr"

	print -file resfile "default_move_group=$movegroup"

	print -file resfile "default_pipe_command=$pipe"

	print -file resfile "default_post_newsgroups=$postgroup"

	print -file resfile "default_post_subject=$postgroup"

	print -file resfile "default_regex_pattern=$regexp"

	print -file resfile "default_save_file=$savefile"

	print -file resfile "default_select_pattern=$pattern"

	print -file resfile "default_shell_command=$shell"

	print -file resfile "# news motd file dates from server used for detecting new motd info"

	print -file resfile "motd_file_info=837711926"

	print -file resfile "# active file sizes/dates from different servers used for detecting new groups"

	print -file resfile "active_file_info=news.uni-c.dk\[960718 194532\]"
    }
}
