First Commit
This commit is contained in:
Dvurechensky 2025-06-16 09:22:48 +03:00
commit 4e7800f20a
9 changed files with 1781 additions and 0 deletions

25
.gitignore vendored Normal file

@ -0,0 +1,25 @@
# Node.js dependencies
node_modules/
# VS Code extension build outputs
.vscode-test/
out/
dist/
# TypeScript cache
*.tsbuildinfo
# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# OS файлы
.DS_Store
Thumbs.db
# Редактор
.vscode/
# Пакет для установки расширения
*.vsix

BIN
Media/Afetr_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
Media/After_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
Media/Before.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

42
README.md Normal file

@ -0,0 +1,42 @@
<p align="center">✨Dvurechensky✨</p>
# ⭐ Freelancer Lizerium ⭐
## Color Picker INI (VSCode Extension)
- Работает на [VSCode](https://code.visualstudio.com/)
- Простое расширение позволяет в конструкциях формата `color = 255, 255, 255` подсвечивать цвет и добавляет панель выбора цвета слева от каждой подобной строки
* P.s ✌️ Мне пригодилось для файлов `rich_fonts` и во всех файлах игры, где часто такие конструкции использовались
## Сборка 💦
> Установка всех зависимостей в `Terminal` из корня проекта
```sh
npm install
```
> Сборка проекта (должна появится папка `Out` с итоговым `js` файлом плагина)
```sh
npm run vscode:prepublish
```
## Отладка 💦
1. Переходим в скрипт [extension.ts](src/extension.ts)
2. Запускаем отладку Run->Start Debugging -> VS Code Extension Development
3. Откроется чистый VS Code который мужно просто пополнить вашим тестовым файлом с конструкциями `color = 255, 255, 255` и смотреть результат показанных на примерах ниже
### Пример 💦
---
*`До`* \
![Before](Media/Before.png)
---
*`После`* \
![After_1](Media/Afetr_1.png) \
![After_1](Media/After_2.png)
<p align="center">✨Dvurechensky✨</p>

1621
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
package.json Normal file

@ -0,0 +1,29 @@
{
"name": "lizerium-rgb-color-viewer",
"displayName": "RGB Color Viewer",
"description": "Показывает цвет для конструкций типа color = R, G, B",
"version": "0.0.1",
"engines": {
"vscode": "^1.85.0"
},
"activationEvents": [
"*"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "rgbColorPicker.pickColor",
"title": "Pick RGB Color"
}
]
},
"scripts": {
"vscode:prepublish": "tsc -p ./"
},
"devDependencies": {
"@types/vscode": "^1.85.0",
"typescript": "^5.0.0",
"vsce": "^2.15.0"
}
}

47
src/extension.ts Normal file

@ -0,0 +1,47 @@
/*
* Author: Nikolay Dvurechensky
* Last Updated: 16 June 2025
* Version: 1.0.0
*/
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.languages.registerColorProvider(
{ scheme: 'file', language: '*' },
{
provideDocumentColors(document: vscode.TextDocument) {
const colors: vscode.ColorInformation[] = [];
const regex = /color\s*=\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})/g;
for (let i = 0; i < document.lineCount; i++) {
const line = document.lineAt(i);
const match = regex.exec(line.text);
if (match) {
const r = Number(match[1]) / 255;
const g = Number(match[2]) / 255;
const b = Number(match[3]) / 255;
const startPos = line.range.start.translate(0, match.index);
const endPos = startPos.translate(0, match[0].length);
const range = new vscode.Range(startPos, endPos);
const color = new vscode.Color(r, g, b, 1);
colors.push(new vscode.ColorInformation(range, color));
}
}
return colors;
},
provideColorPresentations(color: vscode.Color, context: { document: vscode.TextDocument; range: vscode.Range }) {
// Преобразуем цвет обратно в "color = R, G, B"
const r = Math.round(color.red * 255);
const g = Math.round(color.green * 255);
const b = Math.round(color.blue * 255);
const label = `color = ${r}, ${g}, ${b}`;
return [new vscode.ColorPresentation(label)];
}
}
)
);
}

17
tsconfig.json Normal file

@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": [
"ES2020"
],
"outDir": "out",
"rootDir": "src",
"strict": true,
"esModuleInterop": true
},
"exclude": [
"node_modules",
".vscode-test"
]
}