# configuration file for hnb
#
# Use tabs when editing this file, or edit it through hnb with
# "hnb -a ~/.hnbrc" to take advantage of the indentation in it.
#
# There are some macros which change e.g. the keybindings or look of hnb.
# Search for "configuration macro" in this file to find more out about them.
# Please note that these macros must be run after they have been defined.
#

##### user interface
	##### display format / bullets
		#
		# display_format:
		#
		#   Defining how each node is displayed, the display string
		#   syntax is interpreted as follows:
		#
		#   - Spaces turn into real spaces, i means indentation, -
		#     means bullet, d means the real data of the node, x is
		#     a temporary placeholder for upcoming column-types (for
		#     debugging only).
		#
		#   - i and x can take an argument specifying how many
		#     characters wide the field should be.
		#
		#   - Until further features are added, only the multiplier
		#     after indentation actually does something. # indicates
		#     the node number (actually line number when used as a
		#     folding editor).
		#
		# bullets:
		#
		#   What kind of bullets are displayed before each item,
		#   possible items and their default values are:
		#
		#   - bullet_leaf               "  -"
		#   - bullet_parent             "  +"
		#   - bullet_parent_expanded    "  *"
		#   - bullet_todo_parent_undone "[ ]"
		#   - bullet_todo_parent_done   "[X]"
		#   - bullet_todo_leaf_undone   "[ ]"
		#   - bullet_todo_leaf_done     "[X]"
		#
		##### samples
			#display_format "i4- d"
			#display_format "i2-d"
			#display_format "# i4- d"
			#display_format "#i2-d"
			#
			#bullet_parent          "  +"
			#bullet_parent          "  *"
			#bullet_parent          "  ·"
			#bullet_parent_expanded "  *"
			#bullet_parent_expanded "  +"
			#bullet_parent_expanded "  ·"
			#bullet_leaf            "  -"
			#bullet_leaf            "  *"
		
		macro define bullets_standard
			
			display_format "i4- d"
			
			bullet_leaf               "  -"
			bullet_parent             "  +"
			bullet_parent_expanded    "  *"
			bullet_todo_parent_undone "[ ]"
			bullet_todo_parent_done   "[X]"
			bullet_todo_leaf_undone   "[_]"
			bullet_todo_leaf_done     "[X]"
			
			end
		
		macro define bullets_alternate
			
			display_format "i2-d"
			
			bullet_leaf               " -"
			bullet_parent             " +"
			bullet_parent_expanded    " *"
			bullet_todo_parent_undone " _"
			bullet_todo_parent_done   " X"
			bullet_todo_leaf_undone   " _"
			bullet_todo_leaf_done     " X"
			
			end
		
		##### configuration macro (bullets):
		#
		# To switch to the alternative bullet scheme enable
		# "bullet_alternate" and disable "bullet_standard".
		#
		macro bullets_standard
		#macro bullets_alternate
		
	##### fixed focus
		#
		# Lock the selection bar to a position 1/3 down the screen.
		#
		# 1=true, 0=false.
		#
		fixedfocus "0"
		
##### external commands
	##### http:// handler
		#
		# What command is executed when a user wants a action performed
		# on a entry containing an URL.
		#
		# * is substituted for the URL
		#
		# The X ones have their error and standard output redirected to
		# dev/null and are put into the background to keep hnb running
		# afterwards.
		#
		##### samples
			#web_command "opera -remote 'openURL(*)'			> /dev/null 2>&1 &"
			#web_command "netscape -remote 'openURL(*)'		> /dev/null 2>&1 &"
			#web_command "netscape -remote 'openURL(*,new-window)'	> /dev/null 2>&1 &"
			#web_command "mozilla -remote 'openURL(*)'		> /dev/null 2>&1 &"
			#web_command "mozilla -remote 'openURL(*,new-window)'	> /dev/null 2>&1 &"
			#web_command "konqueror *				> /dev/null 2>&1 &"
			#web_command "galeon -n					> /dev/null 2>&1 &"
			#web_command "lynx *"
			#web_commend "rxvt -fn fixed -rv +sb -e w3m *		> /dev/null 2>&1 &"
			#web_command "opera -remote 'openURL(*,new-window)'	> /dev/null 2>&1 &"
		web_command "sensible-browser *"
		
	##### mail@handler
		#
		# What command is executed when a user wants a action performed
		# on a entry containing a mail-address.
		#
		# * is substituted for the mail-address
		#
		##### samples
			#mail_command "xterm -rv pine *				> /dev/null 2>&1 &"
			#mail_command "xterm -rv +sb -e mutt *			> /dev/null 2>&1 &"
			#mail_command "pine *"
		mail_command "mutt *"
		
	##### spell checking
		#
		# The spell-checker used.
		#
		##### samples
			#spell_command "aspell -c"
			#spell_command "ispell -x"
			#spell_command "ispell -x -damerican"
			#spell_command "ispell -x -dbritish"
			#spell_command "ispell -x -dbokmål"
			#spell_command "ispell -x -dnynorsk"
		spell_command "ispell -x"
		
##### file formats
	##### Default Format
		#
		# hnb, opml, xml, ascii  are possible choices
		#
		format "hnb"
		
	##### Remember current position in tree
		#
		# Whether hnb remembers the current position in a file
		# (currently supported by the hnb DTD only, but might easily
		# be extended since it fakes it with a XML comment).
		#
		# 1=true, 0=false.
		#
		savepos	"1"
		
	##### XML format
		##### XML Cuddling
			#
			# When loading xml files, should data be allowed on
			# the same line as tags?
			#
			xml_cuddle "0"
			
	##### Autosave
		#
		# When nodes_changed reaches above threshold, invoke
		# autosave.
		#
		autosave_threshold "15"
		autosave_threshold_nodes_changed "0"
		
		#
		# If change has occurred but is less than threshold, save when
		# number of "ticks"/keypresses, invoke autosave.
		#
		autosave_timeout    "50"
		autosave_timer     "0"
		
##### Color/style
	#
	# Color scheme configuration, syntax is:
	#
	# "style <item>  <foreground/background> <attribute,[attribute]>"
	#
	# Legal items are shown below.
	#
	# Colors are: blue, cyan, green, red, magenta, yellow, black and white.
	#
	# Attributes are: normal, reverse, bold and underline.
	#
	
	macro define 'style_standard'	
		style menuitem       default/default reverse
		style menutext       cyan/default    normal
		style parentnode     default/default bold
		style node           default/default normal
		style bullet         cyan/default    normal
		style selected       yellow/red      bold
		style parentselected yellow/red      bold
		style background     default/default normal
		end
	macro define 'style_alternate'	
		style menuitem       red/default     normal
		style menutext       default/default normal
		style parentnode     default/default bold
		style node           default/default normal
		style bullet         yellow/default    normal
		style selected       yellow/blue      normal
		style parentselected yellow/blue      bold
		style background     default/default normal
		end
	
	##### configuration macro (color scheme):
	#
	# To switch to the alternative color scheme enable
	# "style_alternate" and disable "style_standard".
	#
	macro style_standard
	#macro style_alternate
	
##### key-bindings
	#
	# Syntax:
	#   "bind <scope[,scope[...]]>  <key>   <action>"
	#
	# Multiple actions can be chained together by using the virtual key
	# ".." as the following key-binding.
	#
	##################################################
	
	context main
		helptext "ESC| menu || |F2| save || |F5| commandline || |return| edit |
		bind f1 'status "Take a look at ~/.hnbrc to check out the configuration"'
		bind .. 'status "there you will also find details about the available keybindings."'
		bind .. 'status "please feel free to contribute more useful keybindings and helptexts..."'
		
		bind esc menu
		bind ^Q 'context quitsave'
		
		bind f5 'commandline'
		bind .. 'status --clear'
		
		bind f6 'macro m_spellcheck'
			macro define m_spellcheck
				context spellcheck
				save_state
				spell
			end
		
		bind ^E 'context export'
		bind ^L 'context import'
		bind ^F 'macro m_search'
			macro define m_search
				context search
				save_state
				getquery "enter keyword to search for"
				search -f "$query"
			end
		
		bind f9  menu
		bind f10 'context user'
		
		bind ^G 'context grab'
		bind .. 'save_state'
		
		bind ^A 'action'
		bind up    up
		bind down  down
		bind left  right
		bind ..    left
		bind ..    left
		bind right right
		bind npage pagedown
		bind ppage pageup
		bind home  "go root"
		
		
		bind return edit
		bind del    remove
		
		bind ins    insert_below
		bind .. edit
		
		bind tab complete
		bind ^T  toggle_todo
		bind ^D  toggle_done
		bind >   indent
		bind <   outdent
		bind f2  save
		
		bind ^X save_state
		bind .. cut
		
		bind ^C copy
		
		bind ^V paste
		bind .. down
		
		bind ^S save_state
		bind .. sort
		
		bind backspace	backspace
		bind backspace2	backspace
		
		bind sleft "movenode left"
		bind sright	 "movenode right"
		bind sprevious "movenode up"
		bind snext "movenode down"
		
		bind + expand
		bind - collapse
		bind ] "expand --subtree"
		bind [ "collapse --subtree"
		
		bind ^Z restore_state
		
		macro define keybinding_standard
			end
		
		macro define keybinding_vi
			status   "Mutt/Vi-like keybind by Osamu Aoki 2004 osamu@debian.org"
			helptext "ESC| menu || |return| edit || |o| insert line || |s| save || |q| save&quit || |:| cmdline"
			bind q   'context quitsave'
			bind :   'commandline'
			bind E   'context export'
			bind L   'context import'
			bind /   'macro m_search'
			bind G   'context grab'
			bind ..  'save_state'
			bind  A  'action'
			bind k   up
			bind j   down
			bind h   right
			bind ..  left
			bind ..  left
			bind l   right
			bind z   pagedown
			bind Z   pageup
			bind i   edit
			bind a   edit
			bind o   insert_below
			bind ..  edit
			bind O   up
			bind ..  insert_below
			bind ..  edit
			bind T   toggle_todo
			bind D   toggle_done
			bind w   save
			bind s   save
			bind y   copy
			bind d   save_state
			bind ..  cut
			bind p   paste
			bind ..  down
			bind S   save_state
			bind ..  sort
			bind H   "movenode left"
			bind L   "movenode right"
			bind K   "movenode up"
			bind J   "movenode down"
			bind u   restore_state
			# Use "bind any ignore" instead to skip the warnings.
			bind any unbound
			end
		
		##### configuration macro (keybindings):
		#
		# To switch to the alternative keybindings enable
		# "keybinding_vi" and disable "keybinding_standard".
		#
		macro keybinding_standard
		#macro keybinding_vi
		
	context nodeedit
		helptext "editing node |  |ESC| revert || |return| confirm || |^S| split || |^J| join"
		bind up    up
		bind down  down
		bind left  left
		bind ^B    left
		bind right right
		bind ^F    right
		
		bind return  confirm
		bind esc     cancel
		
		bind ^S  split
		bind ^J  join
		
		bind backspace  backspace
		bind backspace2 backspace
		
		bind ^A   bol
		bind home bol
		bind ^E   eol
		bind end  eol
		
		bind ^D   delete
		bind del  delete
		# bkill_word is currently not implemented.
		bind ^W   bkill_word
		
	context lineedit
		helptext lineedit
		
		bind up      up
		bind down    down
		bind left    left
		bind ^B      left
		bind right   right
		bind ^F      right
		
		bind return  confirm
		bind esc     cancel
		bind tab     complete
		
		bind backspace backspace
		bind backspace2 backspace
		bind ^D         delete
		bind del        delete
		# bkill_word is currently not implemented.
		bind ^W   bkill_word
		
		bind ^A   bol
		bind home bol
		bind ^E   eol
		bind end  eol
		
	context confirm
		helptext " y | | j | |return| confirm || |any key| cancel"
		
		bind y      confirm
		bind j      confirm
		bind return confirm
		
		bind any    cancel
		
	macro define 'quitsave_standard'
		context quitsave
		helptext "Save on exit? |    | Y |es | J |a || | N |o || |ESC| cancel"
		bind Y  save
		bind .. quit
		
		bind y  save
		bind .. quit
		
		bind J  save
		bind .. quit
		
		bind j  save
		bind .. quit
		
		bind N  quit
		bind n  quit
		
		bind esc "context main"
		bind any unbound
		
		end
		
	macro define 'quitsave_alternate'
		context quitsave
		helptext "Save on exit? | |return| confirm || |x| exit without saving || |ESC| cancel"
		bind return save
		bind .. quit
		bind x  quit
		bind esc "context main"
		bind any unbound
		end
		
	##### configuration macro (quit/save dialog):
	#
	# To switch to the alternative save/quit dialog enable
	# "quitsave_alternate" and disable "quitsave_standard".
	#
	macro quitsave_standard
	#macro quitsave_alternate
		
	
	context spellcheck
		helptext "Spellchecking |   |Space| next node |ESC| cancel |F6,Return| confirm changes"
		
		bind space "go recurse"
		bind ..    spell
		
		bind down "go recurse"
		bind ..   spell
		
		bind up   "go backrecurse"
		bind ..   spell
		
		bind return "context main"
		bind f6 "context main"
		
		bind esc restore_state
		bind .. "context main"
		
		bind any unbound
	context grab
		helptext "Node grabbed |  |return| |space| drop here || |ESC| cancel"
		bind esc    restore_state
		bind ..     "context main"
		bind return "context main"
		bind space  "context main"
		bind left   "movenode left"
		bind right  "movenode right"
		bind up     "movenode up"
		bind down   "movenode down"
		bind any    unbound
	context export
		helptext "Export |  | A |scii || | H |tml  html| C |ss  | P |ostscript  | O |PML  |ESC| cancel "
			macro define m_export_ascii
				save_state
				go root
				getquery 'what file should I save the ASCII output in?'
				export_ascii $query
				restore_state
				context main
			end
			macro define m_export_html
				save_state
				go root
				getquery 'what file should I save the HTML output in?'
				export_html $query
				context main
				restore_state
			end
			macro define m_export_htmlcss
				save_state
				go root
				getquery 'what file should I save the HTML/CSS output in?'
				export_htmlcss $query
				context main
				restore_state
			end
			macro define m_export_opml
				save_state
				go root
				getquery 'what file should I save the OPML output in?'
				export_opml $query
				context main
				restore_state
			end
			macro define m_export_ps
				save_state
				go root
				getquery 'what file should I save the PostScript output in?'
				export_ps $query
				context main
				restore_state
			end
		bind esc "context main"
		bind A	"macro m_export_ascii"
		bind a	"macro m_export_ascii"
		bind H  "macro m_export_html"
		bind h  "macro m_export_html"
		bind C  "macro m_export_htmlcss"
		bind c  "macro m_export_htmlcss"
		bind O  "macro m_export_opml"
		bind o  "macro m_export_opml"
		bind P  "macro m_export_ps"
		bind p  "macro m_export_ps"		
		bind any unbound
	context import
		helptext "Import |  | A |scii | O |PML  | H |hnb   |ESC| cancel "
		
		bind esc ..
			bind .. "context main"
		bind A ..
			bind .. 'getquery "what file should I import ASCII from?"'
			bind .. 'import_ascii "$query"'
			bind .. 'context main'
		bind a ..
			bind .. 'getquery "what file should I import ASCII from?"'
			bind .. 'import_ascii "$query"'
			bind .. 'context main'
		bind O ..
			bind .. 'getquery "what file should I import OPML from?"'
			bind .. 'import_opml "$query"'
			bind .. 'context main'
		bind o ..
			bind .. 'getquery "what file should I import OPML from?"'
			bind .. 'import_opml "$query"'
			bind .. 'context main'
		bind H ..
			bind .. 'getquery "what file should I import HNB data from?"'
			bind .. 'import_hnb "$query"'
			bind .. 'context main'
		bind h ..
			bind .. 'getquery "what file should I import HNB data from?"'
			bind .. 'import_hnb "$query"'
			bind .. 'context main'
		
		bind any unbound
	context search
		helptext "Searching |  |ESC| cancel || | n |ext || | p |revious || |space|/|return| go"
		bind down   'search -f "$query"'
		bind up     'search -b "$query"'
		bind p      'search -b "$query"'
		bind n      'search -f "$query"'
		bind N      'search -b "$query"'
		
		bind return "context main"
		bind space "context main"
		
		bind esc    "context main"
		bind ..     restore_state
		
		bind any    unbound
	context user
		helptext "Usermenu | |ESC| cancel |F1| ispell language |F2| browser command |F3| expand all  |F4|  collapse all"
		bind esc "context main"
		
		bind f1  "context user_ispell"
		bind f2  "context user_browser"
		bind f3  "expand --all"
		bind ..  "context main"
		
		bind f4  "collapse --all"
		bind ..  "context main"
		
		bind any "unbound"
		
	context user_ispell
		helptext "Language for ispell: | |F1| Br.english  |F2| Am.english  |F3| Norwegian bokmål  |F4| Norwegian nynorsk"
		bind f1  'spell_command "ispell -x -damerican"'
		bind ..  'context main'
		
		bind f2  'spell_command "ispell -x -dbritish"'
		bind ..  'context main'
		
		bind f3  'spell_command "ispell -x -dbokmål"'
		bind ..  'context main'
		
		bind f4  'spell_command "ispell -x -dnynorsk"'
		bind ..  'context main'
		
		bind esc 'context main'
		bind any unbound
		
	context user_browser
		helptext "Browser action: | |F1| sensible-browser replace hnb  |F2| sensible-browser in xterm  |F3| Opera, new tab  |F4| Mozilla new window"
		bind f1 'browser_command "sensible-browser *"'
		bind .. 'context main'
		
		bind f2 'web_commend "xterm -T \"sensible-browser spawned from hnb\" -fn fixed -rv +sb -e sensible-browser * > /dev/null 2>&1 &"'
		bind .. 'context main'
		
		bind f3 'web_command "opera -remote 'openURL(*,new-window)' > /dev/null 2>&1 &"'
		bind .. 'context main'
		
		bind f4 'web_command "mozilla -remote 'openURL(*,new-window)'	> /dev/null 2>&1 &"'
		bind .. 'context main'
		
		bind esc 'context main'
		bind any unbound
		
	##### key related options
		##### escdelay
			#
			# How long the program should wait before accepting
			# that ESC(27d) is the ESC key and not the start of an
			# escape sequence.
			#
			# Increase this number if you are using hnb over a slow
			# network.
			#
			# Link value given is in ms (1/1000seconds).
			#
			escdelay 100
##### menu definition
	##### file
		menu "File" "------------" ""
		menu "File" "save      F2" "save"
		menu "File" "save as..   " "macro saveas"
			macro define saveas
				getquery db_file 'fila to save'
				save_state
				go root
				export_$format $db_file
				restore_state
				end
		menu "File" "revert   " "revert"		
		menu "File" "------------" ""
		menu "File" "export    ^E" "context export"
		menu "File" "import    ^L" "context import"
		menu "File" "------------" ""
		menu "File" "spell chk F6" "macro m_spellcheck"
		menu "File" "expand all"	    "expand --all"
		menu "File" "collapse all"      "collapse --all"
		menu "File" "statistics"	"macro stats"
			macro define stats
				status "file: \"$db_file\" format:$format"
				mem
				stats			
				end
		menu "File" "------------" ""
		menu "File" "exit      ^Q" "context quitsave"
	##### edit
		menu "Edit" "---------" ""
		menu "Edit" "copy   ^C" "copy"
		menu "Edit" "cut    ^X" "cut"
		menu "Edit" "paste  ^V" "paste"
		menu "Edit" "---------" ""
		menu "Edit" "Search ^F" "macro m_search"
	##### entry
		menu "Entry" "-------------------" ""
		menu "Entry" "edit         return" "edit"
		menu "Entry" "delete          del" "remove"
		menu "Entry" "-------------------" ""
		menu "Entry" "do action        ^A" "action"
		menu "Entry" "indent            >" "indent"
		menu "Entry" "outdent           <" "outdent"
		menu "Entry" "toggle todo      ^T" "toggle_todo"
		menu "Entry" "toggle done      ^D" "toggle_done"
		menu "Entry" "expand            +" "expand"
		menu "Entry" "expand subtree    ]" "expand --subtree"
		menu "Entry" "collapse          -" "collapse"
		menu "Entry" "collapse subtree  [" "collapse --subtree"
	##### level
		menu "Level" "------------" ""
		menu "Level" "sort      ^S" "sort -a"
		menu "Level" "sort (desc.)" "sort -d"
		menu "Level" "shuffle     " "sort -r"
#####
	context main
	macro define m_about
		status "hnb - hierarchical notebook   http://hnb.sourceforge.net/"
		status "(c) Øyvind Kolås 2001-2003    pippin@users.sourceforge.net"
		end
	
	macro m_about
