@@ -35,30 +35,33 @@ function executeAction(subject, command) {
3535 key : subject ,
3636 value : effects [ subject ]
3737 }
38+
3839 } )
3940
41+
4042 switch ( subject ) {
4143 case "window.fullscreen" :
4244 win . setFullScreen ( effects [ subject ] )
4345 break
4446 case "window.mousePassthrough" :
4547 win . setIgnoreMouseEvents ( effects [ subject ] )
4648 break
49+
4750 }
4851}
4952
5053
5154function parseBind ( binds ) {
52- function nextBind ( binds ) {
53- if ( binds . length > 0 ) parseBind ( binds )
55+ // If binds is not an array, convert it to one
56+ if ( ! Array . isArray ( binds ) ) {
57+ binds = [ binds ]
5458 }
5559
56- let bind = binds
60+ // If there are no more binds to process, return
61+ if ( binds . length === 0 ) return
5762
58- if ( typeof binds == "object" ) {
59- bind = binds [ 0 ]
60- binds . shift ( )
61- }
63+ // Get the current bind and remove it from the array
64+ let bind = binds . shift ( )
6265
6366 let actionRegex = / ( [ \w \. ] * ?) \s ? - > \s ? ( \w * ) /
6467 let functionRegex = / ( [ \w \. ] * ?) \( ( .* ?) \) /
@@ -67,6 +70,7 @@ function parseBind(binds) {
6770 let parsed = actionRegex . exec ( bind )
6871 executeAction ( parsed [ 1 ] , parsed [ 2 ] )
6972
73+ // Process remaining binds
7074 if ( binds . length > 0 ) parseBind ( binds )
7175 }
7276 else if ( bind . match ( functionRegex ) ) {
@@ -94,22 +98,29 @@ function parseBind(binds) {
9498 break
9599
96100 case "window.width" :
97- win . setSize ( Math . min ( 0 , argument ) , win . getSize ( ) [ 1 ] )
98- return nextBind ( binds )
101+ win . setSize ( Math . max ( 0 , parseInt ( argument ) ) , win . getSize ( ) [ 1 ] )
102+ if ( binds . length > 0 ) parseBind ( binds )
103+ break
104+
99105 case "window.height" :
100- win . setSize ( win . getSize ( ) [ 0 ] , Math . min ( 0 , argument ) )
101- return nextBind ( binds )
106+ win . setSize ( win . getSize ( ) [ 0 ] , Math . max ( 0 , parseInt ( argument ) ) )
107+ if ( binds . length > 0 ) parseBind ( binds )
108+ break
102109
103110 case "window.left" :
104111 win . setBounds ( { x : parseInt ( argument ) } )
105- return nextBind ( binds )
112+ if ( binds . length > 0 ) parseBind ( binds )
113+ break
114+
106115 case "window.top" :
107116 win . setBounds ( { y : parseInt ( argument ) } )
108- return nextBind ( binds )
117+ if ( binds . length > 0 ) parseBind ( binds )
118+ break
109119
110120 default :
111- console . warn ( `WARNING: Unkown keybind function in keybind "${ bind } "` )
112- return
121+ console . warn ( `WARNING: Unknown keybind function in keybind "${ bind } "` )
122+ if ( binds . length > 0 ) parseBind ( binds )
123+ break
113124 }
114125 }
115126}
0 commit comments