Skip to content

Commit aeff295

Browse files
save file
1 parent 460f1f5 commit aeff295

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

utils/misc/nodejs-terminal/html/terminal-tabs/terminal-tabs.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
//:
9494

9595

96+
var cur = {
97+
view : null,
98+
index : null,
99+
};
96100
var mem = [];
97101

98102

@@ -141,6 +145,9 @@
141145

142146

143147
btn['tab-remove'] = function(){
148+
149+
remove();
150+
144151
}//tab-remove
145152

146153

@@ -178,12 +185,35 @@
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');
@@ -193,6 +223,8 @@
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
});

0 commit comments

Comments
 (0)