tigma 1.0.2 → 1.0.4
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.
- package/README.md +6 -3
- package/dist/index.js +178 -89
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
A terminal-based design tool for creating ASCII diagrams and designs.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Running
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
bunx tigma
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
Currently this requires [bun](http://bun.sh).
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
```bash
|
|
@@ -47,6 +49,7 @@ Switch between tools using keyboard shortcuts:
|
|
|
47
49
|
- **Shift+Click** to add/remove objects from selection (multi-select)
|
|
48
50
|
- **Click+Drag** to move selected objects
|
|
49
51
|
- **Click on empty space** to deselect all
|
|
52
|
+
- **Click+Drag on empty space** to box-select multiple items (hold Shift to add)
|
|
50
53
|
|
|
51
54
|
#### Rectangle Resizing
|
|
52
55
|
|
|
@@ -125,7 +128,7 @@ Designs are saved as `.tigma` files in JSON format. The file stores:
|
|
|
125
128
|
## Features
|
|
126
129
|
|
|
127
130
|
- **Layered rendering**: Objects stack based on z-index; newer objects appear on top by default
|
|
128
|
-
- **Multi-selection**: Select multiple objects with Shift+Click
|
|
131
|
+
- **Multi-selection**: Select multiple objects with Shift+Click or box-select
|
|
129
132
|
- **Undo/Redo**: Up to 100 history snapshots
|
|
130
133
|
- **Terminal responsive**: Adapts to terminal resize events
|
|
131
134
|
- **Mouse support**: Full mouse interaction including hover highlighting
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
2
3
|
// node_modules/@opentui/core/index-rysm4rsr.js
|
|
3
4
|
import { Buffer as Buffer2 } from "buffer";
|
|
4
5
|
import { EventEmitter } from "events";
|
|
@@ -1703,56 +1704,56 @@ var Yoga = wrapAssembly(await yoga_wasm_base64_esm_default());
|
|
|
1703
1704
|
var src_default = Yoga;
|
|
1704
1705
|
var BorderChars = {
|
|
1705
1706
|
single: {
|
|
1706
|
-
topLeft: "
|
|
1707
|
-
topRight: "
|
|
1708
|
-
bottomLeft: "
|
|
1709
|
-
bottomRight: "
|
|
1710
|
-
horizontal: "
|
|
1711
|
-
vertical: "
|
|
1712
|
-
topT: "
|
|
1713
|
-
bottomT: "
|
|
1714
|
-
leftT: "
|
|
1715
|
-
rightT: "
|
|
1716
|
-
cross: "
|
|
1707
|
+
topLeft: "\u250C",
|
|
1708
|
+
topRight: "\u2510",
|
|
1709
|
+
bottomLeft: "\u2514",
|
|
1710
|
+
bottomRight: "\u2518",
|
|
1711
|
+
horizontal: "\u2500",
|
|
1712
|
+
vertical: "\u2502",
|
|
1713
|
+
topT: "\u252C",
|
|
1714
|
+
bottomT: "\u2534",
|
|
1715
|
+
leftT: "\u251C",
|
|
1716
|
+
rightT: "\u2524",
|
|
1717
|
+
cross: "\u253C"
|
|
1717
1718
|
},
|
|
1718
1719
|
double: {
|
|
1719
|
-
topLeft: "
|
|
1720
|
-
topRight: "
|
|
1721
|
-
bottomLeft: "
|
|
1722
|
-
bottomRight: "
|
|
1723
|
-
horizontal: "
|
|
1724
|
-
vertical: "
|
|
1725
|
-
topT: "
|
|
1726
|
-
bottomT: "
|
|
1727
|
-
leftT: "
|
|
1728
|
-
rightT: "
|
|
1729
|
-
cross: "
|
|
1720
|
+
topLeft: "\u2554",
|
|
1721
|
+
topRight: "\u2557",
|
|
1722
|
+
bottomLeft: "\u255A",
|
|
1723
|
+
bottomRight: "\u255D",
|
|
1724
|
+
horizontal: "\u2550",
|
|
1725
|
+
vertical: "\u2551",
|
|
1726
|
+
topT: "\u2566",
|
|
1727
|
+
bottomT: "\u2569",
|
|
1728
|
+
leftT: "\u2560",
|
|
1729
|
+
rightT: "\u2563",
|
|
1730
|
+
cross: "\u256C"
|
|
1730
1731
|
},
|
|
1731
1732
|
rounded: {
|
|
1732
|
-
topLeft: "
|
|
1733
|
-
topRight: "
|
|
1734
|
-
bottomLeft: "
|
|
1735
|
-
bottomRight: "
|
|
1736
|
-
horizontal: "
|
|
1737
|
-
vertical: "
|
|
1738
|
-
topT: "
|
|
1739
|
-
bottomT: "
|
|
1740
|
-
leftT: "
|
|
1741
|
-
rightT: "
|
|
1742
|
-
cross: "
|
|
1733
|
+
topLeft: "\u256D",
|
|
1734
|
+
topRight: "\u256E",
|
|
1735
|
+
bottomLeft: "\u2570",
|
|
1736
|
+
bottomRight: "\u256F",
|
|
1737
|
+
horizontal: "\u2500",
|
|
1738
|
+
vertical: "\u2502",
|
|
1739
|
+
topT: "\u252C",
|
|
1740
|
+
bottomT: "\u2534",
|
|
1741
|
+
leftT: "\u251C",
|
|
1742
|
+
rightT: "\u2524",
|
|
1743
|
+
cross: "\u253C"
|
|
1743
1744
|
},
|
|
1744
1745
|
heavy: {
|
|
1745
|
-
topLeft: "
|
|
1746
|
-
topRight: "
|
|
1747
|
-
bottomLeft: "
|
|
1748
|
-
bottomRight: "
|
|
1749
|
-
horizontal: "
|
|
1750
|
-
vertical: "
|
|
1751
|
-
topT: "
|
|
1752
|
-
bottomT: "
|
|
1753
|
-
leftT: "
|
|
1754
|
-
rightT: "
|
|
1755
|
-
cross: "
|
|
1746
|
+
topLeft: "\u250F",
|
|
1747
|
+
topRight: "\u2513",
|
|
1748
|
+
bottomLeft: "\u2517",
|
|
1749
|
+
bottomRight: "\u251B",
|
|
1750
|
+
horizontal: "\u2501",
|
|
1751
|
+
vertical: "\u2503",
|
|
1752
|
+
topT: "\u2533",
|
|
1753
|
+
bottomT: "\u253B",
|
|
1754
|
+
leftT: "\u2523",
|
|
1755
|
+
rightT: "\u252B",
|
|
1756
|
+
cross: "\u254B"
|
|
1756
1757
|
}
|
|
1757
1758
|
};
|
|
1758
1759
|
function getBorderSides(border) {
|
|
@@ -2288,7 +2289,7 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
2288
2289
|
key.meta = s.length === 2;
|
|
2289
2290
|
} else if (s === "\t") {
|
|
2290
2291
|
key.name = "tab";
|
|
2291
|
-
} else if (s === "\b" || s === "\x1B\b" || s === "
|
|
2292
|
+
} else if (s === "\b" || s === "\x1B\b" || s === "\x7F" || s === "\x1B\x7F") {
|
|
2292
2293
|
key.name = "backspace";
|
|
2293
2294
|
key.meta = s.charAt(0) === "\x1B";
|
|
2294
2295
|
} else if (s === "\x1B" || s === "\x1B\x1B") {
|
|
@@ -14875,6 +14876,8 @@ class CanvasApp {
|
|
|
14875
14876
|
currentFilePath = null;
|
|
14876
14877
|
saveStatusMessage = null;
|
|
14877
14878
|
saveStatusTimeout = 0;
|
|
14879
|
+
isSelecting = false;
|
|
14880
|
+
isSelectionPending = false;
|
|
14878
14881
|
showSavePrompt = false;
|
|
14879
14882
|
savePromptInput = "";
|
|
14880
14883
|
gridWidth = 0;
|
|
@@ -15350,6 +15353,11 @@ class CanvasApp {
|
|
|
15350
15353
|
if (event.x !== this.mouseDownX || event.y !== this.mouseDownY) {
|
|
15351
15354
|
this.hasDragged = true;
|
|
15352
15355
|
}
|
|
15356
|
+
if (this.isSelectionPending && this.hasDragged && this.currentTool === "move") {
|
|
15357
|
+
this.isSelectionPending = false;
|
|
15358
|
+
this.isSelecting = true;
|
|
15359
|
+
this.isDraggingMouse = true;
|
|
15360
|
+
}
|
|
15353
15361
|
if (this.isDraggingSelection) {
|
|
15354
15362
|
const dx = event.x - this.dragStartX;
|
|
15355
15363
|
const dy = event.y - this.dragStartY;
|
|
@@ -15361,7 +15369,7 @@ class CanvasApp {
|
|
|
15361
15369
|
if (rectId !== undefined) {
|
|
15362
15370
|
this.resizeRect(rectId, event.x, event.y);
|
|
15363
15371
|
}
|
|
15364
|
-
} else if (this.isDrawingRect || this.isDrawingLine) {
|
|
15372
|
+
} else if (this.isDrawingRect || this.isDrawingLine || this.isSelecting) {
|
|
15365
15373
|
this.drawCursorX = Math.max(0, Math.min(this.gridWidth - 1, event.x));
|
|
15366
15374
|
this.drawCursorY = Math.max(0, Math.min(this.gridHeight - 1, event.y));
|
|
15367
15375
|
this.renderer.requestRender();
|
|
@@ -15379,6 +15387,11 @@ class CanvasApp {
|
|
|
15379
15387
|
this.drawCursorY = Math.max(0, Math.min(this.gridHeight - 1, event.y));
|
|
15380
15388
|
this.commitLine();
|
|
15381
15389
|
}
|
|
15390
|
+
if (this.isSelecting) {
|
|
15391
|
+
this.drawCursorX = Math.max(0, Math.min(this.gridWidth - 1, event.x));
|
|
15392
|
+
this.drawCursorY = Math.max(0, Math.min(this.gridHeight - 1, event.y));
|
|
15393
|
+
this.commitSelection();
|
|
15394
|
+
}
|
|
15382
15395
|
if (this.clickedOnSelectedTextBox && !this.hasDragged && this.selectedTextBoxIds.size === 1) {
|
|
15383
15396
|
const textBoxId = this.selectedTextBoxIds.values().next().value;
|
|
15384
15397
|
const textBox = this.textBoxes.find((b) => b.id === textBoxId);
|
|
@@ -15397,6 +15410,8 @@ class CanvasApp {
|
|
|
15397
15410
|
this.isDraggingMouse = false;
|
|
15398
15411
|
this.clickedOnSelectedTextBox = false;
|
|
15399
15412
|
this.hasDragged = false;
|
|
15413
|
+
this.isSelecting = false;
|
|
15414
|
+
this.isSelectionPending = false;
|
|
15400
15415
|
return;
|
|
15401
15416
|
}
|
|
15402
15417
|
if (event.type === "down") {
|
|
@@ -15501,6 +15516,11 @@ class CanvasApp {
|
|
|
15501
15516
|
if (!shiftHeld) {
|
|
15502
15517
|
this.clearSelection();
|
|
15503
15518
|
}
|
|
15519
|
+
this.isSelectionPending = true;
|
|
15520
|
+
this.drawStartX = event.x;
|
|
15521
|
+
this.drawStartY = event.y;
|
|
15522
|
+
this.drawCursorX = event.x;
|
|
15523
|
+
this.drawCursorY = event.y;
|
|
15504
15524
|
this.renderer.requestRender();
|
|
15505
15525
|
return;
|
|
15506
15526
|
}
|
|
@@ -15876,6 +15896,40 @@ class CanvasApp {
|
|
|
15876
15896
|
this.isDrawingLine = false;
|
|
15877
15897
|
this.setTool("move");
|
|
15878
15898
|
}
|
|
15899
|
+
commitSelection() {
|
|
15900
|
+
if (!this.isSelecting)
|
|
15901
|
+
return;
|
|
15902
|
+
const selX1 = Math.min(this.drawStartX, this.drawCursorX);
|
|
15903
|
+
const selX2 = Math.max(this.drawStartX, this.drawCursorX);
|
|
15904
|
+
const selY1 = Math.min(this.drawStartY, this.drawCursorY);
|
|
15905
|
+
const selY2 = Math.max(this.drawStartY, this.drawCursorY);
|
|
15906
|
+
const isIntersecting = (x1, y1, x2, y2) => {
|
|
15907
|
+
return !(x2 < selX1 || x1 > selX2 || y2 < selY1 || y1 > selY2);
|
|
15908
|
+
};
|
|
15909
|
+
for (const box of this.textBoxes) {
|
|
15910
|
+
const width = Math.max(1, this.getTextLength(box));
|
|
15911
|
+
const bx1 = box.x;
|
|
15912
|
+
const bx2 = box.x + width - 1;
|
|
15913
|
+
const by1 = box.y;
|
|
15914
|
+
const by2 = box.y;
|
|
15915
|
+
if (isIntersecting(bx1, by1, bx2, by2)) {
|
|
15916
|
+
this.selectTextBox(box.id, true);
|
|
15917
|
+
}
|
|
15918
|
+
}
|
|
15919
|
+
for (const rect of this.rectangles) {
|
|
15920
|
+
const { x1, y1, x2, y2 } = this.normalizeRect(rect);
|
|
15921
|
+
if (isIntersecting(x1, y1, x2, y2)) {
|
|
15922
|
+
this.selectRect(rect.id, true);
|
|
15923
|
+
}
|
|
15924
|
+
}
|
|
15925
|
+
for (const line of this.lines) {
|
|
15926
|
+
const { x1, y1, x2, y2 } = this.normalizeLine(line);
|
|
15927
|
+
if (isIntersecting(x1, y1, x2, y2)) {
|
|
15928
|
+
this.selectLine(line.id, true);
|
|
15929
|
+
}
|
|
15930
|
+
}
|
|
15931
|
+
this.isSelecting = false;
|
|
15932
|
+
}
|
|
15879
15933
|
deleteLine(id) {
|
|
15880
15934
|
this.saveSnapshot();
|
|
15881
15935
|
this.lines = this.lines.filter((l) => l.id !== id);
|
|
@@ -16011,6 +16065,8 @@ class CanvasApp {
|
|
|
16011
16065
|
}
|
|
16012
16066
|
this.isDrawingRect = false;
|
|
16013
16067
|
this.isDrawingLine = false;
|
|
16068
|
+
this.isSelecting = false;
|
|
16069
|
+
this.isSelectionPending = false;
|
|
16014
16070
|
this.isDraggingMouse = false;
|
|
16015
16071
|
this.currentTool = tool;
|
|
16016
16072
|
if (tool !== "move") {
|
|
@@ -16056,6 +16112,9 @@ class CanvasApp {
|
|
|
16056
16112
|
if (this.isDrawingLine) {
|
|
16057
16113
|
this.renderLinePreview(buffer);
|
|
16058
16114
|
}
|
|
16115
|
+
if (this.isSelecting) {
|
|
16116
|
+
this.renderSelectionBoxPreview(buffer);
|
|
16117
|
+
}
|
|
16059
16118
|
if (this.activeTextBoxId !== null) {
|
|
16060
16119
|
const activeBox = this.textBoxes.find((b) => b.id === this.activeTextBoxId);
|
|
16061
16120
|
if (activeBox) {
|
|
@@ -16109,31 +16168,31 @@ class CanvasApp {
|
|
|
16109
16168
|
for (let x = startX;x < startX + promptWidth; x++) {
|
|
16110
16169
|
if (x >= 0 && x < this.gridWidth) {
|
|
16111
16170
|
if (startY >= 0 && startY < this.gridHeight) {
|
|
16112
|
-
buffer.setCell(x, startY, "
|
|
16171
|
+
buffer.setCell(x, startY, "\u2500", borderColor, bgColor, 0);
|
|
16113
16172
|
}
|
|
16114
16173
|
if (startY + promptHeight - 1 >= 0 && startY + promptHeight - 1 < this.gridHeight) {
|
|
16115
|
-
buffer.setCell(x, startY + promptHeight - 1, "
|
|
16174
|
+
buffer.setCell(x, startY + promptHeight - 1, "\u2500", borderColor, bgColor, 0);
|
|
16116
16175
|
}
|
|
16117
16176
|
}
|
|
16118
16177
|
}
|
|
16119
16178
|
for (let y = startY;y < startY + promptHeight; y++) {
|
|
16120
16179
|
if (y >= 0 && y < this.gridHeight) {
|
|
16121
16180
|
if (startX >= 0 && startX < this.gridWidth) {
|
|
16122
|
-
buffer.setCell(startX, y, "
|
|
16181
|
+
buffer.setCell(startX, y, "\u2502", borderColor, bgColor, 0);
|
|
16123
16182
|
}
|
|
16124
16183
|
if (startX + promptWidth - 1 >= 0 && startX + promptWidth - 1 < this.gridWidth) {
|
|
16125
|
-
buffer.setCell(startX + promptWidth - 1, y, "
|
|
16184
|
+
buffer.setCell(startX + promptWidth - 1, y, "\u2502", borderColor, bgColor, 0);
|
|
16126
16185
|
}
|
|
16127
16186
|
}
|
|
16128
16187
|
}
|
|
16129
16188
|
if (startX >= 0 && startY >= 0)
|
|
16130
|
-
buffer.setCell(startX, startY, "
|
|
16189
|
+
buffer.setCell(startX, startY, "\u250C", borderColor, bgColor, 0);
|
|
16131
16190
|
if (startX + promptWidth - 1 < this.gridWidth && startY >= 0)
|
|
16132
|
-
buffer.setCell(startX + promptWidth - 1, startY, "
|
|
16191
|
+
buffer.setCell(startX + promptWidth - 1, startY, "\u2510", borderColor, bgColor, 0);
|
|
16133
16192
|
if (startX >= 0 && startY + promptHeight - 1 < this.gridHeight)
|
|
16134
|
-
buffer.setCell(startX, startY + promptHeight - 1, "
|
|
16193
|
+
buffer.setCell(startX, startY + promptHeight - 1, "\u2514", borderColor, bgColor, 0);
|
|
16135
16194
|
if (startX + promptWidth - 1 < this.gridWidth && startY + promptHeight - 1 < this.gridHeight)
|
|
16136
|
-
buffer.setCell(startX + promptWidth - 1, startY + promptHeight - 1, "
|
|
16195
|
+
buffer.setCell(startX + promptWidth - 1, startY + promptHeight - 1, "\u2518", borderColor, bgColor, 0);
|
|
16137
16196
|
const title = " Save As ";
|
|
16138
16197
|
const titleX = startX + Math.floor((promptWidth - title.length) / 2);
|
|
16139
16198
|
for (let i = 0;i < title.length; i++) {
|
|
@@ -16157,7 +16216,7 @@ class CanvasApp {
|
|
|
16157
16216
|
}
|
|
16158
16217
|
const cursorX = inputX + displayText.length;
|
|
16159
16218
|
if (cursorX >= 0 && cursorX < inputX + inputWidth && inputY >= 0 && inputY < this.gridHeight) {
|
|
16160
|
-
buffer.setCell(cursorX, inputY, "
|
|
16219
|
+
buffer.setCell(cursorX, inputY, "\u258F", borderColor, inputBgColor, 0);
|
|
16161
16220
|
}
|
|
16162
16221
|
const hint = "Enter to save, Esc to cancel";
|
|
16163
16222
|
const hintX = startX + Math.floor((promptWidth - hint.length) / 2);
|
|
@@ -16208,16 +16267,16 @@ class CanvasApp {
|
|
|
16208
16267
|
buffer.setCell(x, y, char, borderColor, bg2, 0);
|
|
16209
16268
|
}
|
|
16210
16269
|
};
|
|
16211
|
-
drawBorderCell(x1, y1, "
|
|
16212
|
-
drawBorderCell(x2, y1, "
|
|
16213
|
-
drawBorderCell(x1, y2, "
|
|
16214
|
-
drawBorderCell(x2, y2, "
|
|
16270
|
+
drawBorderCell(x1, y1, "\u250C");
|
|
16271
|
+
drawBorderCell(x2, y1, "\u2510");
|
|
16272
|
+
drawBorderCell(x1, y2, "\u2514");
|
|
16273
|
+
drawBorderCell(x2, y2, "\u2518");
|
|
16215
16274
|
for (let x = x1 + 1;x < x2; x++) {
|
|
16216
|
-
drawBorderCell(x, y1, "
|
|
16217
|
-
drawBorderCell(x, y2, "
|
|
16275
|
+
drawBorderCell(x, y1, "\u2500");
|
|
16276
|
+
drawBorderCell(x, y2, "\u2500");
|
|
16218
16277
|
}
|
|
16219
|
-
drawBorderCell(x1, box.y, "
|
|
16220
|
-
drawBorderCell(x2, box.y, "
|
|
16278
|
+
drawBorderCell(x1, box.y, "\u2502");
|
|
16279
|
+
drawBorderCell(x2, box.y, "\u2502");
|
|
16221
16280
|
}
|
|
16222
16281
|
renderTextCursor(buffer, box) {
|
|
16223
16282
|
if (!this.cursorBlinkVisible)
|
|
@@ -16257,17 +16316,17 @@ class CanvasApp {
|
|
|
16257
16316
|
continue;
|
|
16258
16317
|
let char = "";
|
|
16259
16318
|
if (y === y1 && x === x1)
|
|
16260
|
-
char = "
|
|
16319
|
+
char = "\u250C";
|
|
16261
16320
|
else if (y === y1 && x === x2)
|
|
16262
|
-
char = "
|
|
16321
|
+
char = "\u2510";
|
|
16263
16322
|
else if (y === y2 && x === x1)
|
|
16264
|
-
char = "
|
|
16323
|
+
char = "\u2514";
|
|
16265
16324
|
else if (y === y2 && x === x2)
|
|
16266
|
-
char = "
|
|
16325
|
+
char = "\u2518";
|
|
16267
16326
|
else if (y === y1 || y === y2)
|
|
16268
|
-
char = "
|
|
16327
|
+
char = "\u2500";
|
|
16269
16328
|
else if (x === x1 || x === x2)
|
|
16270
|
-
char = "
|
|
16329
|
+
char = "\u2502";
|
|
16271
16330
|
if (char) {
|
|
16272
16331
|
let bg2 = this.bgColor;
|
|
16273
16332
|
if (isHovered) {
|
|
@@ -16292,17 +16351,17 @@ class CanvasApp {
|
|
|
16292
16351
|
continue;
|
|
16293
16352
|
let char = "";
|
|
16294
16353
|
if (y === y1 && x === x1)
|
|
16295
|
-
char = "
|
|
16354
|
+
char = "\u250C";
|
|
16296
16355
|
else if (y === y1 && x === x2)
|
|
16297
|
-
char = "
|
|
16356
|
+
char = "\u2510";
|
|
16298
16357
|
else if (y === y2 && x === x1)
|
|
16299
|
-
char = "
|
|
16358
|
+
char = "\u2514";
|
|
16300
16359
|
else if (y === y2 && x === x2)
|
|
16301
|
-
char = "
|
|
16360
|
+
char = "\u2518";
|
|
16302
16361
|
else if (y === y1 || y === y2)
|
|
16303
|
-
char = "
|
|
16362
|
+
char = "\u2500";
|
|
16304
16363
|
else if (x === x1 || x === x2)
|
|
16305
|
-
char = "
|
|
16364
|
+
char = "\u2502";
|
|
16306
16365
|
if (char) {
|
|
16307
16366
|
buffer.setCell(x, y, char, fg2, this.bgColor, attrs);
|
|
16308
16367
|
}
|
|
@@ -16338,28 +16397,58 @@ class CanvasApp {
|
|
|
16338
16397
|
buffer.setCell(x, y, char, fg2, bg2, attrs);
|
|
16339
16398
|
}
|
|
16340
16399
|
}
|
|
16400
|
+
renderSelectionBoxPreview(buffer) {
|
|
16401
|
+
const x1 = Math.min(this.drawStartX, this.drawCursorX);
|
|
16402
|
+
const x2 = Math.max(this.drawStartX, this.drawCursorX);
|
|
16403
|
+
const y1 = Math.min(this.drawStartY, this.drawCursorY);
|
|
16404
|
+
const y2 = Math.max(this.drawStartY, this.drawCursorY);
|
|
16405
|
+
const fg2 = this.toolbarActiveColor;
|
|
16406
|
+
for (let y = y1;y <= y2; y++) {
|
|
16407
|
+
for (let x = x1;x <= x2; x++) {
|
|
16408
|
+
if (x < 0 || x >= this.gridWidth || y < 0 || y >= this.gridHeight)
|
|
16409
|
+
continue;
|
|
16410
|
+
let char = "";
|
|
16411
|
+
if (y === y1 && x === x1)
|
|
16412
|
+
char = "+";
|
|
16413
|
+
else if (y === y1 && x === x2)
|
|
16414
|
+
char = "+";
|
|
16415
|
+
else if (y === y2 && x === x1)
|
|
16416
|
+
char = "+";
|
|
16417
|
+
else if (y === y2 && x === x2)
|
|
16418
|
+
char = "+";
|
|
16419
|
+
else if (y === y1 || y === y2)
|
|
16420
|
+
char = "-";
|
|
16421
|
+
else if (x === x1 || x === x2)
|
|
16422
|
+
char = "\u2502";
|
|
16423
|
+
if (char) {
|
|
16424
|
+
const currentBg = this.readBufferBg(buffer, x, y);
|
|
16425
|
+
buffer.setCell(x, y, char, fg2, currentBg, 0);
|
|
16426
|
+
}
|
|
16427
|
+
}
|
|
16428
|
+
}
|
|
16429
|
+
}
|
|
16341
16430
|
getLineChar(x1, y1, x2, y2, index, total) {
|
|
16342
16431
|
const dx = x2 - x1;
|
|
16343
16432
|
const dy = y2 - y1;
|
|
16344
16433
|
if (dx === 0) {
|
|
16345
16434
|
if (index === 0)
|
|
16346
|
-
return dy > 0 ? "
|
|
16435
|
+
return dy > 0 ? "\u2577" : "\u2575";
|
|
16347
16436
|
if (index === total - 1)
|
|
16348
|
-
return dy > 0 ? "
|
|
16349
|
-
return "
|
|
16437
|
+
return dy > 0 ? "\u2575" : "\u2577";
|
|
16438
|
+
return "\u2502";
|
|
16350
16439
|
} else if (dy === 0) {
|
|
16351
16440
|
if (index === 0)
|
|
16352
|
-
return dx > 0 ? "
|
|
16441
|
+
return dx > 0 ? "\u2576" : "\u2574";
|
|
16353
16442
|
if (index === total - 1)
|
|
16354
|
-
return dx > 0 ? "
|
|
16355
|
-
return "
|
|
16443
|
+
return dx > 0 ? "\u2574" : "\u2576";
|
|
16444
|
+
return "\u2500";
|
|
16356
16445
|
} else {
|
|
16357
16446
|
const goingRight = dx > 0;
|
|
16358
16447
|
const goingDown = dy > 0;
|
|
16359
16448
|
if (goingRight === goingDown) {
|
|
16360
|
-
return "
|
|
16449
|
+
return "\u2572";
|
|
16361
16450
|
} else {
|
|
16362
|
-
return "
|
|
16451
|
+
return "\u2571";
|
|
16363
16452
|
}
|
|
16364
16453
|
}
|
|
16365
16454
|
}
|
|
@@ -16543,9 +16632,9 @@ class CanvasApp {
|
|
|
16543
16632
|
if (x < width) {
|
|
16544
16633
|
if (color === null) {
|
|
16545
16634
|
const fg2 = isSelected ? this.toolbarActiveColor : this.toolbarTextColor;
|
|
16546
|
-
buffer.setCell(x, pickerY, "
|
|
16635
|
+
buffer.setCell(x, pickerY, "\u2205", fg2, this.toolbarBgColor, 0);
|
|
16547
16636
|
} else {
|
|
16548
|
-
const char = isSelected ? "
|
|
16637
|
+
const char = isSelected ? "\u2588" : "\u25A0";
|
|
16549
16638
|
buffer.setCell(x, pickerY, char, color, this.toolbarBgColor, 0);
|
|
16550
16639
|
}
|
|
16551
16640
|
x++;
|
|
@@ -16556,9 +16645,9 @@ class CanvasApp {
|
|
|
16556
16645
|
if (x < width) {
|
|
16557
16646
|
if (color === null) {
|
|
16558
16647
|
const fg2 = isSelected ? this.toolbarActiveColor : this.toolbarTextColor;
|
|
16559
|
-
buffer.setCell(x, pickerY, "
|
|
16648
|
+
buffer.setCell(x, pickerY, "\u2205", fg2, this.toolbarBgColor, 0);
|
|
16560
16649
|
} else {
|
|
16561
|
-
const char = isSelected ? "
|
|
16650
|
+
const char = isSelected ? "\u2588" : "\u25A0";
|
|
16562
16651
|
buffer.setCell(x, pickerY, char, color, this.toolbarBgColor, 0);
|
|
16563
16652
|
}
|
|
16564
16653
|
x++;
|
|
@@ -16599,7 +16688,7 @@ class CanvasApp {
|
|
|
16599
16688
|
if (this.activeTextBoxId !== null) {
|
|
16600
16689
|
modeText = "| Editing (Esc to finish)";
|
|
16601
16690
|
} else if (this.currentTool === "move") {
|
|
16602
|
-
modeText = "| Click to select, drag to move";
|
|
16691
|
+
modeText = "| Click to select, drag to move, drag empty space to box-select";
|
|
16603
16692
|
} else if (this.currentTool === "text") {
|
|
16604
16693
|
modeText = "| Click to add/edit text";
|
|
16605
16694
|
} else if (this.isDrawingRect || this.isDrawingLine) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tigma",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A terminal-based design tool",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "bun build ./index.ts --outdir ./dist --target
|
|
15
|
+
"build": "bun build ./index.ts --outdir ./dist --target bun && echo '#!/usr/bin/env bun' | cat - ./dist/index.js > ./dist/temp && mv ./dist/temp ./dist/index.js && chmod +x ./dist/index.js",
|
|
16
16
|
"prepublishOnly": "bun run build"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|