@@ -95,9 +95,9 @@ export function Help({show, setShow, style}) {
9595 </ >
9696}
9797
98- const availableStyles = [ 'Sequent ' , 'SequentBindingMode ' ] ;
98+ const availableStyles = [ 'UserVisible ' , 'InMemory ' ] ;
9999
100- export function MainNavBar ( { compare, setCompare, style, setStyle } ) {
100+ export function MainNavBar ( { compare, setCompare, style, setStyleName , styleMap } ) {
101101 const navigate = useNavigate ( )
102102 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
103103 function resetSearchParams ( ) {
@@ -114,11 +114,11 @@ export function MainNavBar({compare, setCompare, style, setStyle}) {
114114
115115 const currentStyle = style ;
116116 const styles = availableStyles . map ( style_name => {
117- let style = PredicateStyleJs . from_name ( style_name ) ;
117+ let style = styleMap [ style_name ] ;
118118 return < OverlayTrigger key = { style_name } placement = "bottom" overlay = { < Tooltip > { style . doc ( ) } </ Tooltip > } >
119119 < Button
120120 active = { currentStyle . to_name ( ) == style_name }
121- onClick = { ( ) => setStyle ( style ) }
121+ onClick = { ( ) => setStyleName ( style_name ) }
122122 dangerouslySetInnerHTML = { { __html : style . display_generic_predicate ( ) } }
123123 > </ Button >
124124 </ OverlayTrigger >
@@ -399,17 +399,34 @@ export default function Solver() {
399399 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
400400 const sp = { searchParams, setSearchParams} ;
401401 const [ compare , setCompare ] = useStateInParams ( sp , 'compare' , false , ( x ) => x == 'true' ) ;
402- const defaultStyle = PredicateStyleJs . from_name ( 'Sequent' ) ;
403- const [ style , setStyle ] = useStateInParams ( sp , 'style' , defaultStyle , PredicateStyleJs . from_name , ( style ) => style . to_name ( ) ) ;
404402 const [ optionsLeft , setOptionsLeft ] = useStateInParams ( sp , 'opts1' , RuleSetJs . from_bundle_name ( 'nadri' , 'stable' ) , RuleSetJs . decode , ( o ) => o . encode ( ) ) ;
405403 const [ optionsRight , setOptionsRight ] = useStateInParams ( sp , 'opts2' , RuleSetJs . from_bundle_name ( 'rfc3627' , 'rfc3627' ) , RuleSetJs . decode , ( o ) => o . encode ( ) ) ;
406404 const [ inputQuery , setInputQuery ] = useStateInParams ( sp , 'q' , "[&x]: &mut [&T]" ) ;
407405 const [ mode , setMode ] = useStateInParams ( sp , 'mode' , 'typechecker' , validateIn ( [ 'typechecker' , 'rules' , 'compare' ] ) ) ;
406+ const [ styleName , setStyleName ] = useStateInParams ( sp , 'style' , 'UserVisible' , validateIn ( [ 'UserVisible' , 'InMemory' , 'Sequent' , 'SequentBindingMode' ] ) ) ;
407+
408+ // Map from style name to predicate style. Takes into account the selected
409+ // options to hide parts of the predicate we don't care about.
410+ const styleMap = useMemo ( ( ) => {
411+ var map = availableStyles . reduce ( function ( map , style_name ) {
412+ if ( compare ) {
413+ map [ style_name ] = PredicateStyleJs . from_name_and_options ( style_name , optionsLeft , optionsRight ) ;
414+ } else {
415+ map [ style_name ] = PredicateStyleJs . from_name_and_option ( style_name , optionsLeft ) ;
416+ }
417+ return map ;
418+ } , { } ) ;
419+ // Back-compat with permalinks that used the old style names.
420+ map [ 'Sequent' ] = map [ 'UserVisible' ] ;
421+ map [ 'SequentBindingMode' ] = map [ 'InMemory' ] ;
422+ return map ;
423+ } , [ compare , optionsLeft , optionsRight ] ) ;
424+ const style = styleMap [ styleName ] ;
408425
409426 return (
410427 < >
411428 < div className = "sticky-top" >
412- < MainNavBar { ...{ compare, setCompare, style, setStyle } } />
429+ < MainNavBar { ...{ compare, setCompare, style, setStyleName , styleMap } } />
413430 < SolverOptions options = { optionsLeft } setOptions = { setOptionsLeft } title = { compare ? < > Left </ > : null } />
414431 { compare ? < SolverOptions options = { optionsRight } setOptions = { setOptionsRight } title = "Right" /> : null }
415432 </ div >
0 commit comments