@nsshunt/stsui 1.3.12 → 1.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/stsuiframe.js +57 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsui",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "",
5
5
  "main": "stsui.js",
6
6
  "scripts": {
package/stsuiframe.js CHANGED
@@ -22,6 +22,9 @@ class STSUIFrame extends EventEmitter {
22
22
  #minHeight = 7;
23
23
 
24
24
  #sortInfo = ''; // Current sort mode UI box control
25
+ #screenHeader = '';
26
+
27
+ __uiBox = this.#uiBox;
25
28
 
26
29
  /**
27
30
  *
@@ -138,8 +141,21 @@ class STSUIFrame extends EventEmitter {
138
141
  *
139
142
  * Setup all panels
140
143
  */
141
- #SetupPanels = () => {
144
+ #SetupPanels() {
142
145
  let panelKeys = Object.keys(this.#uidata.panels);
146
+
147
+ // Check for deleted panels
148
+ let uiBoxIds = Object.keys(this.#uiBox);
149
+ for (let i=0; i < uiBoxIds.length; i++) {
150
+ if (typeof this.#uidata.panels[uiBoxIds[i]] === 'undefined') {
151
+ let uiBox = this.__uiBox[uiBoxIds[i]];
152
+ this.#screen.remove(uiBox.boxHeader);
153
+ this.#screen.remove(uiBox.box);
154
+ uiBox = null;
155
+ delete this.__uiBox[uiBoxIds[i]];
156
+ }
157
+ }
158
+
143
159
  for (let i=0; i < (this.#uidata.grid.cols * this.#uidata.grid.rows); i++)
144
160
  {
145
161
  let gridPos = this.#cursor + i;
@@ -343,7 +359,25 @@ class STSUIFrame extends EventEmitter {
343
359
  tags: true // Allow style in-line tags such as bolt, italics, etc.
344
360
  });
345
361
 
346
- this.UpdateCursorInfo();
362
+
363
+ this.#screenHeader = blessed.box({
364
+ parent: this.#screen,
365
+ top: 0,
366
+ left: 'center',
367
+ width: 'shrink',
368
+ height: 1,
369
+ style:
370
+ {
371
+ bg: 'gray'
372
+ , fg: 'white'
373
+ },
374
+ keys: false, // Do not allow default key handling for this box
375
+ mouse: false,
376
+ content: `[ ... ]`,
377
+ tags: true // Allow style in-line tags such as bolt, italics, etc.
378
+ });
379
+
380
+ this.UpdateCursorInfo();
347
381
  this.UpdateSortInfo('Default');
348
382
 
349
383
  // Render the screen.
@@ -360,6 +394,11 @@ class STSUIFrame extends EventEmitter {
360
394
  this.#sortInfo.setContent(`Sort: ${sortMode}`);
361
395
  }
362
396
 
397
+ UpdateScreenHeader = (screenHeader) =>
398
+ {
399
+ this.#screenHeader.setContent(`[ ${screenHeader} ]`);
400
+ }
401
+
363
402
  IncRows = () =>
364
403
  {
365
404
  if (this.#screen.height / (this.#uidata.grid.rows+1) > this.#minHeight)
@@ -367,7 +406,7 @@ class STSUIFrame extends EventEmitter {
367
406
  {
368
407
  this.#uidata.grid.rows++;
369
408
  this.CheckCursor();
370
- this.SetupUI();
409
+ this.#UpdateUI();
371
410
  }
372
411
  }
373
412
 
@@ -377,7 +416,7 @@ class STSUIFrame extends EventEmitter {
377
416
  {
378
417
  this.#uidata.grid.rows--;
379
418
  this.CheckCursor();
380
- this.SetupUI();
419
+ this.#UpdateUI();
381
420
  }
382
421
  }
383
422
 
@@ -387,7 +426,7 @@ class STSUIFrame extends EventEmitter {
387
426
  {
388
427
  this.#uidata.grid.cols++;
389
428
  this.CheckCursor();
390
- this.SetupUI();
429
+ this.#UpdateUI();
391
430
  }
392
431
  }
393
432
 
@@ -397,7 +436,7 @@ class STSUIFrame extends EventEmitter {
397
436
  {
398
437
  this.#uidata.grid.cols--;
399
438
  this.CheckCursor();
400
- this.SetupUI();
439
+ this.#UpdateUI();
401
440
  }
402
441
  }
403
442
 
@@ -431,7 +470,7 @@ class STSUIFrame extends EventEmitter {
431
470
  if (this.#cursor > endpos) {
432
471
  this.#cursor = endpos;
433
472
  }
434
- this.SetupUI();
473
+ this.#UpdateUI();
435
474
  }
436
475
  }
437
476
 
@@ -442,10 +481,20 @@ class STSUIFrame extends EventEmitter {
442
481
  if (this.#cursor < 0) {
443
482
  this.#cursor = 0;
444
483
  }
445
- this.SetupUI();
484
+ this.#UpdateUI();
446
485
  }
447
486
  }
448
487
 
488
+ #UpdateUI()
489
+ {
490
+ this.SetupUI();
491
+
492
+ //@@ fix screen render - should not need to blow entire screen away ...
493
+ //this.#SetupPanels();
494
+ //this.UpdateCursorInfo();
495
+ //this.#screen.render();
496
+ }
497
+
449
498
  Exit = () => {
450
499
  this.DestroyUI();
451
500
  this.emit('exit');