File tree Expand file tree Collapse file tree
utils/misc/nodejs-terminal/html/terminal-tabs Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9393 //:
9494
9595
96+ var cur = {
97+ view : null ,
98+ index : null ,
99+ } ;
96100 var mem = [ ] ;
97101
98102
141145
142146
143147 btn [ 'tab-remove' ] = function ( ) {
148+
149+ remove ( ) ;
150+
144151 } //tab-remove
145152
146153
178185 obj . remove = remove ;
179186
180187 function remove ( ) {
188+
189+ if ( ! cur . view ) {
190+ log . red ( 'no current tab' ) ;
191+ return ;
192+ }
193+
194+ cur . view . tab . remove ( ) ;
195+ cur . view . terminal . remove ( ) ;
196+ mem . splice ( cur . index , 1 , 0 ) ;
197+
198+ if ( mem . length == 0 ) {
199+ cur . view = null ;
200+ cur . index = null ;
201+ return ;
202+ }
203+
204+ if ( cur . index == mem . length ) {
205+ cur . index -- ;
206+ }
207+
208+ cur . view = mem [ cur . index ] ;
209+ show ( cur . view ) ;
210+
181211 } //remove
182212
183213
184214 function show ( view ) {
185215
186- mem . forEach ( view2 => {
216+ mem . forEach ( ( view2 , index ) => {
187217
188218 if ( view2 !== view ) {
189219 view2 . tab . classList . remove ( 'active' ) ;
193223 view2 . tab . classList . remove ( 'inactive' ) ;
194224 view2 . tab . classList . add ( 'active' ) ;
195225 view2 . terminal . show ( ) ;
226+ cur . view = view ;
227+ cur . index = index ;
196228 }
197229
198230 } ) ;
You can’t perform that action at this time.
0 commit comments