Skip to content

Commit 3cb442d

Browse files
committed
Added commands for line numbering and removal
1 parent a90c54a commit 3cb442d

6 files changed

Lines changed: 56 additions & 0 deletions

File tree

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,16 @@
377377
"command": "gcode.webviews.codes.show",
378378
"title": "G-Code: Show Code Reference",
379379
"category": "G-Code"
380+
},
381+
{
382+
"command": "gcode.addLineNumbers",
383+
"title": "G-Code: Add Line Numbers",
384+
"category": "G-Code"
385+
},
386+
{
387+
"command": "gcode.removeLineNumbers",
388+
"title": "G-Code: Remove Line Numbers",
389+
"category": "G-Code"
380390
}
381391
]
382392
},

src/util/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ export function registerCommands(context: ExtensionContext): void {
1515
new Commands.ShowSupportGCode(),
1616
new Commands.AddComment(),
1717
new Commands.RemoveComment(),
18+
new Commands.AddLineNumbers(),
19+
new Commands.RemoveLineNumbers(),
1820
);
1921
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* ---------------------------------------------------------------------------------------------
2+
* Copyright (c) Applied Eng & Design All rights reserved.
3+
* Licensed under the MIT License. See License.md in the project root for license information.
4+
* -------------------------------------------------------------------------------------------- */
5+
6+
'use strict';
7+
8+
import { LineNumberer } from '../lineNumberer';
9+
import { GCommand, UtilCommands } from './common';
10+
11+
export class AddLineNumbers extends GCommand {
12+
constructor() {
13+
super(UtilCommands.AddLineNumbers);
14+
}
15+
16+
async execute() {
17+
const ln = new LineNumberer();
18+
await ln.addNumbers(10, 10, true);
19+
}
20+
}

src/util/commands/cmds.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ export * from './addComment';
1010
export * from './removeComment';
1111
export * from './showGCodeSettings';
1212
export * from './showSupportGCode';
13+
export * from './addLineNumbers';
14+
export * from './removeLineNumbers';

src/util/commands/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const enum UtilCommands {
1212
ShowSupportGCode = 'gcode.supportGCode',
1313
AddComment = 'gcode.addComment',
1414
RemoveComment = 'gcode.removeComment',
15+
AddLineNumbers = 'gcode.addLineNumbers',
16+
RemoveLineNumbers = 'gcode.removeLineNumbers',
1517
}
1618

1719
export abstract class GCommand implements Disposable {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* ---------------------------------------------------------------------------------------------
2+
* Copyright (c) Applied Eng & Design All rights reserved.
3+
* Licensed under the MIT License. See License.md in the project root for license information.
4+
* -------------------------------------------------------------------------------------------- */
5+
6+
'use strict';
7+
8+
import { LineNumberer } from '../lineNumberer';
9+
import { GCommand, UtilCommands } from './common';
10+
11+
export class RemoveLineNumbers extends GCommand {
12+
constructor() {
13+
super(UtilCommands.RemoveLineNumbers);
14+
}
15+
16+
async execute() {
17+
const ln = new LineNumberer();
18+
await ln.removeNumbers(true);
19+
}
20+
}

0 commit comments

Comments
 (0)