| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | ! Copyright (C) 2006, 2009 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | USING: debugger help help.topics kernel models compiler.units | 
					
						
							|  |  |  | assocs words vocabs accessors fry combinators.short-circuit | 
					
						
							| 
									
										
										
										
											2009-01-07 16:06:43 -05:00
										 |  |  | models models.history tools.apropos | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | ui.commands ui.gadgets ui.gadgets.panes ui.gadgets.scrollers | 
					
						
							|  |  |  | ui.gadgets.tracks ui.gestures ui.gadgets.buttons ui.gadgets.packs | 
					
						
							| 
									
										
										
										
											2009-01-06 21:55:23 -05:00
										 |  |  | ui.gadgets.editors ui.gadgets.labels ui.gadgets.status-bar | 
					
						
							|  |  |  | ui.tools.common ui ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | IN: ui.tools.browser | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | TUPLE: browser-gadget < track pane scroller search-field ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-11 17:47:38 -05:00
										 |  |  | : show-help ( link browser-gadget -- )
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |     model>> dup add-history | 
					
						
							| 
									
										
										
										
											2008-11-20 21:34:49 -05:00
										 |  |  |     [ >link ] dip set-model ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : <help-pane> ( browser-gadget -- gadget )
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |     model>> [ '[ _ print-topic ] try ] <pane-control> ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-11 17:47:38 -05:00
										 |  |  | : search-browser ( string browser -- )
 | 
					
						
							|  |  |  |     [ <apropos> ] dip show-help ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : <search-field> ( browser -- field )
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |     '[ _ search-browser ] <action-field> | 
					
						
							|  |  |  |         10 >>min-width | 
					
						
							|  |  |  |         10 >>max-width ;
 | 
					
						
							| 
									
										
										
										
											2008-12-11 17:47:38 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : <browser-toolbar> ( browser -- toolbar )
 | 
					
						
							|  |  |  |     <shelf> | 
					
						
							|  |  |  |         { 5 5 } >>gap | 
					
						
							|  |  |  |         over <toolbar> add-gadget | 
					
						
							|  |  |  |         "Search:" <label> add-gadget | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |         swap search-field>> add-gadget ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : <help-pane-scroller> ( browser -- scroller )
 | 
					
						
							|  |  |  |     pane>> <limited-scroller> | 
					
						
							| 
									
										
										
										
											2009-01-06 15:21:37 -05:00
										 |  |  |         { 550 400 } >>max-dim | 
					
						
							|  |  |  |         { 550 400 } >>min-dim ;
 | 
					
						
							| 
									
										
										
										
											2008-12-11 17:47:38 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | : <browser-gadget> ( link -- gadget )
 | 
					
						
							| 
									
										
										
										
											2008-09-27 15:36:04 -04:00
										 |  |  |     { 0 1 } browser-gadget new-track | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |         swap <history> >>model | 
					
						
							|  |  |  |         dup <search-field> >>search-field | 
					
						
							| 
									
										
										
										
											2008-12-11 17:47:38 -05:00
										 |  |  |         dup <browser-toolbar> f track-add | 
					
						
							| 
									
										
										
										
											2008-09-27 15:36:04 -04:00
										 |  |  |         dup <help-pane> >>pane | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |         dup <help-pane-scroller> >>scroller | 
					
						
							|  |  |  |         dup scroller>> 1 track-add ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 |  |  | M: browser-gadget graft* | 
					
						
							| 
									
										
										
										
											2008-07-11 01:01:22 -04:00
										 |  |  |     [ add-definition-observer ] [ call-next-method ] bi ;
 | 
					
						
							| 
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | M: browser-gadget ungraft* | 
					
						
							| 
									
										
										
										
											2008-07-11 01:01:22 -04:00
										 |  |  |     [ call-next-method ] [ remove-definition-observer ] bi ;
 | 
					
						
							| 
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : showing-definition? ( defspec assoc -- ? )
 | 
					
						
							| 
									
										
										
										
											2008-11-20 21:34:49 -05:00
										 |  |  |     { | 
					
						
							|  |  |  |         [ key? ] | 
					
						
							|  |  |  |         [ [ dup word-link? [ name>> ] when ] dip key? ] | 
					
						
							|  |  |  |         [ [ dup vocab-link? [ vocab ] when ] dip key? ] | 
					
						
							|  |  |  |     } 2|| ;
 | 
					
						
							| 
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | M: browser-gadget definitions-changed ( assoc browser -- )
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |     model>> tuck value>> swap showing-definition? | 
					
						
							| 
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 |  |  |     [ notify-connections ] [ drop ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | M: browser-gadget focusable-child* search-field>> ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 15:21:37 -05:00
										 |  |  | : com-follow ( link -- )
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  |     [ browser-gadget? ] find-window | 
					
						
							|  |  |  |     [ [ raise-window ] [ gadget-child show-help ] bi ] | 
					
						
							| 
									
										
										
										
											2009-01-06 15:21:37 -05:00
										 |  |  |     [ <browser-gadget> "Browser" open-status-window ] if* ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | : com-back ( browser -- ) model>> go-back ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | : com-forward ( browser -- ) model>> go-forward ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-08 16:32:55 -04:00
										 |  |  | : com-documentation ( browser -- ) "handbook" swap show-help ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 15:21:37 -05:00
										 |  |  | : browser-help ( -- ) "ui-browser" com-follow ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | \ browser-help H{ { +nullary+ t } } define-command | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | browser-gadget "toolbar" f { | 
					
						
							| 
									
										
										
										
											2008-11-21 23:03:14 -05:00
										 |  |  |     { T{ key-down f { A+ } "LEFT" } com-back } | 
					
						
							|  |  |  |     { T{ key-down f { A+ } "RIGHT" } com-forward } | 
					
						
							|  |  |  |     { f com-documentation } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  |     { T{ key-down f f "F1" } browser-help } | 
					
						
							|  |  |  | } define-command-map | 
					
						
							| 
									
										
										
										
											2008-04-11 23:33:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | browser-gadget "multi-touch" f { | 
					
						
							|  |  |  |     { T{ left-action } com-back } | 
					
						
							|  |  |  |     { T{ right-action } com-forward } | 
					
						
							|  |  |  | } define-command-map | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | browser-gadget "scrolling" | 
					
						
							| 
									
										
										
										
											2009-01-07 00:30:08 -05:00
										 |  |  | "The browser's scroller can be scrolled from the keyboard." | 
					
						
							| 
									
										
										
										
											2009-01-06 14:56:14 -05:00
										 |  |  | { | 
					
						
							|  |  |  |     { T{ key-down f f "UP" } com-scroll-up } | 
					
						
							|  |  |  |     { T{ key-down f f "DOWN" } com-scroll-down } | 
					
						
							|  |  |  |     { T{ key-down f f "PAGE_UP" } com-page-up } | 
					
						
							|  |  |  |     { T{ key-down f f "PAGE_DOWN" } com-page-down } | 
					
						
							| 
									
										
										
										
											2009-01-07 16:06:43 -05:00
										 |  |  | } define-command-map | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : browser-window ( -- )
 | 
					
						
							|  |  |  |     [ "handbook" com-follow ] with-ui ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MAIN: browser-window |