From 1da80638f9a311367f1bd9d4f848c177ca9d228a Mon Sep 17 00:00:00 2001 From: Drizzy Date: Sat, 2 Dec 2023 17:43:53 -0400 Subject: [PATCH] version 1.2.0 --- CHANGELOG.md | 16 ++++++++++++ README.md | 11 -------- package.json | 55 ++------------------------------------- src/items.js | 46 +++++++++----------------------- src/template/makefile.txt | 4 +-- 5 files changed, 33 insertions(+), 99 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56e0bcd..60458cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +### [v1.2.0](https://github.com/drizzy/vscode-code-make/releases/tag/v1.2.0) + +> 02 December 2023 + +### Features + +- Improved performance by avoiding frequent status bar updates +- Commands and key assignments removed +- Flags for compiling programs with SDL2 added to Makefile + ### [v1.1.0](https://github.com/drizzy/vscode-code-make/releases/tag/v1.1.0) > 22 November 2023 @@ -12,12 +22,16 @@ > 01 February 2023 +### Features + - Add flags in makefile ### [v1.0.1](https://github.com/drizzy/vscode-code-make/releases/tag/v1.0.1) > 08 October 2022 +### Features + - Problems creating projects on windows fixed - Brief documentation to be able to install `make` @@ -30,4 +44,6 @@ > 04 October 2022 +### Features + - Initial release \ No newline at end of file diff --git a/README.md b/README.md index d6b3109..6d63f6b 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,6 @@ Create C++ projects, compile, and run programs directly from the VSCode interfac After installing the extension, click on the `+` symbol in the bottom left corner to create a C++ project structure. Use the gear wheel to compile, the play symbol to run the program, the trash can to delete files from the `bin` and `obj` directories, and 'x' to delete both directories. -## Keybindings - -| Linux | Windows | Mac | Description | -| ------------- | ------------- | ------------- | ------------------- | -| ctrl+alt+f | ctrl+alt+f | ctrl+alt+f | Make Create Folder | -| ctrl+alt+b | ctrl+alt+b | ctrl+alt+b | Make Build Folder | -| ctrl+alt+r | ctrl+alt+r | ctrl+alt+r | Make Run Folder | -| ctrl+alt+c | ctrl+alt+c | ctrl+alt+c | Make Clean Folder | -| ctrl+alt+d | ctrl+alt+d | ctrl+alt+d | Make Delete Folder | - - ## Release Notes Refer to [CHANGELOG](CHANGELOG.md) for detailed release notes. \ No newline at end of file diff --git a/package.json b/package.json index 79b5a0d..0c4ba81 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "code-make", "displayName": "Code Make", - "description": "Creates c++ projects with configured Makefile", - "version": "1.1.0", + "description": "Code Make is designed to make it easy to create and compile C++ projects using the Make tool.", + "version": "1.2.0", "publisher": "drizzy", "license": "MIT", "icon": "icons/logo.png", @@ -44,57 +44,6 @@ "onCommand:code-make-destroy.run" ], "main": "./extension.js", - "contributes": { - "commands": [ - { - "command": "code-make.run", - "title": "Make Run Folder" - }, - { - "command": "code-make-create.run", - "title": "Make Create Folder" - }, - { - "command": "code-make-build.run", - "title": "Make Build Folder" - }, - { - "command": "code-make-clean.run", - "title": "Make Clean Folder" - }, - { - "command": "code-make-destroy.run", - "title": "Make Delete Folder" - } - ], - "keybindings": [ - { - "command": "code-make.run", - "key": "ctrl+alt+r", - "mac": "ctrl+alt+r" - }, - { - "command": "code-make-create.run", - "key": "ctrl+alt+f", - "mac": "ctrl+alt+f" - }, - { - "command": "code-make-build.run", - "key": "ctrl+alt+b", - "mac": "ctrl+alt+b" - }, - { - "command": "code-make-clean.run", - "key": "ctrl+alt+c", - "mac": "ctrl+alt+c" - }, - { - "command": "code-make-destroy.run", - "key": "ctrl+alt+d", - "mac": "ctrl+alt+d" - } - ] - }, "scripts": { "lint": "eslint .", "pretest": "npm run lint", diff --git a/src/items.js b/src/items.js index 1d71d69..7737be4 100644 --- a/src/items.js +++ b/src/items.js @@ -1,35 +1,12 @@ const vscode = require('vscode'); const os = require('os'); const fs = require('fs'); -const events = require('events'); const path = require('path'); const workspace = vscode.workspace; const window = vscode.window; const commands = vscode.commands; -/* Creating a new event emitter. */ -let eventEmitter = events.EventEmitter; - -/* Creating a new event emitter. */ -let event = new eventEmitter(); - -/* Getting the path of the workspace folder. */ -let folderPath; -if (!workspace.workspaceFolders) { - folderPath = workspace.rootPath; -} -else { - - let root; - if (workspace.workspaceFolders.length === 1) { - root = workspace.workspaceFolders[0]; - } - else { - root = workspace.getWorkspaceFolder(resource); - } - - folderPath = root.uri.fsPath; -} +let folderPath = workspace.workspaceFolders ? workspace.workspaceFolders[0].uri.fsPath : workspace.rootPath; /* Creating a new status bar item for each of the commands. */ let items = { @@ -46,6 +23,12 @@ let items = { */ let updateStatusBar = function () { + const srcPath = path.join(folderPath, 'src'); + const includePath = path.join(folderPath, 'include'); + const makefilePath = path.join(folderPath, 'Makefile'); + + const isProjectValid = fs.existsSync(srcPath) && fs.existsSync(includePath) && fs.existsSync(makefilePath); + items.work.text = `$(folder-active) ${workspace.name}`; items.work.command = null; items.work.color = '#FF79C6'; @@ -70,7 +53,7 @@ let updateStatusBar = function () { items.destroy.command = 'code-make-destroy.run'; items.destroy.color = '#ED836E'; - if (fs.existsSync(path.join(folderPath, 'src')) && fs.existsSync(path.join(folderPath, 'include')) && fs.existsSync(path.join(folderPath, 'Makefile'))){ + if (isProjectValid){ items.create.hide(); @@ -103,15 +86,12 @@ let updateStatusBar = function () { } -/* Listening for an event called 'update' and when it is triggered it will run the function -`updateStatusBar`. */ -event.on('update', updateStatusBar); +let watcher = vscode.workspace.createFileSystemWatcher('**/*', false, false, false); +watcher.onDidChange(updateStatusBar); +watcher.onDidCreate(updateStatusBar); +watcher.onDidDelete(updateStatusBar); -/* Updating the status bar every 500 milliseconds. */ -setInterval( () => { - event.emit('update', Date.now()); - },500 -); +updateStatusBar(); module.exports = { os, diff --git a/src/template/makefile.txt b/src/template/makefile.txt index 9beb8e4..e987a3a 100644 --- a/src/template/makefile.txt +++ b/src/template/makefile.txt @@ -5,9 +5,9 @@ APPNAME := Example CXX := g++ # define the FLAGS -CFLAGS := -Wall $(shell pkg-config gtkmm-3.0 --cflags) +CFLAGS := -Wall $(shell pkg-config gtkmm-3.0 sdl2 --cflags) -LFLAGS := $(shell pkg-config gtkmm-3.0 --libs) +LFLAGS := $(shell pkg-config gtkmm-3.0 sdl2 --libs) -lSDL2_image # define bin directory BIN := bin