mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-09 12:37:41 +03:00
Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3277873d0c | |||
| 0db962db76 | |||
| 2d015c6fb7 | |||
| 4697f69dac | |||
| 3e798f1fb8 | |||
| 6fc80daaa1 | |||
| 4293421166 | |||
| 78daab7176 | |||
| 56a499502f | |||
| 2b1c6d59c4 | |||
| d852d58948 | |||
| 41939f4df4 | |||
| a813b7f6c9 | |||
| 9803f4948b | |||
| c17960d1e6 | |||
| 19291f35ee | |||
| 4d61ed3194 | |||
| d722499e80 | |||
| e3cd9cd362 | |||
| e256dcad2e | |||
| 5b0599a958 | |||
| afa7275e37 | |||
| fc5663839e | |||
| 997e7c3eae | |||
| 4229db457c | |||
| d17776b8e4 | |||
| 8112096647 | |||
| 4ada2c44ed | |||
| 82998d688c | |||
| 6ac9c03ec4 | |||
| 2a433483d7 | |||
| ece7c84371 | |||
| 5b641cdd02 | |||
| dff3e916fe | |||
| 2d653834a5 | |||
| 9be0a159ea | |||
| 0288773ccb | |||
| c68ca3dabe | |||
| 292a748ac4 | |||
| 7641846600 | |||
| 613c2c80f5 | |||
| 1a1747a472 | |||
| 57c3c55a94 | |||
| d4ff415f45 | |||
| 4c0502d8ee | |||
| 0acb36445f | |||
| b08ba4d754 | |||
| 231e9f0176 |
2
.github/workflows/Test PKGBUILD-git.yml
vendored
2
.github/workflows/Test PKGBUILD-git.yml
vendored
@@ -2,7 +2,7 @@ name: Test PKGBUILD-git
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branch: master
|
branches: master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: master
|
branches: master
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/publish-release.yml
vendored
2
.github/workflows/publish-release.yml
vendored
@@ -49,6 +49,7 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y cmake build-essential git \
|
sudo apt-get install -y cmake build-essential git \
|
||||||
libglfw3-dev libfreetype6-dev libfontconfig1-dev \
|
libglfw3-dev libfreetype6-dev libfontconfig1-dev \
|
||||||
|
zlib1g-dev libharfbuzz-dev \
|
||||||
libx11-dev libxrandr-dev libxi-dev libgtk-3-dev \
|
libx11-dev libxrandr-dev libxi-dev libgtk-3-dev \
|
||||||
mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev \
|
mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev \
|
||||||
libxinerama-dev libxcursor-dev libxkbcommon-dev
|
libxinerama-dev libxcursor-dev libxkbcommon-dev
|
||||||
@@ -83,6 +84,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
dnf install -y cmake gcc gcc-c++ make rpm-build git \
|
dnf install -y cmake gcc gcc-c++ make rpm-build git \
|
||||||
glfw-devel freetype-devel fontconfig-devel \
|
glfw-devel freetype-devel fontconfig-devel \
|
||||||
|
zlib-devel harfbuzz-devel \
|
||||||
libX11-devel libXrandr-devel libXi-devel \
|
libX11-devel libXrandr-devel libXi-devel \
|
||||||
mesa-libGL-devel mesa-libGLU-devel \
|
mesa-libGL-devel mesa-libGLU-devel \
|
||||||
libXinerama-devel libXcursor-devel \
|
libXinerama-devel libXcursor-devel \
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,7 +3,10 @@
|
|||||||
.vs
|
.vs
|
||||||
out
|
out
|
||||||
|
|
||||||
|
.clangd
|
||||||
|
|
||||||
build/
|
build/
|
||||||
|
build-msvc/
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
|
|||||||
35
.vscode/launch.json
vendored
35
.vscode/launch.json
vendored
@@ -1,19 +1,12 @@
|
|||||||
{
|
{
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Debug current target",
|
"name": "Debug current target (GDB)",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${command:cmake.launchTargetPath}",
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
"args": [
|
"args": [],
|
||||||
"--apply",
|
|
||||||
"--theme",
|
|
||||||
"dark"
|
|
||||||
],
|
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
@@ -32,5 +25,29 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug current target (LLDB)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "lldb",
|
||||||
|
"miDebuggerPath": "lldb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug current target (MSVC)",
|
||||||
|
"type": "cppvsdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
3
.vscode/settnigs.json
vendored
Normal file
3
.vscode/settnigs.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"cmake.useCMakePresets": "always"
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Maintainer: Daniel Dada <dan@binarygoose.dev>
|
# Maintainer: Daniel Dada <dan@binarygoose.dev>
|
||||||
pkgname=clrsync
|
pkgname=clrsync
|
||||||
pkgver=0.1.5
|
pkgver=1.1.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Color scheme manager"
|
pkgdesc="Color scheme manager"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Maintainer: Daniel Dada <dan@binarygoose.dev>
|
# Maintainer: Daniel Dada <dan@binarygoose.dev>
|
||||||
pkgname=clrsync-git
|
pkgname=clrsync-git
|
||||||
pkgver=r22.d8baae2
|
pkgver=r107.4229db4
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Color scheme manager (git version)"
|
pkgdesc="Color scheme manager (git version)"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
@@ -10,6 +10,8 @@ depends=(
|
|||||||
glfw
|
glfw
|
||||||
freetype2
|
freetype2
|
||||||
fontconfig
|
fontconfig
|
||||||
|
zlib
|
||||||
|
harfbuzz
|
||||||
mesa
|
mesa
|
||||||
libglvnd
|
libglvnd
|
||||||
libxcursor
|
libxcursor
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(clrsync VERSION 0.1.5 LANGUAGES CXX)
|
project(clrsync VERSION 1.1.0 LANGUAGES CXX)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
|||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
file(WRITE "${CMAKE_SOURCE_DIR}/.clangd"
|
||||||
|
"CompileFlags:\n CompilationDatabase: ${CMAKE_BINARY_DIR}\n")
|
||||||
|
|
||||||
option(USE_SYSTEM_GLFW "Use system-installed GLFW instead of fetching it statically" OFF)
|
option(USE_SYSTEM_GLFW "Use system-installed GLFW instead of fetching it statically" OFF)
|
||||||
message(STATUS "USE_SYSTEM_GLFW: ${USE_SYSTEM_GLFW}")
|
message(STATUS "USE_SYSTEM_GLFW: ${USE_SYSTEM_GLFW}")
|
||||||
|
|
||||||
@@ -57,8 +60,8 @@ endif()
|
|||||||
message(STATUS "clrsync version: ${SEMVER}")
|
message(STATUS "clrsync version: ${SEMVER}")
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_SOURCE_DIR}/src/core/version.hpp.in
|
${CMAKE_SOURCE_DIR}/src/core/common/version.hpp.in
|
||||||
${CMAKE_SOURCE_DIR}/src/core/version.hpp
|
${CMAKE_SOURCE_DIR}/src/core/common/version.hpp
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
325
CMakePresets.json
Normal file
325
CMakePresets.json
Normal file
@@ -0,0 +1,325 @@
|
|||||||
|
{
|
||||||
|
"version": 6,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "base",
|
||||||
|
"hidden": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "debug",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": "base",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": "base",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": "base",
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Linux"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": "base",
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Windows"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": "base",
|
||||||
|
"condition": {
|
||||||
|
"type": "equals",
|
||||||
|
"lhs": "${hostSystemName}",
|
||||||
|
"rhs": "Darwin"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gcc",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "gcc",
|
||||||
|
"CMAKE_CXX_COMPILER": "g++"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "clang",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "clang",
|
||||||
|
"CMAKE_CXX_COMPILER": "clang++"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ninja",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Ninja"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "make",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Unix Makefiles"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "msvc-ninja",
|
||||||
|
"displayName": "MSVC (Ninja)",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"hidden": true,
|
||||||
|
"binaryDir": "${sourceDir}/build/windows/msvc",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "cl",
|
||||||
|
"CMAKE_CXX_COMPILER": "cl"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "msvc-vs2026",
|
||||||
|
"displayName": "MSVC (Visual Studio 18 2026)",
|
||||||
|
"generator": "Visual Studio 18 2026",
|
||||||
|
"binaryDir": "${sourceDir}/build/windows/msvc/vs2026",
|
||||||
|
"architecture": {
|
||||||
|
"value": "x64"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-msvc-ninja-debug",
|
||||||
|
"inherits": [
|
||||||
|
"windows",
|
||||||
|
"msvc-ninja",
|
||||||
|
"ninja",
|
||||||
|
"debug"
|
||||||
|
],
|
||||||
|
"displayName": "Windows · MSVC · Ninja · Debug",
|
||||||
|
"binaryDir": "${sourceDir}/build/windows/msvc/ninja/debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-msvc-ninja-release",
|
||||||
|
"inherits": [
|
||||||
|
"windows",
|
||||||
|
"msvc-ninja",
|
||||||
|
"ninja",
|
||||||
|
"release"
|
||||||
|
],
|
||||||
|
"displayName": "Windows · MSVC · Ninja · Release",
|
||||||
|
"binaryDir": "${sourceDir}/build/windows/msvc/ninja/release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-ninja-debug",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"gcc",
|
||||||
|
"ninja",
|
||||||
|
"debug"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · GCC · Ninja · Debug",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/gcc/ninja/debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-ninja-release",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"gcc",
|
||||||
|
"ninja",
|
||||||
|
"release"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · GCC · Ninja · Release",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/gcc/ninja/release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-make-debug",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"gcc",
|
||||||
|
"make",
|
||||||
|
"debug"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · GCC · Make · Debug",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/gcc/make/debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-make-release",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"gcc",
|
||||||
|
"make",
|
||||||
|
"release"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · GCC · Make · Release",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/gcc/make/release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-ninja-debug",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"clang",
|
||||||
|
"ninja",
|
||||||
|
"debug"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · Clang · Ninja · Debug",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/clang/ninja/debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-ninja-release",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"clang",
|
||||||
|
"ninja",
|
||||||
|
"release"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · Clang · Ninja · Release",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/clang/ninja/release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-make-debug",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"clang",
|
||||||
|
"make",
|
||||||
|
"debug"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · Clang · Make · Debug",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/clang/make/debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-make-release",
|
||||||
|
"inherits": [
|
||||||
|
"linux",
|
||||||
|
"clang",
|
||||||
|
"make",
|
||||||
|
"release"
|
||||||
|
],
|
||||||
|
"displayName": "Linux · Clang · Make · Release",
|
||||||
|
"binaryDir": "${sourceDir}/build/linux/clang/make/release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-ninja-debug",
|
||||||
|
"inherits": [
|
||||||
|
"macos",
|
||||||
|
"clang",
|
||||||
|
"ninja",
|
||||||
|
"debug"
|
||||||
|
],
|
||||||
|
"displayName": "macOS · Apple Clang · Ninja · Debug",
|
||||||
|
"binaryDir": "${sourceDir}/build/macos/appleclang/ninja/debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-ninja-release",
|
||||||
|
"inherits": [
|
||||||
|
"macos",
|
||||||
|
"clang",
|
||||||
|
"ninja",
|
||||||
|
"release"
|
||||||
|
],
|
||||||
|
"displayName": "macOS · Apple Clang · Ninja · Release",
|
||||||
|
"binaryDir": "${sourceDir}/build/macos/appleclang/ninja/release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-make-debug",
|
||||||
|
"inherits": [
|
||||||
|
"macos",
|
||||||
|
"clang",
|
||||||
|
"make",
|
||||||
|
"debug"
|
||||||
|
],
|
||||||
|
"displayName": "macOS · Apple Clang · Make · Debug",
|
||||||
|
"binaryDir": "${sourceDir}/build/macos/appleclang/make/debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-make-release",
|
||||||
|
"inherits": [
|
||||||
|
"macos",
|
||||||
|
"clang",
|
||||||
|
"make",
|
||||||
|
"release"
|
||||||
|
],
|
||||||
|
"displayName": "macOS · Apple Clang · Make · Release",
|
||||||
|
"binaryDir": "${sourceDir}/build/macos/appleclang/make/release"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildPresets": [
|
||||||
|
{
|
||||||
|
"name": "vs-debug",
|
||||||
|
"configurePreset": "msvc-vs2026",
|
||||||
|
"configuration": "Debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vs-release",
|
||||||
|
"configurePreset": "msvc-vs2026",
|
||||||
|
"configuration": "Release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "msvc-ninja-debug",
|
||||||
|
"configurePreset": "windows-msvc-ninja-debug",
|
||||||
|
"configuration": "Debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "msvc-ninja-release",
|
||||||
|
"configurePreset": "windows-msvc-ninja-release",
|
||||||
|
"configuration": "Release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-ninja-debug",
|
||||||
|
"configurePreset": "linux-gcc-ninja-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-ninja-release",
|
||||||
|
"configurePreset": "linux-gcc-ninja-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-make-debug",
|
||||||
|
"configurePreset": "linux-gcc-make-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-make-release",
|
||||||
|
"configurePreset": "linux-gcc-make-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-ninja-debug",
|
||||||
|
"configurePreset": "linux-clang-ninja-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-ninja-release",
|
||||||
|
"configurePreset": "linux-clang-ninja-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-make-debug",
|
||||||
|
"configurePreset": "linux-clang-make-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-make-release",
|
||||||
|
"configurePreset": "linux-clang-make-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-ninja-debug",
|
||||||
|
"configurePreset": "macos-appleclang-ninja-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-ninja-release",
|
||||||
|
"configurePreset": "macos-appleclang-ninja-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-make-debug",
|
||||||
|
"configurePreset": "macos-appleclang-make-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-appleclang-make-release",
|
||||||
|
"configurePreset": "macos-appleclang-make-release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
16
README.md
16
README.md
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
# clrsync
|
# clrsync
|
||||||
|
|
||||||
**Notice:** This application is not yet released and is subject to change.
|
|
||||||
|
|
||||||
A theme management tool for synchronizing color schemes across multiple applications. clrsync allows to define color palettes once and apply them consistently to all configurable applications.
|
A theme management tool for synchronizing color schemes across multiple applications. clrsync allows to define color palettes once and apply them consistently to all configurable applications.
|
||||||
|
|
||||||

|

|
||||||
@@ -34,6 +32,7 @@ A theme management tool for synchronizing color schemes across multiple applicat
|
|||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [CLI](#cli)
|
- [CLI](#cli)
|
||||||
- [GUI](#gui)
|
- [GUI](#gui)
|
||||||
|
- [Extras](#extras)
|
||||||
- [Acknowledgments](#acknowledgments)
|
- [Acknowledgments](#acknowledgments)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@@ -47,6 +46,14 @@ A theme management tool for synchronizing color schemes across multiple applicat
|
|||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
|
#### Arch Linux
|
||||||
|
|
||||||
|
Install the package from AUR using any helper or install manually
|
||||||
|
|
||||||
|
```shell
|
||||||
|
yay -S clrsync-git
|
||||||
|
```
|
||||||
|
|
||||||
#### Ubuntu
|
#### Ubuntu
|
||||||
|
|
||||||
1. Download the latest .deb from the [releases page](https://github.com/obsqrbtz/clrsync/releases)
|
1. Download the latest .deb from the [releases page](https://github.com/obsqrbtz/clrsync/releases)
|
||||||
@@ -457,6 +464,10 @@ The GUI provides:
|
|||||||
- **Template Editor**: Edit template files
|
- **Template Editor**: Edit template files
|
||||||
- **Live Preview**: See changes in real-time
|
- **Live Preview**: See changes in real-time
|
||||||
|
|
||||||
|
## Extras
|
||||||
|
|
||||||
|
You may find some pre-configured color schemes and templates in [extra](extra) directory of this repository.
|
||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
- **[matugen](https://github.com/InioX/matugen)** - A material you color generation tool
|
- **[matugen](https://github.com/InioX/matugen)** - A material you color generation tool
|
||||||
@@ -465,4 +476,3 @@ The GUI provides:
|
|||||||
- **[toml++](https://github.com/marzer/tomlplusplus)** - Header-only TOML config file parser and serializer for C++17
|
- **[toml++](https://github.com/marzer/tomlplusplus)** - Header-only TOML config file parser and serializer for C++17
|
||||||
- **[argparse](https://github.com/p-ranav/argparse)** - Argument Parser for Modern C++
|
- **[argparse](https://github.com/p-ranav/argparse)** - Argument Parser for Modern C++
|
||||||
- **[ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit)** - Syntax highlighting text editor for ImGui
|
- **[ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit)** - Syntax highlighting text editor for ImGui
|
||||||
- **cursed** by **[pyratebeard](https://pyratebeard.net)** - Color scheme
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 370 KiB After Width: | Height: | Size: 856 KiB |
@@ -7,7 +7,19 @@ if(WIN32)
|
|||||||
freetype
|
freetype
|
||||||
URL https://download.savannah.gnu.org/releases/freetype/freetype-2.14.1.tar.gz
|
URL https://download.savannah.gnu.org/releases/freetype/freetype-2.14.1.tar.gz
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(freetype)
|
FetchContent_MakeAvailable(freetype)
|
||||||
|
elseif(APPLE)
|
||||||
|
option(USE_SYSTEM_GLFW ON)
|
||||||
|
find_package(Freetype REQUIRED)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(BZip2 REQUIRED)
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
|
pkg_check_modules(HARFBUZZ harfbuzz)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
find_package(Freetype REQUIRED)
|
find_package(Freetype REQUIRED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
@@ -15,22 +27,31 @@ else()
|
|||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(BZip2 REQUIRED)
|
find_package(BZip2 REQUIRED)
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
|
|
||||||
find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
|
find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
|
||||||
find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
|
find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
|
||||||
|
|
||||||
pkg_check_modules(HARFBUZZ harfbuzz)
|
pkg_check_modules(HARFBUZZ harfbuzz)
|
||||||
pkg_check_modules(WAYLAND_CLIENT wayland-client)
|
pkg_check_modules(WAYLAND_CLIENT wayland-client)
|
||||||
pkg_check_modules(WAYLAND_EGL wayland-egl)
|
pkg_check_modules(WAYLAND_EGL wayland-egl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LINUX)
|
if(LINUX)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_SYSTEM_GLFW)
|
if(USE_SYSTEM_GLFW)
|
||||||
|
if(APPLE)
|
||||||
|
find_package(glfw3 QUIET)
|
||||||
|
if(glfw3_FOUND)
|
||||||
|
set(GLFW_FOUND TRUE)
|
||||||
|
set(GLFW_LIBRARIES glfw)
|
||||||
|
else()
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(GLFW REQUIRED glfw3)
|
pkg_check_modules(GLFW REQUIRED glfw3)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
pkg_check_modules(GLFW REQUIRED glfw3)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
@@ -55,19 +76,19 @@ if(BROTLIDEC_LIBRARY AND BROTLICOMMON_LIBRARY)
|
|||||||
list(APPEND FREETYPE_EXTRA_LIBS ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY})
|
list(APPEND FREETYPE_EXTRA_LIBS ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY})
|
||||||
message(STATUS "Found Brotli libraries")
|
message(STATUS "Found Brotli libraries")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HARFBUZZ_FOUND)
|
if(HARFBUZZ_FOUND)
|
||||||
list(APPEND FREETYPE_EXTRA_LIBS ${HARFBUZZ_LIBRARIES})
|
list(APPEND FREETYPE_EXTRA_LIBS ${HARFBUZZ_LIBRARIES})
|
||||||
message(STATUS "Found HarfBuzz")
|
message(STATUS "Found HarfBuzz")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(WAYLAND_LIBS "")
|
set(WAYLAND_LIBS "")
|
||||||
if(WAYLAND_CLIENT_FOUND)
|
if(NOT APPLE)
|
||||||
|
if(WAYLAND_CLIENT_FOUND)
|
||||||
list(APPEND WAYLAND_LIBS ${WAYLAND_CLIENT_LIBRARIES})
|
list(APPEND WAYLAND_LIBS ${WAYLAND_CLIENT_LIBRARIES})
|
||||||
message(STATUS "Found Wayland client")
|
message(STATUS "Found Wayland client")
|
||||||
endif()
|
endif()
|
||||||
if(WAYLAND_EGL_FOUND)
|
if(WAYLAND_EGL_FOUND)
|
||||||
list(APPEND WAYLAND_LIBS ${WAYLAND_EGL_LIBRARIES})
|
list(APPEND WAYLAND_LIBS ${WAYLAND_EGL_LIBRARIES})
|
||||||
message(STATUS "Found Wayland EGL")
|
message(STATUS "Found Wayland EGL")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ set(CPACK_NSIS_CREATE_DESKTOP_LINKS "bin/clrsync_gui.exe;clrsync")
|
|||||||
|
|
||||||
# Debian
|
# Debian
|
||||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Daniel Dada <dan@binarygoose.dev>")
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Daniel Dada <dan@binarygoose.dev>")
|
||||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libglfw3, libfreetype6")
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libglfw3, libfreetype6, zlib1g, libharfbuzz0b")
|
||||||
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
|
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
|
||||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
|
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
|
||||||
@@ -36,6 +36,6 @@ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
|
|||||||
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
|
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
|
||||||
set(CPACK_RPM_PACKAGE_GROUP "Applications/System")
|
set(CPACK_RPM_PACKAGE_GROUP "Applications/System")
|
||||||
set(CPACK_RPM_PACKAGE_URL "https://github.com/obsqrbtz/clrsync")
|
set(CPACK_RPM_PACKAGE_URL "https://github.com/obsqrbtz/clrsync")
|
||||||
set(CPACK_RPM_PACKAGE_REQUIRES "freetype, glfw, fontconfig")
|
set(CPACK_RPM_PACKAGE_REQUIRES "freetype, glfw, fontconfig, zlib, harfbuzz")
|
||||||
|
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[general]
|
[general]
|
||||||
default_theme = 'cursed'
|
default_theme = 'dark'
|
||||||
palettes_path = '~/.config/clrsync/palettes'
|
palettes_path = '~/.config/clrsync/palettes'
|
||||||
font = 'JetBrainsMono Nerd Font Mono'
|
font = 'JetBrainsMono Nerd Font Mono'
|
||||||
font_size = 14
|
font_size = 14
|
||||||
@@ -12,7 +12,7 @@ output_path = '~/.config/clrsync/formats-demo'
|
|||||||
[templates.kitty]
|
[templates.kitty]
|
||||||
enabled = true
|
enabled = true
|
||||||
input_path = '~/.config/clrsync/templates/kitty.conf'
|
input_path = '~/.config/clrsync/templates/kitty.conf'
|
||||||
output_path = '~/.config/kitty/kitty_test.conf'
|
output_path = '~/.config/kitty/clrsync.conf'
|
||||||
reload_cmd = 'pkill -SIGUSR1 kitty'
|
reload_cmd = 'pkill -SIGUSR1 kitty'
|
||||||
|
|
||||||
[templates.nvim]
|
[templates.nvim]
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
[colors]
|
|
||||||
# General
|
|
||||||
background = "#f5f5f5FF"
|
|
||||||
on_background = "#3d3d2fFF"
|
|
||||||
|
|
||||||
surface = "#e8e8e8FF"
|
|
||||||
on_surface = "#3d3d2fFF"
|
|
||||||
|
|
||||||
surface_variant = "#d0d0c8FF"
|
|
||||||
on_surface_variant = "#3d3d2fFF"
|
|
||||||
|
|
||||||
border_focused = "#c9a305FF"
|
|
||||||
border = "#d0d0c8FF"
|
|
||||||
|
|
||||||
foreground = "#3d3d2fFF"
|
|
||||||
|
|
||||||
cursor = "#c9a305FF"
|
|
||||||
accent = "#b44242FF"
|
|
||||||
|
|
||||||
# Terminal
|
|
||||||
base00 = "#f5f5f5FF"
|
|
||||||
base01 = "#b44242FF"
|
|
||||||
base02 = "#95a328FF"
|
|
||||||
base03 = "#c9a305FF"
|
|
||||||
base04 = "#60928fFF"
|
|
||||||
base05 = "#7c435aFF"
|
|
||||||
base06 = "#a48b4aFF"
|
|
||||||
base07 = "#3d3d2fFF"
|
|
||||||
base08 = "#c0c0b8FF"
|
|
||||||
base09 = "#dc7671FF"
|
|
||||||
base0A = "#d4d430FF"
|
|
||||||
base0B = "#9e9052FF"
|
|
||||||
base0C = "#76c39bFF"
|
|
||||||
base0D = "#86596cFF"
|
|
||||||
base0E = "#b89a1fFF"
|
|
||||||
base0F = "#4f4f48FF"
|
|
||||||
|
|
||||||
# Semantic
|
|
||||||
success = "#95a328FF"
|
|
||||||
info = "#60928fFF"
|
|
||||||
warning = "#c9a305FF"
|
|
||||||
error = "#b44242FF"
|
|
||||||
|
|
||||||
on_success = "#f5f5f5FF"
|
|
||||||
on_info = "#f5f5f5FF"
|
|
||||||
on_warning = "#f5f5f5FF"
|
|
||||||
on_error = "#f5f5f5FF"
|
|
||||||
|
|
||||||
# Code editor
|
|
||||||
editor_background = "#f5f5f5FF"
|
|
||||||
editor_command = "#b89a1fFF"
|
|
||||||
editor_comment = "#a0a098FF"
|
|
||||||
editor_disabled = "#c0c0b8FF"
|
|
||||||
editor_emphasis = "#dc7671FF"
|
|
||||||
editor_error = "#b44242FF"
|
|
||||||
editor_inactive = "#a0a098FF"
|
|
||||||
editor_line_number = "#86596cFF"
|
|
||||||
editor_link = "#60928fFF"
|
|
||||||
editor_main = "#3d3d2fFF"
|
|
||||||
editor_selected = "#d0d0c8FF"
|
|
||||||
editor_selection_inactive = "#e0e0d8FF"
|
|
||||||
editor_string = "#5fa37bFF"
|
|
||||||
editor_success = "#95a328FF"
|
|
||||||
editor_warning = "#c9a305FF"
|
|
||||||
|
|
||||||
[general]
|
|
||||||
name = 'cursed-light'
|
|
||||||
55
example_config/palettes/dark.toml
Normal file
55
example_config/palettes/dark.toml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
[colors]
|
||||||
|
accent = '#9A8652FF'
|
||||||
|
accent_secondary = '#9A8652FF'
|
||||||
|
background = '#111111FF'
|
||||||
|
base00 = '#111111FF'
|
||||||
|
base01 = '#668A51FF'
|
||||||
|
base02 = '#9A8652FF'
|
||||||
|
base03 = '#B47837FF'
|
||||||
|
base04 = '#9A5552FF'
|
||||||
|
base05 = '#AA477BFF'
|
||||||
|
base06 = '#3A898CFF'
|
||||||
|
base07 = '#B5B5B5FF'
|
||||||
|
base08 = '#AA4E4AFF'
|
||||||
|
base09 = '#A9DC86FF'
|
||||||
|
base0A = '#B6AB82FF'
|
||||||
|
base0B = '#C5916BFF'
|
||||||
|
base0C = '#AC7676FF'
|
||||||
|
base0D = '#B0779EFF'
|
||||||
|
base0E = '#849899FF'
|
||||||
|
base0F = '#D2D2D2FF'
|
||||||
|
border = '#242424FF'
|
||||||
|
border_focused = '#2E2E2EFF'
|
||||||
|
cursor = '#D2D2D2FF'
|
||||||
|
editor_background = '#111111FF'
|
||||||
|
editor_command = '#3A898CFF'
|
||||||
|
editor_comment = '#849899FF'
|
||||||
|
editor_disabled = '#849899FF'
|
||||||
|
editor_emphasis = '#A9DC86FF'
|
||||||
|
editor_error = '#AA4E4AFF'
|
||||||
|
editor_inactive = '#849899FF'
|
||||||
|
editor_line_number = '#849899FF'
|
||||||
|
editor_link = '#B0779EFF'
|
||||||
|
editor_main = '#D2D2D2FF'
|
||||||
|
editor_selected = '#242424FF'
|
||||||
|
editor_selection_inactive = '#1D1C1CFF'
|
||||||
|
editor_string = '#9A8652FF'
|
||||||
|
editor_success = '#668A51FF'
|
||||||
|
editor_warning = '#B47837FF'
|
||||||
|
error = '#AA4E4AFF'
|
||||||
|
foreground = '#D2D2D2FF'
|
||||||
|
info = '#3A898CFF'
|
||||||
|
on_background = '#D4D4D4FF'
|
||||||
|
on_error = '#D2D2D2FF'
|
||||||
|
on_info = '#D2D2D2FF'
|
||||||
|
on_success = '#D2D2D2FF'
|
||||||
|
on_surface = '#D4D4D4FF'
|
||||||
|
on_surface_variant = '#D4D4D4FF'
|
||||||
|
on_warning = '#D2D2D2FF'
|
||||||
|
success = '#668A51FF'
|
||||||
|
surface = '#111111FF'
|
||||||
|
surface_variant = '#191919FF'
|
||||||
|
warning = '#B47837FF'
|
||||||
|
|
||||||
|
[general]
|
||||||
|
name = 'dark'
|
||||||
55
example_config/palettes/light.toml
Normal file
55
example_config/palettes/light.toml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
[colors]
|
||||||
|
accent = '#9A8652FF'
|
||||||
|
accent_secondary = '#9A8652FF'
|
||||||
|
background = '#E0E0E0FF'
|
||||||
|
base00 = '#E0E0E0FF'
|
||||||
|
base01 = '#668A51FF'
|
||||||
|
base02 = '#9A8652FF'
|
||||||
|
base03 = '#B47837FF'
|
||||||
|
base04 = '#9A5552FF'
|
||||||
|
base05 = '#AA477BFF'
|
||||||
|
base06 = '#3A898CFF'
|
||||||
|
base07 = '#5A5A5AFF'
|
||||||
|
base08 = '#AA4E4AFF'
|
||||||
|
base09 = '#4A7A2EFF'
|
||||||
|
base0A = '#7A6A42FF'
|
||||||
|
base0B = '#A5714BFF'
|
||||||
|
base0C = '#8C5656FF'
|
||||||
|
base0D = '#90577EFF'
|
||||||
|
base0E = '#2A6A6DFF'
|
||||||
|
base0F = '#2A2A2AFF'
|
||||||
|
border = '#C5C5C5FF'
|
||||||
|
border_focused = '#B9B9B9FF'
|
||||||
|
cursor = '#2A2A2AFF'
|
||||||
|
editor_background = '#E0E0E0FF'
|
||||||
|
editor_command = '#3A898CFF'
|
||||||
|
editor_comment = '#849899FF'
|
||||||
|
editor_disabled = '#A0A0A0FF'
|
||||||
|
editor_emphasis = '#4A7A2EFF'
|
||||||
|
editor_error = '#AA4E4AFF'
|
||||||
|
editor_inactive = '#A0A0A0FF'
|
||||||
|
editor_line_number = '#9A9A95FF'
|
||||||
|
editor_link = '#90577EFF'
|
||||||
|
editor_main = '#2A2A2AFF'
|
||||||
|
editor_selected = '#C9C9C9FF'
|
||||||
|
editor_selection_inactive = '#D2D2D2FF'
|
||||||
|
editor_string = '#9A8652FF'
|
||||||
|
editor_success = '#668A51FF'
|
||||||
|
editor_warning = '#B47837FF'
|
||||||
|
error = '#AA4E4AFF'
|
||||||
|
foreground = '#2A2A2AFF'
|
||||||
|
info = '#3A898CFF'
|
||||||
|
on_background = '#2A2A2AFF'
|
||||||
|
on_error = '#FAFAF8FF'
|
||||||
|
on_info = '#FAFAF8FF'
|
||||||
|
on_success = '#FAFAF8FF'
|
||||||
|
on_surface = '#2A2A2AFF'
|
||||||
|
on_surface_variant = '#3A3A3AFF'
|
||||||
|
on_warning = '#FAFAF8FF'
|
||||||
|
success = '#668A51FF'
|
||||||
|
surface = '#E0E0E0FF'
|
||||||
|
surface_variant = '#CECECEFF'
|
||||||
|
warning = '#B47837FF'
|
||||||
|
|
||||||
|
[general]
|
||||||
|
name = 'light'
|
||||||
@@ -5,7 +5,7 @@ foreground {foreground}
|
|||||||
background {background}
|
background {background}
|
||||||
selection_foreground {on_surface}
|
selection_foreground {on_surface}
|
||||||
selection_background {surface}
|
selection_background {surface}
|
||||||
url_color {accent}
|
url_color {accent_secondary}
|
||||||
|
|
||||||
color0 {base00}
|
color0 {base00}
|
||||||
color8 {base08}
|
color8 {base08}
|
||||||
|
|||||||
52
extra/README.md
Normal file
52
extra/README.md
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Extras
|
||||||
|
|
||||||
|
Pre-configured palettes and templates for clrsync.
|
||||||
|
|
||||||
|
## Palettes
|
||||||
|
|
||||||
|
| Palette | Preview |
|
||||||
|
|---------|---------|
|
||||||
|
| [Nord](palettes/dark/nord) |  |
|
||||||
|
| [Cursed](palettes/dark/cursed) |  |
|
||||||
|
| [Cursed Light](palettes/light/cursed-light) |  |
|
||||||
|
|
||||||
|
## Templates
|
||||||
|
|
||||||
|
### Terminals
|
||||||
|
- [Alacritty](templates/terminals/alacritty)
|
||||||
|
- [Ghostty](templates/terminals/ghostty)
|
||||||
|
- [Kitty](templates/terminals/kitty)
|
||||||
|
|
||||||
|
### Text Editors
|
||||||
|
- [Neovim](templates/text-editors/neovim)
|
||||||
|
- [VS Code](templates/text-editors/vscode)
|
||||||
|
|
||||||
|
### Browsers
|
||||||
|
- [Firefox](templates/browsers/firefox)
|
||||||
|
|
||||||
|
### Desktop
|
||||||
|
- [GTK](templates/desktop/gtk)
|
||||||
|
- [Qt](templates/desktop/qt)
|
||||||
|
|
||||||
|
### Window Managers
|
||||||
|
- [Hyprland](templates/wms/hyprland)
|
||||||
|
|
||||||
|
### Apps
|
||||||
|
- [Telegram](templates/apps/telegram)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
To add a new palette:
|
||||||
|
|
||||||
|
1. Create a folder in `palettes/<dark/light>` with your palette name
|
||||||
|
2. Add your `.toml` palette file
|
||||||
|
3. Add a `readme.md` with description
|
||||||
|
4. Add a screenshot (`.png`)
|
||||||
|
5. Submit a PR
|
||||||
|
|
||||||
|
To add a new template:
|
||||||
|
|
||||||
|
1. Create a folder in `templates/<category>` with the app name
|
||||||
|
2. Add your template file(s)
|
||||||
|
3. Add a `readme.md` with installation instructions
|
||||||
|
4. Submit a PR
|
||||||
BIN
extra/palettes/dark/cursed/cursed.png
Normal file
BIN
extra/palettes/dark/cursed/cursed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 235 KiB |
@@ -1,5 +1,6 @@
|
|||||||
[colors]
|
[colors]
|
||||||
accent = '#B44242FF'
|
accent = '#95A328FF'
|
||||||
|
accent_secondary = '#95A328FF'
|
||||||
background = '#151515FF'
|
background = '#151515FF'
|
||||||
base00 = '#151515FF'
|
base00 = '#151515FF'
|
||||||
base01 = '#B44242FF'
|
base01 = '#B44242FF'
|
||||||
@@ -22,7 +23,7 @@ border_focused = '#E1C135FF'
|
|||||||
cursor = '#E1C135FF'
|
cursor = '#E1C135FF'
|
||||||
editor_background = '#151515FF'
|
editor_background = '#151515FF'
|
||||||
editor_command = '#CEB34FFF'
|
editor_command = '#CEB34FFF'
|
||||||
editor_comment = '#3F3639FF'
|
editor_comment = '#7A7A7AFF'
|
||||||
editor_disabled = '#3F3639FF'
|
editor_disabled = '#3F3639FF'
|
||||||
editor_emphasis = '#DC7671FF'
|
editor_emphasis = '#DC7671FF'
|
||||||
editor_error = '#B44242FF'
|
editor_error = '#B44242FF'
|
||||||
@@ -43,7 +44,7 @@ on_error = '#151515FF'
|
|||||||
on_info = '#151515FF'
|
on_info = '#151515FF'
|
||||||
on_success = '#151515FF'
|
on_success = '#151515FF'
|
||||||
on_surface = '#C2C2B0FF'
|
on_surface = '#C2C2B0FF'
|
||||||
on_surface_variant = '#C2C2B0FF'
|
on_surface_variant = '#CCCCCCFF'
|
||||||
on_warning = '#151515FF'
|
on_warning = '#151515FF'
|
||||||
success = '#95A328FF'
|
success = '#95A328FF'
|
||||||
surface = '#1C1C1CFF'
|
surface = '#1C1C1CFF'
|
||||||
7
extra/palettes/dark/cursed/readme.md
Normal file
7
extra/palettes/dark/cursed/readme.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Cursed
|
||||||
|
|
||||||
|
A dark color scheme inspired by the `cursed` theme by [pyratebeard](https://pyratebeard.net).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[Download](cursed.toml)
|
||||||
BIN
extra/palettes/dark/nord/nord.png
Normal file
BIN
extra/palettes/dark/nord/nord.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 243 KiB |
55
extra/palettes/dark/nord/nord.toml
Normal file
55
extra/palettes/dark/nord/nord.toml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
[colors]
|
||||||
|
accent = '#A1CDFAFF'
|
||||||
|
accent_secondary = '#A1CDFAFF'
|
||||||
|
background = '#2E3440FF'
|
||||||
|
base00 = '#2E3440FF'
|
||||||
|
base01 = '#BF616AFF'
|
||||||
|
base02 = '#A3BE8CFF'
|
||||||
|
base03 = '#EBCB8BFF'
|
||||||
|
base04 = '#81A1C1FF'
|
||||||
|
base05 = '#B48EADFF'
|
||||||
|
base06 = '#88C0D0FF'
|
||||||
|
base07 = '#E5E9F0FF'
|
||||||
|
base08 = '#4C566AFF'
|
||||||
|
base09 = '#D08770FF'
|
||||||
|
base0A = '#EBCB8BFF'
|
||||||
|
base0B = '#A3BE8CFF'
|
||||||
|
base0C = '#8FBCBBFF'
|
||||||
|
base0D = '#5E81ACFF'
|
||||||
|
base0E = '#B48EADFF'
|
||||||
|
base0F = '#ECEFF4FF'
|
||||||
|
border = '#4C566AFF'
|
||||||
|
border_focused = '#88C0D0FF'
|
||||||
|
cursor = '#D8DEE9FF'
|
||||||
|
editor_background = '#2E3440FF'
|
||||||
|
editor_command = '#81A1C1FF'
|
||||||
|
editor_comment = '#616E88FF'
|
||||||
|
editor_disabled = '#4C566AFF'
|
||||||
|
editor_emphasis = '#B48EADFF'
|
||||||
|
editor_error = '#BF616AFF'
|
||||||
|
editor_inactive = '#616E88FF'
|
||||||
|
editor_line_number = '#4C566AFF'
|
||||||
|
editor_link = '#88C0D0FF'
|
||||||
|
editor_main = '#D8DEE9FF'
|
||||||
|
editor_selected = '#434C5EFF'
|
||||||
|
editor_selection_inactive = '#3B4252FF'
|
||||||
|
editor_string = '#A3BE8CFF'
|
||||||
|
editor_success = '#A3BE8CFF'
|
||||||
|
editor_warning = '#EBCB8BFF'
|
||||||
|
error = '#BF616AFF'
|
||||||
|
foreground = '#D8DEE9FF'
|
||||||
|
info = '#5E81ACFF'
|
||||||
|
on_background = '#D8DEE9FF'
|
||||||
|
on_error = '#2E3440FF'
|
||||||
|
on_info = '#2E3440FF'
|
||||||
|
on_success = '#2E3440FF'
|
||||||
|
on_surface = '#ECEFF4FF'
|
||||||
|
on_surface_variant = '#ECEFF4FF'
|
||||||
|
on_warning = '#2E3440FF'
|
||||||
|
success = '#A3BE8CFF'
|
||||||
|
surface = '#3B4252FF'
|
||||||
|
surface_variant = '#434C5EFF'
|
||||||
|
warning = '#EBCB8BFF'
|
||||||
|
|
||||||
|
[general]
|
||||||
|
name = 'nord'
|
||||||
7
extra/palettes/dark/nord/readme.md
Normal file
7
extra/palettes/dark/nord/readme.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Nord
|
||||||
|
|
||||||
|
A color scheme based on the [Nord](https://www.nordtheme.com/) palette.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[Download](nord.toml)
|
||||||
BIN
extra/palettes/light/cursed-light/cursed-light.png
Normal file
BIN
extra/palettes/light/cursed-light/cursed-light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 243 KiB |
55
extra/palettes/light/cursed-light/cursed-light.toml
Normal file
55
extra/palettes/light/cursed-light/cursed-light.toml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
[colors]
|
||||||
|
accent = '#95A328FF'
|
||||||
|
accent_secondary = '#95A328FF'
|
||||||
|
background = '#F5F5F5FF'
|
||||||
|
base00 = '#F5F5F5FF'
|
||||||
|
base01 = '#B44242FF'
|
||||||
|
base02 = '#95A328FF'
|
||||||
|
base03 = '#C9A305FF'
|
||||||
|
base04 = '#60928FFF'
|
||||||
|
base05 = '#7C435AFF'
|
||||||
|
base06 = '#A48B4AFF'
|
||||||
|
base07 = '#3D3D2FFF'
|
||||||
|
base08 = '#C0C0B8FF'
|
||||||
|
base09 = '#DC7671FF'
|
||||||
|
base0A = '#D4D430FF'
|
||||||
|
base0B = '#9E9052FF'
|
||||||
|
base0C = '#76C39BFF'
|
||||||
|
base0D = '#86596CFF'
|
||||||
|
base0E = '#B89A1FFF'
|
||||||
|
base0F = '#4F4F48FF'
|
||||||
|
border = '#D0D0C8FF'
|
||||||
|
border_focused = '#C9A305FF'
|
||||||
|
cursor = '#C9A305FF'
|
||||||
|
editor_background = '#F5F5F5FF'
|
||||||
|
editor_command = '#B89A1FFF'
|
||||||
|
editor_comment = '#A0A098FF'
|
||||||
|
editor_disabled = '#C0C0B8FF'
|
||||||
|
editor_emphasis = '#DC7671FF'
|
||||||
|
editor_error = '#B44242FF'
|
||||||
|
editor_inactive = '#A0A098FF'
|
||||||
|
editor_line_number = '#86596CFF'
|
||||||
|
editor_link = '#60928FFF'
|
||||||
|
editor_main = '#3D3D2FFF'
|
||||||
|
editor_selected = '#D0D0C8FF'
|
||||||
|
editor_selection_inactive = '#E0E0D8FF'
|
||||||
|
editor_string = '#5FA37BFF'
|
||||||
|
editor_success = '#95A328FF'
|
||||||
|
editor_warning = '#C9A305FF'
|
||||||
|
error = '#B44242FF'
|
||||||
|
foreground = '#3D3D2FFF'
|
||||||
|
info = '#60928FFF'
|
||||||
|
on_background = '#3D3D2FFF'
|
||||||
|
on_error = '#F5F5F5FF'
|
||||||
|
on_info = '#F5F5F5FF'
|
||||||
|
on_success = '#F5F5F5FF'
|
||||||
|
on_surface = '#3D3D2FFF'
|
||||||
|
on_surface_variant = '#CCCCCCFF'
|
||||||
|
on_warning = '#F5F5F5FF'
|
||||||
|
success = '#95A328FF'
|
||||||
|
surface = '#E8E8E8FF'
|
||||||
|
surface_variant = '#D0D0C8FF'
|
||||||
|
warning = '#C9A305FF'
|
||||||
|
|
||||||
|
[general]
|
||||||
|
name = 'cursed-light'
|
||||||
7
extra/palettes/light/cursed-light/readme.md
Normal file
7
extra/palettes/light/cursed-light/readme.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Cursed Light
|
||||||
|
|
||||||
|
A light variant of the `cursed` color scheme.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[Download](cursed-light.toml)
|
||||||
17
extra/templates/apps/telegram/readme.md
Normal file
17
extra/templates/apps/telegram/readme.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Telegram
|
||||||
|
|
||||||
|
1. Download the [template file](telegram.tdesktop-theme)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.telegram]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/telegram.tdesktop-theme'
|
||||||
|
output_path = '~/clrsync.tdesktop-theme'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Apply the palette with clrsync and send the generated `clrsync.tdesktop-theme` file to yourself in Telegram
|
||||||
|
|
||||||
|
4. Click on the theme file in the Telegram dialog to apply it
|
||||||
213
extra/templates/apps/telegram/telegram.tdesktop-theme
Normal file
213
extra/templates/apps/telegram/telegram.tdesktop-theme
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
// Template mostly stolen from noctalia-shell
|
||||||
|
// https://github.com/noctalia-dev/noctalia-shell/blob/main/Assets/MatugenTemplates/telegram.tdesktop-theme
|
||||||
|
|
||||||
|
COLOR_GRAY: {border};
|
||||||
|
COLOR_DARK: {surface_variant};
|
||||||
|
|
||||||
|
windowBg: {background}; // Main background
|
||||||
|
windowFg: {on_background}; // Main text
|
||||||
|
windowBgOver: {surface_variant}; // Generic background on hover
|
||||||
|
windowBgRipple: {surface_variant}; // Ripple effect
|
||||||
|
windowFgOver: {on_surface_variant}; // Text on hover
|
||||||
|
windowSubTextFg: {foreground}60; // Minor text
|
||||||
|
windowSubTextFgOver: {foreground}80; // Minor text on hover
|
||||||
|
|
||||||
|
dialogsBg: {background}; // Sidebar background
|
||||||
|
dialogsBgActive: {surface}; // Active chat background
|
||||||
|
dialogsBgOver: {surface_variant}; // Hover background
|
||||||
|
dialogsRippleBg: {surface_variant}; // Ripple effect
|
||||||
|
dialogsRippleBgActive: {surface_variant}; // Ripple effect for active chat
|
||||||
|
|
||||||
|
dialogsNameFg: {foreground}; // Chat name
|
||||||
|
dialogsNameFgActive: {foreground}; // Chat name for active chat
|
||||||
|
dialogsNameFgOver: {foreground}; // Chat name on hover
|
||||||
|
|
||||||
|
dialogsTextFg: {foreground}; // Message preview
|
||||||
|
dialogsTextFgActive: {foreground}; // Message preview for active chat
|
||||||
|
dialogsTextFgOver: {foreground}; // Message preview on hover
|
||||||
|
|
||||||
|
dialogsTextFgService: {foreground}; // Service text (group sender name)
|
||||||
|
dialogsTextFgServiceActive: {foreground}; // Service text for active chat
|
||||||
|
dialogsTextFgServiceOver: {foreground}; // Service text on hover
|
||||||
|
|
||||||
|
dialogsDateFg: {foreground}60; // Date text
|
||||||
|
dialogsDateFgActive: {foreground}60; // Date text for active chat
|
||||||
|
dialogsDateFgOver: {foreground}60; // Date text on hover
|
||||||
|
|
||||||
|
dialogsDraftFg: {foreground}; // Draft label
|
||||||
|
dialogsDraftFgActive: {foreground}; // Draft label for active chat
|
||||||
|
dialogsDraftFgOver: {foreground}; // Draft label on hover
|
||||||
|
|
||||||
|
dialogsVerifiedIconBg: {accent}; // Verified badge background
|
||||||
|
dialogsVerifiedIconBgActive: {accent_secondary}; // Verified badge for active chat
|
||||||
|
dialogsVerifiedIconBgOver: {accent}; // Verified badge on hover
|
||||||
|
dialogsVerifiedIconFg: {background}; // Verified icon
|
||||||
|
dialogsVerifiedIconFgActive: {background}; // Verified icon for active chat
|
||||||
|
dialogsVerifiedIconFgOver: {background}; // Verified icon on hover
|
||||||
|
|
||||||
|
dialogsSendingIconFg: {foreground}; // Sending icon (clock)
|
||||||
|
dialogsSendingIconFgActive: {foreground}; // Sending icon for active chat
|
||||||
|
dialogsSendingIconFgOver: {foreground}; // Sending icon on hover
|
||||||
|
|
||||||
|
dialogsSentIconFg: {accent}; // Sent icon (tick)
|
||||||
|
dialogsSentIconFgActive: {accent_secondary}; // Sent icon for active chat
|
||||||
|
dialogsSentIconFgOver: {accent}; // Sent icon on hover
|
||||||
|
|
||||||
|
dialogsUnreadBg: {accent}; // Unread badge background
|
||||||
|
dialogsUnreadBgActive: {accent_secondary}; // Unread badge for active chat
|
||||||
|
dialogsUnreadBgOver: {accent}; // Unread badge on hover
|
||||||
|
dialogsUnreadBgMuted: {foreground}; // Muted unread badge
|
||||||
|
dialogsUnreadBgMutedActive: {foreground}; // Muted unread badge for active chat
|
||||||
|
dialogsUnreadBgMutedOver: {foreground}; // Muted unread badge on hover
|
||||||
|
dialogsUnreadFg: {background}; // Unread badge text
|
||||||
|
dialogsUnreadFgActive: {background}; // Unread badge text for active chat
|
||||||
|
dialogsUnreadFgOver: {background}; // Unread badge text on hover
|
||||||
|
|
||||||
|
dialogsChatIconFg: {foreground}; // Group/channel icon
|
||||||
|
dialogsChatIconFgActive: {foreground}; // Group/channel icon for active chat
|
||||||
|
dialogsChatIconFgOver: {foreground}; // Group/channel icon on hover
|
||||||
|
|
||||||
|
dialogsOnlineBadgeFg: {foreground}; // Online status
|
||||||
|
dialogsOnlineBadgeFgActive: {foreground}; // Online status for active chat
|
||||||
|
|
||||||
|
dialogsForwardBg: {surface}; // Forwarding panel background
|
||||||
|
dialogsForwardFg: {foreground}; // Forwarding panel text
|
||||||
|
|
||||||
|
dialogsMenuIconFg: {foreground}; // Main menu icon
|
||||||
|
dialogsMenuIconFgOver: {foreground}60; // Main menu icon on hover
|
||||||
|
windowBoldFg: {on_background}; // Bold text
|
||||||
|
windowBoldFgOver: {on_surface_variant}; // Bold text on hover
|
||||||
|
windowBgActive: {surface}; // Active items background
|
||||||
|
windowFgActive: {foreground}; // Active items text
|
||||||
|
windowActiveTextFg: {accent_secondary}; // Active items text
|
||||||
|
windowShadowFg: {border}; // Window shadow
|
||||||
|
windowShadowFgFallback: {border}; // Fallback for shadow
|
||||||
|
historyOutIconFg: {accent};
|
||||||
|
historyIconFgInverted: {on_surface};
|
||||||
|
|
||||||
|
msgServiceBg: {surface}80;
|
||||||
|
msgServiceFg: {foreground};
|
||||||
|
msgOutBg: {surface};
|
||||||
|
msgOutBgSelected: {surface_variant};
|
||||||
|
msgOutServiceFg: {on_surface};
|
||||||
|
msgOutDateFg: {foreground}80;
|
||||||
|
historySentIconFg: {foreground};
|
||||||
|
msgOutDateFgSelected: {foreground};
|
||||||
|
msgInBg: {surface_variant};
|
||||||
|
msgInBgSelected: {surface};
|
||||||
|
msgDateImgFg: {on_surface};
|
||||||
|
|
||||||
|
|
||||||
|
shadowFg: {border}; // General shadow
|
||||||
|
slideFadeOutBg: {background};
|
||||||
|
slideFadeOutShadowFg: {border};
|
||||||
|
|
||||||
|
imageBg: {surface};
|
||||||
|
imageBgTransparent: {surface};
|
||||||
|
|
||||||
|
activeButtonBg: {accent_secondary}; // Active button background
|
||||||
|
activeButtonBgOver: {surface_variant}; // Active button hover background
|
||||||
|
activeButtonBgRipple: {on_surface_variant}; // Active button ripple
|
||||||
|
activeButtonFg: {on_background}; // Active button text
|
||||||
|
activeButtonFgOver: {on_surface_variant}; // Active button hover text
|
||||||
|
activeButtonSecondaryFg: {on_background}; // Active button secondary text
|
||||||
|
activeButtonSecondaryFgOver: {on_surface_variant}; // Active button secondary hover text
|
||||||
|
activeLineFg: {accent};
|
||||||
|
dialogsBgActive: {surface};
|
||||||
|
|
||||||
|
lightButtonBg: {surface}; // Light button background
|
||||||
|
lightButtonBgOver: {surface_variant}; // Light button hover background
|
||||||
|
lightButtonBgRipple: {accent}; // Light button ripple
|
||||||
|
lightButtonFg: {on_surface}; // Light button text
|
||||||
|
lightButtonFgOver: {on_surface_variant}; // Light button hover text
|
||||||
|
|
||||||
|
attentionButtonFg: {error};
|
||||||
|
attentionButtonFgOver: {error};
|
||||||
|
attentionButtonBgOver: {surface_variant};
|
||||||
|
attentionButtonBgRipple: {on_surface};
|
||||||
|
|
||||||
|
outlineButtonBg: {surface}; // Outline button background
|
||||||
|
outlineButtonBgOver: {surface_variant}; // Outline button hover background
|
||||||
|
outlineButtonOutlineFg: {accent_secondary}; // Outline button color
|
||||||
|
outlineButtonBgRipple: {accent_secondary}; // Outline button ripple
|
||||||
|
|
||||||
|
menuBg: {surface};
|
||||||
|
menuBgOver: {surface_variant};
|
||||||
|
menuBgRipple: {accent_secondary};
|
||||||
|
menuIconFg: {on_surface};
|
||||||
|
menuIconFgOver: {on_surface_variant};
|
||||||
|
menuSubmenuArrowFg: {border};
|
||||||
|
menuFgDisabled: {border};
|
||||||
|
menuSeparatorFg: {border};
|
||||||
|
|
||||||
|
scrollBarBg: {accent}40; // Scroll bar background (40% opacity)
|
||||||
|
scrollBarBgOver: {accent_secondary}60; // Scroll bar hover background (60% opacity)
|
||||||
|
scrollBg: {surface_variant}40; // Scroll bar track (40% opacity)
|
||||||
|
scrollBgOver: {surface_variant}60; // Scroll bar track on hover (60% opacity)
|
||||||
|
|
||||||
|
smallCloseIconFg: {border};
|
||||||
|
smallCloseIconFgOver: {on_surface_variant};
|
||||||
|
|
||||||
|
radialFg: {accent_secondary};
|
||||||
|
radialBg: {surface};
|
||||||
|
|
||||||
|
placeholderFg: {border}; // Placeholder text
|
||||||
|
placeholderFgActive: {accent_secondary}; // Active placeholder text
|
||||||
|
inputBorderFg: {border}; // Input border
|
||||||
|
filterInputBorderFg: {border}; // Search input border
|
||||||
|
filterInputInactiveBg: {surface}; // Inactive search input background
|
||||||
|
checkboxFg: {accent_secondary}; // Checkbox color
|
||||||
|
|
||||||
|
// Filters sidebar (left side bar with folder filters)
|
||||||
|
sideBarBg: {surface}; // Filters sidebar background
|
||||||
|
sideBarBgActive: {surface_variant}; // Filters sidebar active filter background
|
||||||
|
sideBarBgRipple: {background}; // Filters sidebar ripple effect
|
||||||
|
sideBarTextFg: {foreground}; // Filters sidebar text
|
||||||
|
sideBarTextFgActive: {foreground}; // Filters sidebar active filter text
|
||||||
|
sideBarIconFg: {foreground}; // Filters sidebar icon
|
||||||
|
sideBarIconFgActive: {foreground}; // Filters sidebar active filter icon
|
||||||
|
sideBarBadgeBg: {accent}; // Filters sidebar badge background
|
||||||
|
sideBarBadgeBgMuted: {foreground}60; // Filters sidebar muted badge background
|
||||||
|
|
||||||
|
titleBg: {surface}; // Window title background
|
||||||
|
titleShadow: {border};
|
||||||
|
titleButtonFg: {on_surface}; // Title button color
|
||||||
|
titleButtonBgOver: {surface_variant}; // Title button hover background
|
||||||
|
titleButtonFgOver: {on_surface_variant}; // Title button hover color
|
||||||
|
titleButtonCloseBgOver: {error};
|
||||||
|
titleButtonCloseFgOver: {on_error};
|
||||||
|
titleFgActive: {on_surface}; // Active title text
|
||||||
|
titleFg: {on_surface}; // Inactive title text
|
||||||
|
|
||||||
|
trayCounterBg: {error}; // Tray counter background
|
||||||
|
trayCounterBgMute: {border}; // Muted tray counter background
|
||||||
|
trayCounterFg: {on_error}; // Tray counter text
|
||||||
|
trayCounterBgMacInvert: {error}; // Mac tray counter
|
||||||
|
trayCounterFgMacInvert: {on_error}; // Mac tray counter text
|
||||||
|
|
||||||
|
layerBg: {surface}99; // Layer background (60% opacity)
|
||||||
|
|
||||||
|
cancelIconFg: {error}; // Cancel icon
|
||||||
|
cancelIconFgOver: {error}; // Cancel icon on hover
|
||||||
|
|
||||||
|
boxBg: {surface}; // Box background
|
||||||
|
boxTextFg: {on_surface}; // Box text
|
||||||
|
boxTextFgGood: {accent_secondary}; // Box good text
|
||||||
|
boxTextFgError: {error}; // Box error text
|
||||||
|
boxTitleFg: {on_surface}; // Box title text
|
||||||
|
boxSearchBg: {surface}; // Box search field background
|
||||||
|
boxSearchCancelIconFg: {error}; // Box search cancel icon
|
||||||
|
boxSearchCancelIconFgOver: {error}; // Box search cancel icon on hover
|
||||||
|
|
||||||
|
contactsBg: {surface}; // Contacts background
|
||||||
|
contactsBgOver: {surface_variant}; // Contacts background on hover
|
||||||
|
contactsNameFg: {on_surface}; // Contact name
|
||||||
|
contactsStatusFg: {border}; // Contact status
|
||||||
|
contactsStatusFgOver: {on_surface_variant}; // Contact status on hover
|
||||||
|
contactsStatusFgOnline: {accent_secondary}; // Online contact status
|
||||||
|
|
||||||
|
photoCropFadeBg: {surface}cc; // Photo crop fade background
|
||||||
|
photoCropPointFg: {accent_secondary}; // Photo crop points
|
||||||
|
|
||||||
|
chat_inBubbleSelected: {surface_variant}; // inbox selected chat background
|
||||||
|
chat_outBubbleSelected: {surface_variant}; // outbox selected chat background
|
||||||
17
extra/templates/browsers/firefox/readme.md
Normal file
17
extra/templates/browsers/firefox/readme.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Firefox
|
||||||
|
|
||||||
|
1. Download the [template file](userChrome.css)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.firefox]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/userChrome.css'
|
||||||
|
output_path = '~/.mozilla/firefox/<profile>/chrome/userChrome.css'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Enable `toolkit.legacyUserProfileCustomizations.stylesheets` in `about:config`
|
||||||
|
|
||||||
|
4. Restart Firefox to apply the theme
|
||||||
109
extra/templates/browsers/firefox/userChrome.css
Normal file
109
extra/templates/browsers/firefox/userChrome.css
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/* clrsync Firefox Theme */
|
||||||
|
/* Place in: <Firefox Profile>/chrome/userChrome.css */
|
||||||
|
/* Enable: about:config -> toolkit.legacyUserProfileCustomizations.stylesheets = true */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--lwt-accent-color: {background} !important;
|
||||||
|
--lwt-text-color: {foreground} !important;
|
||||||
|
|
||||||
|
--toolbar-bgcolor: {surface} !important;
|
||||||
|
--toolbar-color: {on_surface} !important;
|
||||||
|
--toolbarbutton-hover-background: {surface_variant} !important;
|
||||||
|
--toolbarbutton-active-background: {border_focused} !important;
|
||||||
|
--toolbarbutton-icon-fill: {on_surface} !important;
|
||||||
|
|
||||||
|
--tab-selected-bgcolor: {surface} !important;
|
||||||
|
--tab-selected-textcolor: {foreground} !important;
|
||||||
|
--tab-loading-fill: {accent} !important;
|
||||||
|
--lwt-tab-text: {foreground} !important;
|
||||||
|
--tab-line-color: {accent} !important;
|
||||||
|
|
||||||
|
--urlbar-box-bgcolor: {surface_variant} !important;
|
||||||
|
--urlbar-box-text-color: {on_surface} !important;
|
||||||
|
--urlbar-box-hover-bgcolor: {surface} !important;
|
||||||
|
--urlbar-box-focus-bgcolor: {surface} !important;
|
||||||
|
--urlbar-popup-url-color: {editor_link} !important;
|
||||||
|
|
||||||
|
--arrowpanel-background: {surface} !important;
|
||||||
|
--arrowpanel-color: {on_surface} !important;
|
||||||
|
--arrowpanel-border-color: {border} !important;
|
||||||
|
--panel-separator-color: {border} !important;
|
||||||
|
|
||||||
|
--sidebar-background-color: {background} !important;
|
||||||
|
--sidebar-text-color: {foreground} !important;
|
||||||
|
--sidebar-border-color: {border} !important;
|
||||||
|
|
||||||
|
--toolbar-field-focus-background-color: {surface} !important;
|
||||||
|
--toolbar-field-focus-color: {on_surface} !important;
|
||||||
|
--toolbar-field-focus-border-color: {accent} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#TabsToolbar {
|
||||||
|
background-color: {background} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-background[selected="true"] {
|
||||||
|
background-color: {surface} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabbrowser-tab:hover > .tab-stack > .tab-background:not([selected="true"]) {
|
||||||
|
background-color: {surface_variant} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-line {
|
||||||
|
background-color: {accent} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav-bar {
|
||||||
|
background-color: {surface} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#urlbar-background {
|
||||||
|
background-color: {surface_variant} !important;
|
||||||
|
border-color: {border} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#urlbar[focused="true"] > #urlbar-background {
|
||||||
|
background-color: {surface} !important;
|
||||||
|
border-color: {accent} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#urlbar-input {
|
||||||
|
color: {on_surface} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#PersonalToolbar {
|
||||||
|
background-color: {surface} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
menupopup, panel {
|
||||||
|
--panel-background: {surface} !important;
|
||||||
|
--panel-color: {on_surface} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
menupopup {
|
||||||
|
background-color: {surface} !important;
|
||||||
|
color: {on_surface} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
menuitem:hover, menu:hover {
|
||||||
|
background-color: {surface_variant} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-box {
|
||||||
|
background-color: {background} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar-header {
|
||||||
|
background-color: {surface} !important;
|
||||||
|
border-bottom-color: {border} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
findbar {
|
||||||
|
background-color: {surface} !important;
|
||||||
|
color: {on_surface} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
scrollbar-color: {surface_variant} {background} !important;
|
||||||
|
}
|
||||||
18
extra/templates/desktop/gtk/gtk.css
Normal file
18
extra/templates/desktop/gtk/gtk.css
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
@define-color accent_color {accent};
|
||||||
|
@define-color accent_bg_color {accent};
|
||||||
|
@define-color accent_fg_color {on_surface};
|
||||||
|
@define-color window_bg_color {background};
|
||||||
|
@define-color window_fg_color {foreground};
|
||||||
|
@define-color headerbar_bg_color {surface};
|
||||||
|
@define-color headerbar_fg_color {on_surface};
|
||||||
|
@define-color popover_bg_color {surface_variant};
|
||||||
|
@define-color popover_fg_color {on_surface_variant};
|
||||||
|
@define-color view_bg_color {background};
|
||||||
|
@define-color view_fg_color {foreground};
|
||||||
|
@define-color card_bg_color {surface};
|
||||||
|
@define-color card_fg_color {on_surface};
|
||||||
|
|
||||||
|
@define-color sidebar_bg_color {surface_variant};
|
||||||
|
@define-color sidebar_fg_color {on_surface};
|
||||||
|
@define-color sidebar_border_color @window_bg_color;
|
||||||
|
@define-color sidebar_backdrop_color @window_bg_color;
|
||||||
15
extra/templates/desktop/gtk/readme.md
Normal file
15
extra/templates/desktop/gtk/readme.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# GTK
|
||||||
|
|
||||||
|
1. Download the [template file](gtk.css)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.gtk]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/gtk.css'
|
||||||
|
output_path = '~/.config/gtk-3.0/gtk.css'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Restart GTK applications to apply the theme
|
||||||
571
extra/templates/desktop/qt/kvantum.kvconfig
Normal file
571
extra/templates/desktop/qt/kvantum.kvconfig
Normal file
@@ -0,0 +1,571 @@
|
|||||||
|
[%General]
|
||||||
|
author=Matugen, based on MaterialADW by Vince Liuice
|
||||||
|
comment=A Material You theme generated by Matugen
|
||||||
|
x11drag=none
|
||||||
|
alt_mnemonic=true
|
||||||
|
left_tabs=false
|
||||||
|
attach_active_tab=false
|
||||||
|
mirror_doc_tabs=true
|
||||||
|
group_toolbar_buttons=false
|
||||||
|
toolbar_item_spacing=0
|
||||||
|
toolbar_interior_spacing=2
|
||||||
|
spread_progressbar=true
|
||||||
|
composite=true
|
||||||
|
menu_shadow_depth=6
|
||||||
|
spread_menuitems=false
|
||||||
|
tooltip_shadow_depth=7
|
||||||
|
splitter_width=1
|
||||||
|
scroll_width=9
|
||||||
|
scroll_arrows=false
|
||||||
|
scroll_min_extent=60
|
||||||
|
slider_width=2
|
||||||
|
slider_handle_width=23
|
||||||
|
slider_handle_length=22
|
||||||
|
tickless_slider_handle_size=22
|
||||||
|
center_toolbar_handle=true
|
||||||
|
check_size=24
|
||||||
|
textless_progressbar=false
|
||||||
|
progressbar_thickness=2
|
||||||
|
menubar_mouse_tracking=true
|
||||||
|
toolbutton_style=1
|
||||||
|
double_click=false
|
||||||
|
translucent_windows=false
|
||||||
|
blurring=false
|
||||||
|
popup_blurring=false
|
||||||
|
vertical_spin_indicators=false
|
||||||
|
spin_button_width=24
|
||||||
|
fill_rubberband=false
|
||||||
|
merge_menubar_with_toolbar=true
|
||||||
|
small_icon_size=16
|
||||||
|
large_icon_size=32
|
||||||
|
button_icon_size=16
|
||||||
|
toolbar_icon_size=16
|
||||||
|
combo_as_lineedit=true
|
||||||
|
animate_states=true
|
||||||
|
button_contents_shift=false
|
||||||
|
combo_menu=true
|
||||||
|
hide_combo_checkboxes=true
|
||||||
|
combo_focus_rect=false
|
||||||
|
groupbox_top_label=true
|
||||||
|
inline_spin_indicators=true
|
||||||
|
joined_inactive_tabs=false
|
||||||
|
layout_spacing=3
|
||||||
|
layout_margin=3
|
||||||
|
scrollbar_in_view=true
|
||||||
|
transient_scrollbar=true
|
||||||
|
transient_groove=false
|
||||||
|
submenu_overlap=0
|
||||||
|
tooltip_delay=0
|
||||||
|
tree_branch_line=false
|
||||||
|
no_window_pattern=false
|
||||||
|
opaque=kaffeine,kmplayer,subtitlecomposer,kdenlive,vlc,smplayer,smplayer2,avidemux,avidemux2_qt4,avidemux3_qt4,avidemux3_qt5,kamoso,QtCreator,VirtualBox,VirtualBoxVM,trojita,dragon,digikam,lyx
|
||||||
|
reduce_window_opacity=0
|
||||||
|
respect_DE=true
|
||||||
|
scrollable_menu=false
|
||||||
|
submenu_delay=150
|
||||||
|
no_inactiveness=false
|
||||||
|
reduce_menu_opacity=0
|
||||||
|
click_behavior=2
|
||||||
|
contrast=1.00
|
||||||
|
dialog_button_layout=0
|
||||||
|
intensity=1.00
|
||||||
|
saturation=1.00
|
||||||
|
shadowless_popup=false
|
||||||
|
drag_from_buttons=false
|
||||||
|
menu_blur_radius=0
|
||||||
|
tooltip_blur_radius=0
|
||||||
|
|
||||||
|
[GeneralColors]
|
||||||
|
window.color={surface}
|
||||||
|
base.color={surface}
|
||||||
|
alt.base.color={surface}
|
||||||
|
button.color={surface_variant}
|
||||||
|
light.color={surface}
|
||||||
|
mid.light.color={surface_variant}
|
||||||
|
dark.color={surface_variant}
|
||||||
|
mid.color={surface_variant}
|
||||||
|
highlight.color={accent}
|
||||||
|
inactive.highlight.color={accent}
|
||||||
|
text.color={on_surface}
|
||||||
|
window.text.color={on_surface}
|
||||||
|
button.text.color={on_surface}
|
||||||
|
disabled.text.color={editor_disabled}
|
||||||
|
tooltip.text.color={on_surface}
|
||||||
|
highlight.text.color={on_surface}
|
||||||
|
link.color={base06}
|
||||||
|
link.visited.color={base0D}
|
||||||
|
progress.indicator.text.color={on_surface}
|
||||||
|
|
||||||
|
[Hacks]
|
||||||
|
transparent_ktitle_label=true
|
||||||
|
transparent_dolphin_view=true
|
||||||
|
transparent_pcmanfm_sidepane=true
|
||||||
|
blur_translucent=false
|
||||||
|
transparent_menutitle=true
|
||||||
|
respect_darkness=true
|
||||||
|
kcapacitybar_as_progressbar=true
|
||||||
|
force_size_grip=true
|
||||||
|
iconless_pushbutton=false
|
||||||
|
iconless_menu=false
|
||||||
|
disabled_icon_opacity=100
|
||||||
|
lxqtmainmenu_iconsize=16
|
||||||
|
normal_default_pushbutton=true
|
||||||
|
single_top_toolbar=true
|
||||||
|
tint_on_mouseover=0
|
||||||
|
transparent_pcmanfm_view=true
|
||||||
|
no_selection_tint=true
|
||||||
|
transparent_arrow_button=true
|
||||||
|
middle_click_scroll=false
|
||||||
|
opaque_colors=false
|
||||||
|
kinetic_scrolling=false
|
||||||
|
scroll_jump_workaround=true
|
||||||
|
centered_forms=false
|
||||||
|
noninteger_translucency=false
|
||||||
|
style_vertical_toolbars=false
|
||||||
|
blur_only_active_window=true
|
||||||
|
|
||||||
|
[PanelButtonCommand]
|
||||||
|
frame=true
|
||||||
|
frame.element=button
|
||||||
|
frame.top=6
|
||||||
|
frame.bottom=6
|
||||||
|
frame.left=6
|
||||||
|
frame.right=6
|
||||||
|
interior=true
|
||||||
|
interior.element=button
|
||||||
|
indicator.size=8
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
text.shadow=0
|
||||||
|
text.margin=4
|
||||||
|
text.iconspacing=4
|
||||||
|
indicator.element=arrow
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[PanelButtonTool]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
text.bold=false
|
||||||
|
indicator.element=arrow
|
||||||
|
indicator.size=8
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[ToolbarButton]
|
||||||
|
frame=true
|
||||||
|
frame.element=tbutton
|
||||||
|
interior.element=tbutton
|
||||||
|
frame.top=16
|
||||||
|
frame.bottom=16
|
||||||
|
frame.left=16
|
||||||
|
frame.right=16
|
||||||
|
indicator.element=tarrow
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
text.bold=false
|
||||||
|
frame.expansion=32
|
||||||
|
|
||||||
|
[Dock]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
interior.element=dock
|
||||||
|
frame.element=dock
|
||||||
|
frame.top=1
|
||||||
|
frame.bottom=1
|
||||||
|
frame.left=1
|
||||||
|
frame.right=1
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
|
||||||
|
[DockTitle]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=false
|
||||||
|
interior=false
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.bold=false
|
||||||
|
|
||||||
|
[IndicatorSpinBox]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=true
|
||||||
|
interior=true
|
||||||
|
frame.top=2
|
||||||
|
frame.bottom=2
|
||||||
|
frame.left=2
|
||||||
|
frame.right=2
|
||||||
|
indicator.element=spin
|
||||||
|
indicator.size=8
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.margin.top=2
|
||||||
|
text.margin.bottom=2
|
||||||
|
text.margin.left=2
|
||||||
|
text.margin.right=2
|
||||||
|
|
||||||
|
[RadioButton]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=false
|
||||||
|
interior.element=radio
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
min_width=+0.3font
|
||||||
|
min_height=+0.3font
|
||||||
|
|
||||||
|
[CheckBox]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=false
|
||||||
|
interior.element=checkbox
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
min_width=+0.3font
|
||||||
|
min_height=+0.3font
|
||||||
|
|
||||||
|
[Focus]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=true
|
||||||
|
frame.element=focus
|
||||||
|
frame.top=2
|
||||||
|
frame.bottom=2
|
||||||
|
frame.left=2
|
||||||
|
frame.right=2
|
||||||
|
frame.patternsize=14
|
||||||
|
|
||||||
|
[GenericFrame]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=true
|
||||||
|
interior=false
|
||||||
|
frame.element=common
|
||||||
|
interior.element=common
|
||||||
|
frame.top=1
|
||||||
|
frame.bottom=1
|
||||||
|
frame.left=1
|
||||||
|
frame.right=1
|
||||||
|
|
||||||
|
[LineEdit]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.element=lineedit
|
||||||
|
interior.element=lineedit
|
||||||
|
frame.top=6
|
||||||
|
frame.bottom=6
|
||||||
|
frame.left=6
|
||||||
|
frame.right=6
|
||||||
|
text.margin.top=2
|
||||||
|
text.margin.bottom=2
|
||||||
|
text.margin.left=2
|
||||||
|
text.margin.right=2
|
||||||
|
|
||||||
|
[ToolbarLineEdit]
|
||||||
|
frame.element=lineedit
|
||||||
|
interior.element=lineedit
|
||||||
|
|
||||||
|
[DropDownButton]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
indicator.element=arrow-down
|
||||||
|
|
||||||
|
[IndicatorArrow]
|
||||||
|
indicator.element=arrow
|
||||||
|
indicator.size=8
|
||||||
|
|
||||||
|
[ToolboxTab]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
|
||||||
|
[Tab]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
interior.element=tab
|
||||||
|
text.margin.left=8
|
||||||
|
text.margin.right=8
|
||||||
|
text.margin.top=0
|
||||||
|
text.margin.bottom=0
|
||||||
|
frame.element=tab
|
||||||
|
indicator.element=tab
|
||||||
|
indicator.size=22
|
||||||
|
frame.top=8
|
||||||
|
frame.bottom=8
|
||||||
|
frame.left=8
|
||||||
|
frame.right=8
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
frame.expansion=0
|
||||||
|
text.bold=false
|
||||||
|
|
||||||
|
[TabFrame]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.element=tabframe
|
||||||
|
interior.element=tabframe
|
||||||
|
frame.top=6
|
||||||
|
frame.bottom=6
|
||||||
|
frame.left=6
|
||||||
|
frame.right=6
|
||||||
|
|
||||||
|
[TreeExpander]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
indicator.size=8
|
||||||
|
indicator.element=tree
|
||||||
|
|
||||||
|
[HeaderSection]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
interior.element=header
|
||||||
|
frame.element=header
|
||||||
|
frame.top=0
|
||||||
|
frame.bottom=1
|
||||||
|
frame.left=1
|
||||||
|
frame.right=1
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[SizeGrip]
|
||||||
|
indicator.element=resize-grip
|
||||||
|
|
||||||
|
[Toolbar]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
indicator.element=toolbar
|
||||||
|
indicator.size=5
|
||||||
|
text.margin=0
|
||||||
|
interior.element=menubar
|
||||||
|
frame.element=menubar
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
frame.left=6
|
||||||
|
frame.right=6
|
||||||
|
frame.top=0
|
||||||
|
frame.bottom=1
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[Slider]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.element=slider
|
||||||
|
focusFrame=true
|
||||||
|
interior.element=slider
|
||||||
|
frame.top=3
|
||||||
|
frame.bottom=3
|
||||||
|
frame.left=3
|
||||||
|
frame.right=3
|
||||||
|
|
||||||
|
[SliderCursor]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=false
|
||||||
|
interior.element=slidercursor
|
||||||
|
|
||||||
|
[Progressbar]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.element=progress
|
||||||
|
interior.element=progress
|
||||||
|
text.margin=0
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
text.bold=false
|
||||||
|
frame.expansion=8
|
||||||
|
|
||||||
|
[ProgressbarContents]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=true
|
||||||
|
frame.element=progress-pattern
|
||||||
|
interior.element=progress-pattern
|
||||||
|
|
||||||
|
[ItemView]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
text.margin=0
|
||||||
|
frame.element=itemview
|
||||||
|
interior.element=itemview
|
||||||
|
frame.top=4
|
||||||
|
frame.bottom=4
|
||||||
|
frame.left=4
|
||||||
|
frame.right=4
|
||||||
|
text.margin.top=0
|
||||||
|
text.margin.bottom=0
|
||||||
|
text.margin.left=8
|
||||||
|
text.margin.right=8
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
min_width=+0.3font
|
||||||
|
min_height=+0.3font
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[Splitter]
|
||||||
|
interior.element=splitter
|
||||||
|
frame=false
|
||||||
|
indicator.size=0
|
||||||
|
|
||||||
|
[Scrollbar]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
indicator.element=arrow
|
||||||
|
indicator.size=12
|
||||||
|
|
||||||
|
[ScrollbarSlider]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.element=scrollbarslider
|
||||||
|
interior=false
|
||||||
|
frame.left=5
|
||||||
|
frame.right=5
|
||||||
|
frame.top=5
|
||||||
|
frame.bottom=5
|
||||||
|
indicator.element=grip
|
||||||
|
indicator.size=12
|
||||||
|
|
||||||
|
[ScrollbarGroove]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
interior=false
|
||||||
|
frame=false
|
||||||
|
|
||||||
|
[Menu]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.top=10
|
||||||
|
frame.bottom=10
|
||||||
|
frame.left=10
|
||||||
|
frame.right=10
|
||||||
|
frame.element=menu
|
||||||
|
interior.element=menu
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.shadow=false
|
||||||
|
frame.expansion=0
|
||||||
|
text.bold=false
|
||||||
|
|
||||||
|
[MenuItem]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=true
|
||||||
|
frame.element=menuitem
|
||||||
|
interior.element=menuitem
|
||||||
|
indicator.element=menuitem
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.margin.top=0
|
||||||
|
text.margin.bottom=0
|
||||||
|
text.margin.left=6
|
||||||
|
text.margin.right=6
|
||||||
|
frame.top=4
|
||||||
|
frame.bottom=4
|
||||||
|
frame.left=4
|
||||||
|
frame.right=4
|
||||||
|
text.bold=false
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[MenuBar]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.element=menubar
|
||||||
|
interior.element=menubar
|
||||||
|
frame.bottom=0
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
frame.expansion=0
|
||||||
|
text.bold=false
|
||||||
|
|
||||||
|
[MenuBarItem]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
interior=true
|
||||||
|
interior.element=menubaritem
|
||||||
|
frame.element=menubaritem
|
||||||
|
frame.top=2
|
||||||
|
frame.bottom=2
|
||||||
|
frame.left=2
|
||||||
|
frame.right=2
|
||||||
|
text.margin.left=4
|
||||||
|
text.margin.right=4
|
||||||
|
text.margin.top=0
|
||||||
|
text.margin.bottom=0
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
text.bold=false
|
||||||
|
min_width=+0.3font
|
||||||
|
min_height=+0.3font
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[TitleBar]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame=false
|
||||||
|
text.margin.top=2
|
||||||
|
text.margin.bottom=2
|
||||||
|
text.margin.left=2
|
||||||
|
text.margin.right=2
|
||||||
|
interior.element=titlebar
|
||||||
|
indicator.size=16
|
||||||
|
indicator.element=mdi
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.bold=false
|
||||||
|
text.italic=true
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[ComboBox]
|
||||||
|
inherits=PanelButtonCommand
|
||||||
|
frame.element=combo
|
||||||
|
interior.element=combo
|
||||||
|
frame.top=6
|
||||||
|
frame.bottom=6
|
||||||
|
frame.left=6
|
||||||
|
frame.right=6
|
||||||
|
text.margin.top=2
|
||||||
|
text.margin.bottom=2
|
||||||
|
text.margin.left=2
|
||||||
|
text.margin.right=2
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.press.color={on_surface}
|
||||||
|
text.toggle.color={on_surface}
|
||||||
|
|
||||||
|
[GroupBox]
|
||||||
|
inherits=GenericFrame
|
||||||
|
frame=false
|
||||||
|
text.shadow=0
|
||||||
|
text.margin=0
|
||||||
|
text.normal.color={on_surface}
|
||||||
|
text.focus.color={on_surface}
|
||||||
|
text.bold=false
|
||||||
|
frame.expansion=0
|
||||||
|
|
||||||
|
[TabBarFrame]
|
||||||
|
inherits=GenericFrame
|
||||||
|
frame=false
|
||||||
|
frame.element=tabBarFrame
|
||||||
|
interior=false
|
||||||
|
frame.top=0
|
||||||
|
frame.bottom=0
|
||||||
|
frame.left=0
|
||||||
|
frame.right=0
|
||||||
|
|
||||||
|
[ToolTip]
|
||||||
|
inherits=GenericFrame
|
||||||
|
frame.top=6
|
||||||
|
frame.bottom=6
|
||||||
|
frame.left=6
|
||||||
|
frame.right=6
|
||||||
|
interior=true
|
||||||
|
text.shadow=0
|
||||||
|
text.margin=6
|
||||||
|
interior.element=tooltip
|
||||||
|
frame.element=tooltip
|
||||||
|
frame.expansion=6
|
||||||
|
|
||||||
|
[StatusBar]
|
||||||
|
inherits=GenericFrame
|
||||||
|
frame=false
|
||||||
|
interior=false
|
||||||
|
|
||||||
|
[Window]
|
||||||
|
interior=true
|
||||||
|
interior.element=window
|
||||||
|
frame=true
|
||||||
|
frame.element=window
|
||||||
|
frame.bottom=10
|
||||||
|
frame.top=10
|
||||||
|
|
||||||
|
text.disabled.color={editor_disabled}
|
||||||
6355
extra/templates/desktop/qt/kvantum.svg
Normal file
6355
extra/templates/desktop/qt/kvantum.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 170 KiB |
4
extra/templates/desktop/qt/qtct.conf
Normal file
4
extra/templates/desktop/qt/qtct.conf
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[ColorScheme]
|
||||||
|
active_colors={on_background}, {surface}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {on_background}, #ffffff, {on_surface}, {background}, {background}, {border}, {accent}, {on_surface}, {base04}, {accent}, {surface}, {surface}, {surface}, {on_surface}, {base04}
|
||||||
|
disabled_colors={editor_disabled}, {surface}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {editor_disabled}, #ffffff, {editor_disabled}, {background}, {background}, {border}, {surface_variant}, {on_surface_variant}, {base04}, {accent}, {surface}, {surface}, {surface}, {editor_disabled}, {base04}
|
||||||
|
inactive_colors={on_background}, {surface}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {on_background}, #ffffff, {on_surface}, {background}, {background}, {border}, {surface_variant}, {on_surface_variant}, {base04}, {accent}, {surface}, {surface}, {surface}, {on_surface}, {base04}
|
||||||
48
extra/templates/desktop/qt/readme.md
Normal file
48
extra/templates/desktop/qt/readme.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Qt
|
||||||
|
|
||||||
|
1. Download the templates:
|
||||||
|
- Kvantum: [kvantum.kvconfig](kvantum.kvconfig) and [kvantum.svg](kvantum.svg)
|
||||||
|
- Qt5ct/Qt6ct: [qtct.conf](qtct.conf)
|
||||||
|
|
||||||
|
2. Configure the templates in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.kvantum]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/kvantum/kvantum.kvconfig'
|
||||||
|
output_path = '~/.config/Kvantum/clrsync/clrsync.kvconfig'
|
||||||
|
reload_cmd = ''
|
||||||
|
|
||||||
|
[templates.kvantum-svg]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/kvantum/kvantum.svg'
|
||||||
|
output_path = '~/.config/Kvantum/clrsync/clrsync.svg'
|
||||||
|
reload_cmd = ''
|
||||||
|
|
||||||
|
[templates.qt5ct]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/qtct.conf'
|
||||||
|
output_path = '~/.config/qt5ct/colors/clrsync.conf'
|
||||||
|
reload_cmd = ''
|
||||||
|
|
||||||
|
[templates.qt6ct]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/qtct.conf'
|
||||||
|
output_path = '~/.config/qt6ct/colors/clrsync.conf'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Set the theme in `~/.config/Kvantum/kvantum.kvconfig`:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
[General]
|
||||||
|
theme=clrsync
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Set the theme in `~/.config/qt5ct/qt5ct.conf` and `~/.config/qt6ct/qt6ct.conf`:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
[Appearance]
|
||||||
|
color_scheme_path=$HOME/.config/qt5ct/colors/clrsync.conf
|
||||||
|
custom_palette=true
|
||||||
|
```
|
||||||
69
extra/templates/terminals/alacritty/alacritty.toml
Normal file
69
extra/templates/terminals/alacritty/alacritty.toml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
[colors.primary]
|
||||||
|
background = '{background}'
|
||||||
|
foreground = '{foreground}'
|
||||||
|
|
||||||
|
[colors.cursor]
|
||||||
|
text = '{background}'
|
||||||
|
cursor = '{cursor}'
|
||||||
|
|
||||||
|
[colors.vi_mode_cursor]
|
||||||
|
text = '{background}'
|
||||||
|
cursor = '{cursor}'
|
||||||
|
|
||||||
|
[colors.selection]
|
||||||
|
text = 'CellForeground'
|
||||||
|
background = '{editor_selected}'
|
||||||
|
|
||||||
|
[colors.search.matches]
|
||||||
|
foreground = '{background}'
|
||||||
|
background = '{base0A}'
|
||||||
|
|
||||||
|
[colors.search.focused_match]
|
||||||
|
foreground = '{background}'
|
||||||
|
background = '{accent}'
|
||||||
|
|
||||||
|
[colors.footer_bar]
|
||||||
|
foreground = '{foreground}'
|
||||||
|
background = '{surface}'
|
||||||
|
|
||||||
|
[colors.hints.start]
|
||||||
|
foreground = '{background}'
|
||||||
|
background = '{warning}'
|
||||||
|
|
||||||
|
[colors.hints.end]
|
||||||
|
foreground = '{background}'
|
||||||
|
background = '{surface_variant}'
|
||||||
|
|
||||||
|
[colors.line_indicator]
|
||||||
|
foreground = 'None'
|
||||||
|
background = 'None'
|
||||||
|
|
||||||
|
[colors.normal]
|
||||||
|
black = '{base00}'
|
||||||
|
red = '{base08}'
|
||||||
|
green = '{base01}'
|
||||||
|
yellow = '{base02}'
|
||||||
|
blue = '{base06}'
|
||||||
|
magenta = '{base05}'
|
||||||
|
cyan = '{base0E}'
|
||||||
|
white = '{base07}'
|
||||||
|
|
||||||
|
[colors.bright]
|
||||||
|
black = '{border_focused}'
|
||||||
|
red = '{editor_error}'
|
||||||
|
green = '{editor_success}'
|
||||||
|
yellow = '{base0A}'
|
||||||
|
blue = '{editor_link}'
|
||||||
|
magenta = '{base0D}'
|
||||||
|
cyan = '{editor_comment}'
|
||||||
|
white = '{base0F}'
|
||||||
|
|
||||||
|
[colors.dim]
|
||||||
|
black = '{border}'
|
||||||
|
red = '{base0C}'
|
||||||
|
green = '{base01}'
|
||||||
|
yellow = '{editor_string}'
|
||||||
|
blue = '{base06}'
|
||||||
|
magenta = '{base05}'
|
||||||
|
cyan = '{base0E}'
|
||||||
|
white = '{base07}'
|
||||||
20
extra/templates/terminals/alacritty/readme.md
Normal file
20
extra/templates/terminals/alacritty/readme.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Alacritty
|
||||||
|
|
||||||
|
1. Download the [template file](alacritty.toml)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.alacritty]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/alacritty.toml'
|
||||||
|
output_path = '~/.config/alacritty/clrsync.toml'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Import the generated color scheme in `~/.config/alacritty/alacritty.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[general]
|
||||||
|
import = ["clrsync.toml"]
|
||||||
|
```
|
||||||
26
extra/templates/terminals/ghostty/ghostty.conf
Normal file
26
extra/templates/terminals/ghostty/ghostty.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
background = {background}
|
||||||
|
foreground = {foreground}
|
||||||
|
|
||||||
|
cursor-color = {cursor}
|
||||||
|
cursor-text = {foreground}
|
||||||
|
|
||||||
|
selection-background = {editor_selected}
|
||||||
|
selection-foreground = {foreground}
|
||||||
|
|
||||||
|
palette = 0={base00}
|
||||||
|
palette = 1={base08}
|
||||||
|
palette = 2={base01}
|
||||||
|
palette = 3={base02}
|
||||||
|
palette = 4={base06}
|
||||||
|
palette = 5={base05}
|
||||||
|
palette = 6={base0E}
|
||||||
|
palette = 7={base07}
|
||||||
|
|
||||||
|
palette = 8={border_focused}
|
||||||
|
palette = 9={editor_error}
|
||||||
|
palette = 10={editor_success}
|
||||||
|
palette = 11={base0A}
|
||||||
|
palette = 12={editor_link}
|
||||||
|
palette = 13={base0D}
|
||||||
|
palette = 14={editor_comment}
|
||||||
|
palette = 15={base0F}
|
||||||
19
extra/templates/terminals/ghostty/readme.md
Normal file
19
extra/templates/terminals/ghostty/readme.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Ghostty
|
||||||
|
|
||||||
|
1. Download the [template file](ghostty)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.ghostty]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/ghostty'
|
||||||
|
output_path = '~/.config/ghostty/themes/clrsync'
|
||||||
|
reload_cmd = 'pkill -SIGUSR2 ghostty'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Set the generated color scheme in `~/.config/ghostty/config`:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
theme = "clrsync"
|
||||||
|
```
|
||||||
32
extra/templates/terminals/kitty/kitty.conf
Normal file
32
extra/templates/terminals/kitty/kitty.conf
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
cursor {cursor}
|
||||||
|
cursor_text_color {background}
|
||||||
|
|
||||||
|
foreground {foreground}
|
||||||
|
background {background}
|
||||||
|
selection_foreground {on_surface}
|
||||||
|
selection_background {surface}
|
||||||
|
url_color {accent}
|
||||||
|
|
||||||
|
color0 {base00}
|
||||||
|
color8 {base08}
|
||||||
|
|
||||||
|
color1 {base01}
|
||||||
|
color9 {base09}
|
||||||
|
|
||||||
|
color2 {base02}
|
||||||
|
color10 {base0A}
|
||||||
|
|
||||||
|
color3 {base03}
|
||||||
|
color11 {base0B}
|
||||||
|
|
||||||
|
color4 {base04}
|
||||||
|
color12 {base0C}
|
||||||
|
|
||||||
|
color5 {base05}
|
||||||
|
color13 {base0D}
|
||||||
|
|
||||||
|
color6 {base06}
|
||||||
|
color14 {base0E}
|
||||||
|
|
||||||
|
color7 {base07}
|
||||||
|
color15 {base0F}
|
||||||
19
extra/templates/terminals/kitty/readme.md
Normal file
19
extra/templates/terminals/kitty/readme.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Kitty
|
||||||
|
|
||||||
|
1. Download the [template file](kitty.conf)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.kitty]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/kitty.conf'
|
||||||
|
output_path = '~/.config/kitty/clrsync.conf'
|
||||||
|
reload_cmd = 'pkill -SIGUSR1 kitty'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Import the generated color scheme in `~/.config/kitty/kitty.conf`:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
include clrsync.conf
|
||||||
|
```
|
||||||
93
extra/templates/text-editors/neovim/nvim.lua
Normal file
93
extra/templates/text-editors/neovim/nvim.lua
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
vim.cmd("highlight clear")
|
||||||
|
vim.cmd("syntax reset")
|
||||||
|
vim.g.colors_name = "clrsync"
|
||||||
|
|
||||||
|
local palette = {
|
||||||
|
-- Editor colors
|
||||||
|
Default = "{editor_main.hex}",
|
||||||
|
Keyword = "{editor_command.hex}",
|
||||||
|
Number = "{editor_warning.hex}",
|
||||||
|
String = "{editor_string.hex}",
|
||||||
|
CharLiteral = "{editor_string.hex}",
|
||||||
|
Punctuation = "{editor_main.hex}",
|
||||||
|
Preprocessor = "{editor_emphasis.hex}",
|
||||||
|
Identifier = "{editor_main.hex}",
|
||||||
|
KnownIdentifier = "{editor_link.hex}",
|
||||||
|
PreprocIdentifier = "{editor_link.hex}",
|
||||||
|
|
||||||
|
Comment = "{editor_comment.hex}",
|
||||||
|
MultiLineComment = "{editor_comment.hex}",
|
||||||
|
|
||||||
|
Background = "{editor_background.hex}",
|
||||||
|
Cursor = "{cursor.hex}",
|
||||||
|
|
||||||
|
Selection = "{editor_selected.hex}",
|
||||||
|
ErrorMarker = "{editor_error.hex}",
|
||||||
|
Breakpoint = "{editor_error.hex}",
|
||||||
|
|
||||||
|
LineNumber = "{editor_line_number.hex}",
|
||||||
|
CurrentLineFill = "{surface_variant.hex}",
|
||||||
|
CurrentLineFillInactive = "{surface.hex}",
|
||||||
|
|
||||||
|
CurrentLineEdge = "{border_focused.hex}",
|
||||||
|
|
||||||
|
-- Semantic colors
|
||||||
|
Success = "{success.hex}",
|
||||||
|
Warning = "{warning.hex}",
|
||||||
|
Error = "{error.hex}",
|
||||||
|
Info = "{info.hex}",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Helper function to set highlights in Neovim
|
||||||
|
local function set_hl(group, opts)
|
||||||
|
vim.api.nvim_set_hl(0, group, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.o.winborder = "rounded"
|
||||||
|
|
||||||
|
-- Basic editor highlights using the mapped palette
|
||||||
|
set_hl("Normal", { fg = palette.Default, bg = palette.Background })
|
||||||
|
set_hl("CursorLine", { bg = palette.CurrentLineFill })
|
||||||
|
set_hl("Visual", { bg = palette.Selection })
|
||||||
|
set_hl("LineNr", { fg = palette.LineNumber })
|
||||||
|
set_hl("CursorLineNr", { fg = palette.Keyword })
|
||||||
|
|
||||||
|
-- Syntax highlights
|
||||||
|
set_hl("Comment", { fg = palette.Comment, italic = true })
|
||||||
|
set_hl("Constant", { fg = palette.Number })
|
||||||
|
set_hl("String", { fg = palette.String })
|
||||||
|
set_hl("Character", { fg = palette.CharLiteral })
|
||||||
|
set_hl("Identifier", { fg = palette.Identifier })
|
||||||
|
set_hl("Function", { fg = palette.Keyword })
|
||||||
|
set_hl("Statement", { fg = palette.Keyword })
|
||||||
|
set_hl("PreProc", { fg = palette.Preprocessor })
|
||||||
|
set_hl("Type", { fg = palette.Keyword })
|
||||||
|
set_hl("Special", { fg = palette.PreprocIdentifier })
|
||||||
|
set_hl("Underlined", { fg = palette.KnownIdentifier })
|
||||||
|
set_hl("Error", { fg = palette.ErrorMarker, bg = palette.Background })
|
||||||
|
set_hl("Todo", { fg = palette.Default, bg = palette.Keyword })
|
||||||
|
|
||||||
|
-- Floating windows
|
||||||
|
set_hl("NormalFloat", { bg = palette.Background })
|
||||||
|
set_hl("FloatBorder", { fg = palette.CurrentLineEdge, bg = palette.Background })
|
||||||
|
|
||||||
|
-- Completion menu
|
||||||
|
set_hl("Pmenu", { bg = palette.Background })
|
||||||
|
set_hl("PmenuSel", { bg = palette.Keyword, fg = palette.Background })
|
||||||
|
|
||||||
|
-- Git and diagnostic highlights
|
||||||
|
set_hl("DiffAdd", { fg = palette.Success, bg = palette.Background })
|
||||||
|
set_hl("DiffChange", { fg = palette.Keyword, bg = palette.Background })
|
||||||
|
set_hl("DiffDelete", { fg = palette.ErrorMarker, bg = palette.Background })
|
||||||
|
set_hl("DiagnosticError", { fg = palette.Error })
|
||||||
|
set_hl("DiagnosticWarn", { fg = palette.Warning })
|
||||||
|
set_hl("DiagnosticInfo", { fg = palette.Info })
|
||||||
|
set_hl("DiagnosticHint", { fg = palette.PreprocIdentifier })
|
||||||
|
|
||||||
|
-- Treesitter links
|
||||||
|
set_hl("@comment", { link = "Comment" })
|
||||||
|
set_hl("@string", { fg = palette.String })
|
||||||
|
set_hl("@function", { fg = palette.Keyword })
|
||||||
|
set_hl("@variable", { fg = palette.Identifier })
|
||||||
|
set_hl("@keyword", { fg = palette.Keyword })
|
||||||
|
set_hl("@type", { fg = palette.Preprocessor })
|
||||||
19
extra/templates/text-editors/neovim/readme.md
Normal file
19
extra/templates/text-editors/neovim/readme.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Neovim
|
||||||
|
|
||||||
|
1. Download the [template file](nvim.lua)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.nvim]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/nvim.lua'
|
||||||
|
output_path = '~/.config/nvim/colors/clrsync.lua'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Set the colorscheme in your Neovim config:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
vim.cmd.colorscheme 'clrsync'
|
||||||
|
```
|
||||||
2094
extra/templates/text-editors/vscode/code.json
Normal file
2094
extra/templates/text-editors/vscode/code.json
Normal file
File diff suppressed because it is too large
Load Diff
17
extra/templates/text-editors/vscode/readme.md
Normal file
17
extra/templates/text-editors/vscode/readme.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Visual Studio Code
|
||||||
|
|
||||||
|
1. Install the [clrsync VS Code theme](https://marketplace.visualstudio.com/items?itemName=obsqrbtz.clrsync)
|
||||||
|
|
||||||
|
2. Download the [template file](code.json)
|
||||||
|
|
||||||
|
3. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.vscode]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/code.json'
|
||||||
|
output_path = '~/.vscode/extensions/obsqrbtz.clrsync-1.0.2/themes/clrsync-color-theme.json'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Set the `clrsync` color scheme in VS Code
|
||||||
25
extra/templates/wms/hyprland/hyprland.conf
Normal file
25
extra/templates/wms/hyprland/hyprland.conf
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
$primary = rgb({accent_stripped})
|
||||||
|
$surface = rgb({surface_stripped})
|
||||||
|
$secondary = rgb({accent_secondary_stripped})
|
||||||
|
$error = rgb({error_stripped})
|
||||||
|
$tertiary = rgb({base06_stripped})
|
||||||
|
$surface_lowest = rgb({background_stripped})
|
||||||
|
|
||||||
|
general {
|
||||||
|
col.active_border = $primary
|
||||||
|
col.inactive_border = $surface
|
||||||
|
}
|
||||||
|
|
||||||
|
group {
|
||||||
|
col.border_active = $secondary
|
||||||
|
col.border_inactive = $surface
|
||||||
|
col.border_locked_active = $error
|
||||||
|
col.border_locked_inactive = $surface
|
||||||
|
|
||||||
|
groupbar {
|
||||||
|
col.active = $secondary
|
||||||
|
col.inactive = $surface
|
||||||
|
col.locked_active = $error
|
||||||
|
col.locked_inactive = $surface
|
||||||
|
}
|
||||||
|
}
|
||||||
19
extra/templates/wms/hyprland/readme.md
Normal file
19
extra/templates/wms/hyprland/readme.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Hyprland
|
||||||
|
|
||||||
|
1. Download the [template file](hyprland.conf)
|
||||||
|
|
||||||
|
2. Configure the template in `~/.config/clrsync/config.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[templates.hyprland]
|
||||||
|
enabled = true
|
||||||
|
input_path = '~/.config/clrsync/templates/hyprland.conf'
|
||||||
|
output_path = '~/.config/hypr/clrsync.conf'
|
||||||
|
reload_cmd = ''
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Source the generated config in `~/.config/hypr/hyprland.conf`:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
source = clrsync.conf
|
||||||
|
```
|
||||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1764950072,
|
"lastModified": 1765779637,
|
||||||
"narHash": "sha256-BmPWzogsG2GsXZtlT+MTcAWeDK5hkbGRZTeZNW42fwA=",
|
"narHash": "sha256-KJ2wa/BLSrTqDjbfyNx70ov/HdgNBCBBSQP3BIzKnv4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "f61125a668a320878494449750330ca58b78c557",
|
"rev": "1306659b587dc277866c7b69eb97e5f07864d8c4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
18
package.nix
18
package.nix
@@ -5,6 +5,7 @@
|
|||||||
git,
|
git,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
|
wrapGAppsHook3,
|
||||||
wayland-protocols,
|
wayland-protocols,
|
||||||
glfw,
|
glfw,
|
||||||
freetype,
|
freetype,
|
||||||
@@ -17,7 +18,9 @@
|
|||||||
bzip2,
|
bzip2,
|
||||||
wayland-scanner,
|
wayland-scanner,
|
||||||
gtk3,
|
gtk3,
|
||||||
semver
|
glib,
|
||||||
|
gsettings-desktop-schemas,
|
||||||
|
semver,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
@@ -49,6 +52,7 @@ stdenv.mkDerivation rec {
|
|||||||
git
|
git
|
||||||
pkg-config
|
pkg-config
|
||||||
makeWrapper
|
makeWrapper
|
||||||
|
wrapGAppsHook3
|
||||||
wayland-protocols
|
wayland-protocols
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -69,6 +73,8 @@ stdenv.mkDerivation rec {
|
|||||||
zlib
|
zlib
|
||||||
bzip2
|
bzip2
|
||||||
gtk3
|
gtk3
|
||||||
|
gsettings-desktop-schemas
|
||||||
|
glib
|
||||||
];
|
];
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
@@ -82,21 +88,17 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
cmake --install . --prefix $out
|
cmake --install . --prefix $out
|
||||||
|
|
||||||
wrapProgram $out/bin/clrsync_gui \
|
|
||||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
|
|
||||||
|
|
||||||
wrapProgram $out/bin/clrsync_cli \
|
|
||||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
|
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
dontWrapGApps = false;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Color scheme manager with GUI and CLI";
|
description = "Color scheme manager with GUI and CLI";
|
||||||
homepage = "https://github.com/obsqrbtz/clrsync";
|
homepage = "https://github.com/obsqrbtz/clrsync";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
platforms = platforms.linux;
|
platforms = platforms.linux;
|
||||||
mainProgram = "clrsync_gui";
|
mainProgram = "clrsync_gui";
|
||||||
maintainers = [ ];
|
maintainers = [ "Daniel Dada" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
resources/JetBrainsMono-Regular.ttf
Normal file
BIN
resources/JetBrainsMono-Regular.ttf
Normal file
Binary file not shown.
192
src/cli/main.cpp
192
src/cli/main.cpp
@@ -4,15 +4,17 @@
|
|||||||
|
|
||||||
#include <argparse/argparse.hpp>
|
#include <argparse/argparse.hpp>
|
||||||
|
|
||||||
#include <core/config/config.hpp>
|
#include "core/common/error.hpp"
|
||||||
#include <core/error.hpp>
|
#include "core/common/utils.hpp"
|
||||||
#include <core/io/toml_file.hpp>
|
#include "core/common/version.hpp"
|
||||||
#include <core/palette/palette_file.hpp>
|
#include "core/config/config.hpp"
|
||||||
#include <core/palette/palette_manager.hpp>
|
#include "core/io/toml_file.hpp"
|
||||||
#include <core/theme/theme_renderer.hpp>
|
#include "core/palette/hellwal_generator.hpp"
|
||||||
#include <core/theme/theme_template.hpp>
|
#include "core/palette/matugen_generator.hpp"
|
||||||
#include <core/utils.hpp>
|
#include "core/palette/palette_file.hpp"
|
||||||
#include <core/version.hpp>
|
#include "core/palette/palette_manager.hpp"
|
||||||
|
#include "core/theme/theme_renderer.hpp"
|
||||||
|
#include "core/theme/theme_template.hpp"
|
||||||
|
|
||||||
void handle_show_vars()
|
void handle_show_vars()
|
||||||
{
|
{
|
||||||
@@ -91,6 +93,48 @@ void setup_argument_parser(argparse::ArgumentParser &program)
|
|||||||
auto &group = program.add_mutually_exclusive_group();
|
auto &group = program.add_mutually_exclusive_group();
|
||||||
group.add_argument("-t", "--theme").help("sets theme <theme_name> to apply");
|
group.add_argument("-t", "--theme").help("sets theme <theme_name> to apply");
|
||||||
group.add_argument("-p", "--path").help("sets theme file <path/to/theme> to apply");
|
group.add_argument("-p", "--path").help("sets theme file <path/to/theme> to apply");
|
||||||
|
|
||||||
|
program.add_argument("-g", "--generate").nargs(1).help("generate palette from <image path>");
|
||||||
|
program.add_argument("--generate-color")
|
||||||
|
.nargs(1)
|
||||||
|
.help("generate palette from a color (hex), used with --generator matugen");
|
||||||
|
|
||||||
|
program.add_argument("--generator")
|
||||||
|
.default_value(std::string("hellwal"))
|
||||||
|
.help("palette generator to use (hellwal)")
|
||||||
|
.metavar("GENERATOR");
|
||||||
|
|
||||||
|
program.add_argument("--matugen-type")
|
||||||
|
.default_value(std::string("scheme-tonal-spot"))
|
||||||
|
.help("matugen: Sets a custom color scheme type")
|
||||||
|
.metavar("TYPE");
|
||||||
|
program.add_argument("--matugen-mode")
|
||||||
|
.default_value(std::string("dark"))
|
||||||
|
.help("matugen: Which mode to use for the color scheme (light,dark)")
|
||||||
|
.metavar("MODE");
|
||||||
|
program.add_argument("--matugen-contrast")
|
||||||
|
.default_value(std::string("0.0"))
|
||||||
|
.help("matugen: contrast value from -1 to 1")
|
||||||
|
.metavar("FLOAT");
|
||||||
|
|
||||||
|
// hellwal generator options
|
||||||
|
program.add_argument("--hellwal-neon").help("hellwal: enable neon mode").flag();
|
||||||
|
program.add_argument("--hellwal-dark").help("hellwal: prefer dark palettes").flag();
|
||||||
|
program.add_argument("--hellwal-light").help("hellwal: prefer light palettes").flag();
|
||||||
|
program.add_argument("--hellwal-color").help("hellwal: enable color mode").flag();
|
||||||
|
program.add_argument("--hellwal-invert").help("hellwal: invert colors").flag();
|
||||||
|
program.add_argument("--hellwal-dark-offset")
|
||||||
|
.default_value(std::string("0.0"))
|
||||||
|
.help("hellwal: dark offset (float)")
|
||||||
|
.metavar("FLOAT");
|
||||||
|
program.add_argument("--hellwal-bright-offset")
|
||||||
|
.default_value(std::string("0.0"))
|
||||||
|
.help("hellwal: bright offset (float)")
|
||||||
|
.metavar("FLOAT");
|
||||||
|
program.add_argument("--hellwal-gray-scale")
|
||||||
|
.default_value(std::string("0.0"))
|
||||||
|
.help("hellwal: gray scale factor (float)")
|
||||||
|
.metavar("FLOAT");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -136,6 +180,136 @@ int main(int argc, char *argv[])
|
|||||||
return handle_apply_theme(program, default_theme);
|
return handle_apply_theme(program, default_theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (program.is_used("--generate"))
|
||||||
|
{
|
||||||
|
std::string image_path;
|
||||||
|
if (program.is_used("--generate"))
|
||||||
|
image_path = program.get<std::string>("--generate");
|
||||||
|
std::string generator_name = program.get<std::string>("--generator");
|
||||||
|
|
||||||
|
clrsync::core::palette pal;
|
||||||
|
if (generator_name == "hellwal")
|
||||||
|
{
|
||||||
|
clrsync::core::hellwal_generator gen;
|
||||||
|
clrsync::core::hellwal_generator::options opts{};
|
||||||
|
|
||||||
|
if (program.is_used("--hellwal-neon"))
|
||||||
|
opts.neon = true;
|
||||||
|
if (program.is_used("--hellwal-dark"))
|
||||||
|
opts.dark = true;
|
||||||
|
if (program.is_used("--hellwal-light"))
|
||||||
|
opts.light = true;
|
||||||
|
if (program.is_used("--hellwal-color"))
|
||||||
|
opts.color = true;
|
||||||
|
if (program.is_used("--hellwal-invert"))
|
||||||
|
opts.invert = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::string s1 = program.get<std::string>("--hellwal-dark-offset");
|
||||||
|
opts.dark_offset = std::stof(s1);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::string s2 = program.get<std::string>("--hellwal-bright-offset");
|
||||||
|
opts.bright_offset = std::stof(s2);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::string s3 = program.get<std::string>("--hellwal-gray-scale");
|
||||||
|
opts.gray_scale = std::stof(s3);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
pal = gen.generate_from_image(image_path, opts);
|
||||||
|
}
|
||||||
|
else if (generator_name == "matugen")
|
||||||
|
{
|
||||||
|
clrsync::core::matugen_generator gen;
|
||||||
|
clrsync::core::matugen_generator::options opts{};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
opts.type = program.get<std::string>("--matugen-type");
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
opts.type = program.get<std::string>("--matugen-type");
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
opts.mode = program.get<std::string>("--matugen-mode");
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::string s = program.get<std::string>("--matugen-contrast");
|
||||||
|
opts.contrast = std::stof(s);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (program.is_used("--generate-color"))
|
||||||
|
{
|
||||||
|
std::string color = program.get<std::string>("--generate-color");
|
||||||
|
pal = gen.generate_from_color(color, opts);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pal = gen.generate_from_image(image_path, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Unknown generator: " << generator_name << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pal.name().empty())
|
||||||
|
{
|
||||||
|
std::filesystem::path p(image_path);
|
||||||
|
pal.set_name("generated:" + p.filename().string());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dir = clrsync::core::config::instance().palettes_path();
|
||||||
|
clrsync::core::palette_manager<clrsync::core::io::toml_file> pal_mgr;
|
||||||
|
pal_mgr.save_palette_to_file(pal, dir);
|
||||||
|
|
||||||
|
clrsync::core::theme_renderer<clrsync::core::io::toml_file> renderer;
|
||||||
|
std::filesystem::path file_path = std::filesystem::path(dir) / (pal.name() + ".toml");
|
||||||
|
auto res = renderer.apply_theme_from_path(file_path.string());
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to apply generated palette: " << res.error().description()
|
||||||
|
<< std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::cout << "Generated and applied palette: " << pal.name() << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << program << std::endl;
|
std::cout << program << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
set(CORE_SOURCES
|
set(CORE_SOURCES
|
||||||
palette/color.cpp
|
palette/color.cpp
|
||||||
|
palette/hellwal_generator.cpp
|
||||||
|
palette/matugen_generator.cpp
|
||||||
io/toml_file.cpp
|
io/toml_file.cpp
|
||||||
config/config.cpp
|
config/config.cpp
|
||||||
utils.cpp
|
common/utils.cpp
|
||||||
version.cpp
|
common/version.cpp
|
||||||
theme/theme_template.cpp
|
theme/theme_template.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
266
src/core/common/error.hpp
Normal file
266
src/core/common/error.hpp
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
#ifndef CLRSYNC_CORE_ERROR_HPP
|
||||||
|
#define CLRSYNC_CORE_ERROR_HPP
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
namespace clrsync::core
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class error_code
|
||||||
|
{
|
||||||
|
unknown,
|
||||||
|
|
||||||
|
file_not_found,
|
||||||
|
file_open_failed,
|
||||||
|
file_write_failed,
|
||||||
|
file_read_failed,
|
||||||
|
dir_create_failed,
|
||||||
|
|
||||||
|
parse_failed,
|
||||||
|
invalid_format,
|
||||||
|
|
||||||
|
config_missing,
|
||||||
|
config_invalid,
|
||||||
|
|
||||||
|
template_not_found,
|
||||||
|
template_load_failed,
|
||||||
|
template_apply_failed,
|
||||||
|
|
||||||
|
palette_not_found,
|
||||||
|
palette_load_failed,
|
||||||
|
|
||||||
|
init_failed,
|
||||||
|
invalid_arg,
|
||||||
|
resource_missing,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const char *error_code_string(error_code code)
|
||||||
|
{
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case error_code::unknown:
|
||||||
|
return "Unknown error";
|
||||||
|
case error_code::file_not_found:
|
||||||
|
return "File not found";
|
||||||
|
case error_code::file_open_failed:
|
||||||
|
return "Failed to open file";
|
||||||
|
case error_code::file_write_failed:
|
||||||
|
return "Failed to write file";
|
||||||
|
case error_code::file_read_failed:
|
||||||
|
return "Failed to read file";
|
||||||
|
case error_code::dir_create_failed:
|
||||||
|
return "Failed to create directory";
|
||||||
|
case error_code::parse_failed:
|
||||||
|
return "Parse failed";
|
||||||
|
case error_code::invalid_format:
|
||||||
|
return "Invalid format";
|
||||||
|
case error_code::config_missing:
|
||||||
|
return "Configuration missing";
|
||||||
|
case error_code::config_invalid:
|
||||||
|
return "Configuration invalid";
|
||||||
|
case error_code::template_not_found:
|
||||||
|
return "Template not found";
|
||||||
|
case error_code::template_load_failed:
|
||||||
|
return "Failed to load template";
|
||||||
|
case error_code::template_apply_failed:
|
||||||
|
return "Failed to apply template";
|
||||||
|
case error_code::palette_not_found:
|
||||||
|
return "Palette not found";
|
||||||
|
case error_code::palette_load_failed:
|
||||||
|
return "Failed to load palette";
|
||||||
|
case error_code::init_failed:
|
||||||
|
return "Initialization failed";
|
||||||
|
case error_code::invalid_arg:
|
||||||
|
return "Invalid argument";
|
||||||
|
case error_code::resource_missing:
|
||||||
|
return "Resource missing";
|
||||||
|
default:
|
||||||
|
return "Unknown error code";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Error
|
||||||
|
{
|
||||||
|
error_code code;
|
||||||
|
std::string message;
|
||||||
|
std::string context;
|
||||||
|
|
||||||
|
Error(error_code c) : code(c), message(error_code_string(c))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Error(error_code c, std::string msg) : code(c), message(std::move(msg))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Error(error_code c, std::string msg, std::string ctx)
|
||||||
|
: code(c), message(std::move(msg)), context(std::move(ctx))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string description() const
|
||||||
|
{
|
||||||
|
if (context.empty())
|
||||||
|
return message;
|
||||||
|
return message + " [" + context + "]";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T> class [[nodiscard]] Result
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::variant<T, Error> m_data;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Result(T value) : m_data(std::move(value))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Result(Error error) : m_data(std::move(error))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_ok() const
|
||||||
|
{
|
||||||
|
return std::holds_alternative<T>(m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_error() const
|
||||||
|
{
|
||||||
|
return std::holds_alternative<Error>(m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit operator bool() const
|
||||||
|
{
|
||||||
|
return is_ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
T &value() &
|
||||||
|
{
|
||||||
|
return std::get<T>(m_data);
|
||||||
|
}
|
||||||
|
const T &value() const &
|
||||||
|
{
|
||||||
|
return std::get<T>(m_data);
|
||||||
|
}
|
||||||
|
T &&value() &&
|
||||||
|
{
|
||||||
|
return std::get<T>(std::move(m_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
const Error &error() const
|
||||||
|
{
|
||||||
|
return std::get<Error>(m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
T value_or(T default_value) const
|
||||||
|
{
|
||||||
|
return is_ok() ? std::get<T>(m_data) : std::move(default_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<T> ok() const
|
||||||
|
{
|
||||||
|
if (is_ok())
|
||||||
|
return std::get<T>(m_data);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<Error> err() const
|
||||||
|
{
|
||||||
|
if (is_error())
|
||||||
|
return std::get<Error>(m_data);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename F> auto map(F &&func) -> Result<decltype(func(std::declval<T>()))>
|
||||||
|
{
|
||||||
|
using U = decltype(func(std::declval<T>()));
|
||||||
|
if (is_ok())
|
||||||
|
return Result<U>(func(std::get<T>(m_data)));
|
||||||
|
return Result<U>(std::get<Error>(m_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename F> auto and_then(F &&func) -> decltype(func(std::declval<T>()))
|
||||||
|
{
|
||||||
|
if (is_ok())
|
||||||
|
return func(std::get<T>(m_data));
|
||||||
|
using ResultType = decltype(func(std::declval<T>()));
|
||||||
|
return ResultType(std::get<Error>(m_data));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <> class [[nodiscard]] Result<void>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::optional<Error> m_error;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Result() : m_error(std::nullopt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Result(Error error) : m_error(std::move(error))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_ok() const
|
||||||
|
{
|
||||||
|
return !m_error.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_error() const
|
||||||
|
{
|
||||||
|
return m_error.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit operator bool() const
|
||||||
|
{
|
||||||
|
return is_ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
const Error &error() const
|
||||||
|
{
|
||||||
|
return *m_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<Error> err() const
|
||||||
|
{
|
||||||
|
return m_error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T> Result<T> Ok(T value)
|
||||||
|
{
|
||||||
|
return Result<T>(std::move(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Result<void> Ok()
|
||||||
|
{
|
||||||
|
return Result<void>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> Result<T> Err(Error error)
|
||||||
|
{
|
||||||
|
return Result<T>(std::move(error));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> Result<T> Err(error_code code)
|
||||||
|
{
|
||||||
|
return Result<T>(Error(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> Result<T> Err(error_code code, std::string message)
|
||||||
|
{
|
||||||
|
return Result<T>(Error(code, std::move(message)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> Result<T> Err(error_code code, std::string message, std::string context)
|
||||||
|
{
|
||||||
|
return Result<T>(Error(code, std::move(message), std::move(context)));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace clrsync::core
|
||||||
|
|
||||||
|
#endif // CLRSYNC_CORE_ERROR_HPP
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include <iostream>
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ void print_color_keys()
|
|||||||
|
|
||||||
std::string get_default_config_path()
|
std::string get_default_config_path()
|
||||||
{
|
{
|
||||||
const char* env_path = std::getenv("CLRSYNC_CONFIG_PATH");
|
const char *env_path = std::getenv("CLRSYNC_CONFIG_PATH");
|
||||||
if (env_path && env_path[0] != '\0')
|
if (env_path && env_path[0] != '\0')
|
||||||
return normalize_path(env_path).string();
|
return normalize_path(env_path).string();
|
||||||
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef CLRSYNC_CORE_UTILS_HPP
|
#ifndef CLRSYNC_CORE_UTILS_HPP
|
||||||
#define CLRSYNC_CORE_UTILS_HPP
|
#define CLRSYNC_CORE_UTILS_HPP
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <core/palette/color_keys.hpp>
|
#include "core/palette/color_keys.hpp"
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "version.hpp"
|
#include "core/common/version.hpp"
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::string GIT_SEMVER = "0.1.4+git.g92b06a9";
|
const std::string GIT_SEMVER = "1.0.5+git.g2d015c6";
|
||||||
|
|
||||||
const std::string version_string();
|
const std::string version_string();
|
||||||
} // namespace clrsync::core
|
} // namespace clrsync::core
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "core/utils.hpp"
|
#include "core/common/error.hpp"
|
||||||
#include "core/error.hpp"
|
#include "core/common/utils.hpp"
|
||||||
|
#include "core/io/toml_file.hpp"
|
||||||
|
|
||||||
#include <core/palette/color.hpp>
|
#include "core/palette/color.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@@ -28,7 +29,39 @@ Result<void> config::initialize(std::unique_ptr<clrsync::core::io::file> file)
|
|||||||
|
|
||||||
auto parse_result = m_file->parse();
|
auto parse_result = m_file->parse();
|
||||||
if (!parse_result)
|
if (!parse_result)
|
||||||
return Err<void>(error_code::config_invalid, parse_result.error().message, parse_result.error().context);
|
return Err<void>(error_code::config_invalid, parse_result.error().message,
|
||||||
|
parse_result.error().context);
|
||||||
|
|
||||||
|
std::filesystem::path config_path = get_user_config_dir() / "config.toml";
|
||||||
|
std::filesystem::path temp_config_path = get_user_config_dir() / "config-temp.toml";
|
||||||
|
|
||||||
|
if (std::filesystem::exists(config_path))
|
||||||
|
{
|
||||||
|
std::error_code ec;
|
||||||
|
auto perms = std::filesystem::status(config_path, ec).permissions();
|
||||||
|
|
||||||
|
if (ec || (perms & std::filesystem::perms::owner_write) == std::filesystem::perms::none)
|
||||||
|
{
|
||||||
|
m_temp_config_path = temp_config_path.string();
|
||||||
|
|
||||||
|
if (std::filesystem::exists(temp_config_path))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto temp_conf = std::make_unique<clrsync::core::io::toml_file>(temp_config_path.string());
|
||||||
|
auto temp_parse = temp_conf->parse();
|
||||||
|
if (temp_parse)
|
||||||
|
{
|
||||||
|
m_temp_file = std::move(temp_conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
std::cerr << "Warning: Failed to load temp config: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
@@ -39,6 +72,30 @@ std::filesystem::path config::get_user_config_dir()
|
|||||||
return home / ".config" / "clrsync";
|
return home / ".config" / "clrsync";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::filesystem::path config::get_user_state_dir()
|
||||||
|
{
|
||||||
|
std::filesystem::path home = normalize_path("~");
|
||||||
|
return home / ".local" / "state" / "clrsync";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path config::get_writable_config_path()
|
||||||
|
{
|
||||||
|
std::filesystem::path config_path = get_user_config_dir() / "config.toml";
|
||||||
|
|
||||||
|
if (std::filesystem::exists(config_path))
|
||||||
|
{
|
||||||
|
std::error_code ec;
|
||||||
|
auto perms = std::filesystem::status(config_path, ec).permissions();
|
||||||
|
|
||||||
|
if (ec || (perms & std::filesystem::perms::owner_write) == std::filesystem::perms::none)
|
||||||
|
{
|
||||||
|
return get_user_config_dir() / "config-temp.toml";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config_path;
|
||||||
|
}
|
||||||
|
|
||||||
std::filesystem::path config::get_data_dir()
|
std::filesystem::path config::get_data_dir()
|
||||||
{
|
{
|
||||||
if (std::filesystem::exists(CLRSYNC_DATADIR))
|
if (std::filesystem::exists(CLRSYNC_DATADIR))
|
||||||
@@ -134,15 +191,50 @@ void config::copy_default_configs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<void> config::save_config_value(const std::string §ion, const std::string &key, const value_type &value)
|
||||||
|
{
|
||||||
|
if (!m_temp_config_path.empty())
|
||||||
|
{
|
||||||
|
if (!m_temp_file)
|
||||||
|
{
|
||||||
|
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
|
||||||
|
(void)m_temp_file->parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_temp_file->set_value(section, key, value);
|
||||||
|
return m_temp_file->save_file();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_file->set_value(section, key, value);
|
||||||
|
return m_file->save_file();
|
||||||
|
}
|
||||||
|
|
||||||
const std::string &config::palettes_path()
|
const std::string &config::palettes_path()
|
||||||
{
|
{
|
||||||
if (m_palettes_dir.empty() && m_file)
|
if (m_palettes_dir.empty() && m_file)
|
||||||
|
{
|
||||||
|
if (m_temp_file)
|
||||||
|
{
|
||||||
|
auto temp_value = m_temp_file->get_string_value("general", "palettes_path");
|
||||||
|
if (!temp_value.empty())
|
||||||
|
{
|
||||||
|
m_palettes_dir = temp_value;
|
||||||
|
return m_palettes_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
m_palettes_dir = m_file->get_string_value("general", "palettes_path");
|
m_palettes_dir = m_file->get_string_value("general", "palettes_path");
|
||||||
|
}
|
||||||
return m_palettes_dir;
|
return m_palettes_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string config::default_theme() const
|
const std::string config::default_theme() const
|
||||||
{
|
{
|
||||||
|
if (m_temp_file)
|
||||||
|
{
|
||||||
|
auto temp_value = m_temp_file->get_string_value("general", "default_theme");
|
||||||
|
if (!temp_value.empty())
|
||||||
|
return temp_value;
|
||||||
|
}
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->get_string_value("general", "default_theme");
|
return m_file->get_string_value("general", "default_theme");
|
||||||
return {};
|
return {};
|
||||||
@@ -150,6 +242,12 @@ const std::string config::default_theme() const
|
|||||||
|
|
||||||
const std::string config::font() const
|
const std::string config::font() const
|
||||||
{
|
{
|
||||||
|
if (m_temp_file)
|
||||||
|
{
|
||||||
|
auto temp_value = m_temp_file->get_string_value("general", "font");
|
||||||
|
if (!temp_value.empty())
|
||||||
|
return temp_value;
|
||||||
|
}
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->get_string_value("general", "font");
|
return m_file->get_string_value("general", "font");
|
||||||
return {};
|
return {};
|
||||||
@@ -157,6 +255,12 @@ const std::string config::font() const
|
|||||||
|
|
||||||
const uint32_t config::font_size() const
|
const uint32_t config::font_size() const
|
||||||
{
|
{
|
||||||
|
if (m_temp_file)
|
||||||
|
{
|
||||||
|
auto temp_value = m_temp_file->get_uint_value("general", "font_size");
|
||||||
|
if (temp_value != 0)
|
||||||
|
return temp_value;
|
||||||
|
}
|
||||||
if (m_file)
|
if (m_file)
|
||||||
return m_file->get_uint_value("general", "font_size");
|
return m_file->get_uint_value("general", "font_size");
|
||||||
return 14;
|
return 14;
|
||||||
@@ -167,8 +271,7 @@ Result<void> config::set_default_theme(const std::string &theme)
|
|||||||
if (!m_file)
|
if (!m_file)
|
||||||
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
||||||
|
|
||||||
m_file->set_value("general", "default_theme", theme);
|
return save_config_value("general", "default_theme", theme);
|
||||||
return m_file->save_file();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> config::set_palettes_path(const std::string &path)
|
Result<void> config::set_palettes_path(const std::string &path)
|
||||||
@@ -176,8 +279,7 @@ Result<void> config::set_palettes_path(const std::string &path)
|
|||||||
if (!m_file)
|
if (!m_file)
|
||||||
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
||||||
|
|
||||||
m_file->set_value("general", "palettes_path", path);
|
return save_config_value("general", "palettes_path", path);
|
||||||
return m_file->save_file();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> config::set_font(const std::string &font)
|
Result<void> config::set_font(const std::string &font)
|
||||||
@@ -185,16 +287,14 @@ Result<void> config::set_font(const std::string &font)
|
|||||||
if (!m_file)
|
if (!m_file)
|
||||||
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
||||||
|
|
||||||
m_file->set_value("general", "font", font);
|
return save_config_value("general", "font", font);
|
||||||
return m_file->save_file();
|
|
||||||
}
|
}
|
||||||
Result<void> config::set_font_size(int font_size)
|
Result<void> config::set_font_size(int font_size)
|
||||||
{
|
{
|
||||||
if (!m_file)
|
if (!m_file)
|
||||||
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
||||||
|
|
||||||
m_file->set_value("general", "font_size", font_size);
|
return save_config_value("general", "font_size", static_cast<uint32_t>(font_size));
|
||||||
return m_file->save_file();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> config::update_template(const std::string &key,
|
Result<void> config::update_template(const std::string &key,
|
||||||
@@ -204,11 +304,17 @@ Result<void> config::update_template(const std::string &key,
|
|||||||
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
return Err<void>(error_code::config_missing, "Configuration not initialized");
|
||||||
|
|
||||||
m_themes[key] = theme_template;
|
m_themes[key] = theme_template;
|
||||||
m_file->set_value("templates." + key, "input_path", theme_template.template_path());
|
|
||||||
m_file->set_value("templates." + key, "output_path", theme_template.output_path());
|
auto result1 = save_config_value("templates." + key, "input_path", theme_template.template_path());
|
||||||
m_file->set_value("templates." + key, "enabled", theme_template.enabled());
|
if (!result1) return result1;
|
||||||
m_file->set_value("templates." + key, "reload_cmd", theme_template.reload_command());
|
|
||||||
return m_file->save_file();
|
auto result2 = save_config_value("templates." + key, "output_path", theme_template.output_path());
|
||||||
|
if (!result2) return result2;
|
||||||
|
|
||||||
|
auto result3 = save_config_value("templates." + key, "enabled", theme_template.enabled());
|
||||||
|
if (!result3) return result3;
|
||||||
|
|
||||||
|
return save_config_value("templates." + key, "reload_cmd", theme_template.reload_command());
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> config::remove_template(const std::string &key)
|
Result<void> config::remove_template(const std::string &key)
|
||||||
@@ -223,17 +329,31 @@ Result<void> config::remove_template(const std::string &key)
|
|||||||
std::filesystem::path template_file = it->second.template_path();
|
std::filesystem::path template_file = it->second.template_path();
|
||||||
if (std::filesystem::exists(template_file))
|
if (std::filesystem::exists(template_file))
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
std::filesystem::remove(template_file);
|
std::filesystem::remove(template_file);
|
||||||
} catch (const std::exception& e) {
|
}
|
||||||
return Err<void>(error_code::file_write_failed, "Failed to delete template file", e.what());
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
return Err<void>(error_code::file_write_failed, "Failed to delete template file",
|
||||||
|
e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_themes.erase(it);
|
m_themes.erase(it);
|
||||||
|
|
||||||
m_file->remove_section("templates." + key);
|
if (!m_temp_config_path.empty())
|
||||||
|
{
|
||||||
|
if (!m_temp_file)
|
||||||
|
{
|
||||||
|
m_temp_file = std::make_unique<clrsync::core::io::toml_file>(m_temp_config_path);
|
||||||
|
(void)m_temp_file->parse();
|
||||||
|
}
|
||||||
|
m_temp_file->remove_section("templates." + key);
|
||||||
|
return m_temp_file->save_file();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_file->remove_section("templates." + key);
|
||||||
return m_file->save_file();
|
return m_file->save_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,14 +384,16 @@ const std::unordered_map<std::string, clrsync::core::theme_template> config::tem
|
|||||||
return m_themes;
|
return m_themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<const clrsync::core::theme_template*> config::template_by_name(const std::string &name) const
|
Result<const clrsync::core::theme_template *> config::template_by_name(
|
||||||
|
const std::string &name) const
|
||||||
{
|
{
|
||||||
auto it = m_themes.find(name);
|
auto it = m_themes.find(name);
|
||||||
if (it != m_themes.end())
|
if (it != m_themes.end())
|
||||||
{
|
{
|
||||||
return Ok(&it->second);
|
return Ok(&it->second);
|
||||||
}
|
}
|
||||||
return Err<const clrsync::core::theme_template*>(error_code::template_not_found, "Template not found", name);
|
return Err<const clrsync::core::theme_template *>(error_code::template_not_found,
|
||||||
|
"Template not found", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace clrsync::core
|
} // namespace clrsync::core
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef CLRSYNC_CORE_CONFIG_HPP
|
#ifndef CLRSYNC_CORE_CONFIG_HPP
|
||||||
#define CLRSYNC_CORE_CONFIG_HPP
|
#define CLRSYNC_CORE_CONFIG_HPP
|
||||||
|
|
||||||
#include <core/io/file.hpp>
|
#include "core/common/error.hpp"
|
||||||
#include <core/theme/theme_template.hpp>
|
#include "core/io/file.hpp"
|
||||||
#include <core/error.hpp>
|
#include "core/theme/theme_template.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -22,9 +22,10 @@ class config
|
|||||||
const std::string &palettes_path();
|
const std::string &palettes_path();
|
||||||
const std::string default_theme() const;
|
const std::string default_theme() const;
|
||||||
const std::unordered_map<std::string, clrsync::core::theme_template> templates();
|
const std::unordered_map<std::string, clrsync::core::theme_template> templates();
|
||||||
Result<const clrsync::core::theme_template*> template_by_name(const std::string &name) const;
|
Result<const clrsync::core::theme_template *> template_by_name(const std::string &name) const;
|
||||||
std::filesystem::path get_user_config_dir();
|
std::filesystem::path get_user_config_dir();
|
||||||
|
std::filesystem::path get_user_state_dir();
|
||||||
|
std::filesystem::path get_writable_config_path();
|
||||||
|
|
||||||
Result<void> set_default_theme(const std::string &theme);
|
Result<void> set_default_theme(const std::string &theme);
|
||||||
Result<void> set_palettes_path(const std::string &path);
|
Result<void> set_palettes_path(const std::string &path);
|
||||||
@@ -43,9 +44,12 @@ class config
|
|||||||
|
|
||||||
std::string m_palettes_dir{};
|
std::string m_palettes_dir{};
|
||||||
std::unique_ptr<io::file> m_file;
|
std::unique_ptr<io::file> m_file;
|
||||||
|
std::unique_ptr<io::file> m_temp_file;
|
||||||
|
std::string m_temp_config_path;
|
||||||
std::unordered_map<std::string, theme_template> m_themes{};
|
std::unordered_map<std::string, theme_template> m_themes{};
|
||||||
static void copy_file(const std::filesystem::path& src, const std::filesystem::path& dst);
|
Result<void> save_config_value(const std::string §ion, const std::string &key, const value_type &value);
|
||||||
static void copy_dir(const std::filesystem::path& src, const std::filesystem::path& dst);
|
static void copy_file(const std::filesystem::path &src, const std::filesystem::path &dst);
|
||||||
|
static void copy_dir(const std::filesystem::path &src, const std::filesystem::path &dst);
|
||||||
void copy_default_configs();
|
void copy_default_configs();
|
||||||
};
|
};
|
||||||
} // namespace clrsync::core
|
} // namespace clrsync::core
|
||||||
|
|||||||
@@ -1,207 +0,0 @@
|
|||||||
#ifndef CLRSYNC_CORE_ERROR_HPP
|
|
||||||
#define CLRSYNC_CORE_ERROR_HPP
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <variant>
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
namespace clrsync::core
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class error_code
|
|
||||||
{
|
|
||||||
unknown,
|
|
||||||
|
|
||||||
file_not_found,
|
|
||||||
file_open_failed,
|
|
||||||
file_write_failed,
|
|
||||||
file_read_failed,
|
|
||||||
dir_create_failed,
|
|
||||||
|
|
||||||
parse_failed,
|
|
||||||
invalid_format,
|
|
||||||
|
|
||||||
config_missing,
|
|
||||||
config_invalid,
|
|
||||||
|
|
||||||
template_not_found,
|
|
||||||
template_load_failed,
|
|
||||||
template_apply_failed,
|
|
||||||
|
|
||||||
palette_not_found,
|
|
||||||
palette_load_failed,
|
|
||||||
|
|
||||||
init_failed,
|
|
||||||
invalid_arg,
|
|
||||||
resource_missing,
|
|
||||||
};
|
|
||||||
|
|
||||||
inline const char* error_code_string(error_code code)
|
|
||||||
{
|
|
||||||
switch (code)
|
|
||||||
{
|
|
||||||
case error_code::unknown: return "Unknown error";
|
|
||||||
case error_code::file_not_found: return "File not found";
|
|
||||||
case error_code::file_open_failed: return "Failed to open file";
|
|
||||||
case error_code::file_write_failed: return "Failed to write file";
|
|
||||||
case error_code::file_read_failed: return "Failed to read file";
|
|
||||||
case error_code::dir_create_failed: return "Failed to create directory";
|
|
||||||
case error_code::parse_failed: return "Parse failed";
|
|
||||||
case error_code::invalid_format: return "Invalid format";
|
|
||||||
case error_code::config_missing: return "Configuration missing";
|
|
||||||
case error_code::config_invalid: return "Configuration invalid";
|
|
||||||
case error_code::template_not_found: return "Template not found";
|
|
||||||
case error_code::template_load_failed: return "Failed to load template";
|
|
||||||
case error_code::template_apply_failed: return "Failed to apply template";
|
|
||||||
case error_code::palette_not_found: return "Palette not found";
|
|
||||||
case error_code::palette_load_failed: return "Failed to load palette";
|
|
||||||
case error_code::init_failed: return "Initialization failed";
|
|
||||||
case error_code::invalid_arg: return "Invalid argument";
|
|
||||||
case error_code::resource_missing: return "Resource missing";
|
|
||||||
default: return "Unknown error code";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Error
|
|
||||||
{
|
|
||||||
error_code code;
|
|
||||||
std::string message;
|
|
||||||
std::string context;
|
|
||||||
|
|
||||||
Error(error_code c) : code(c), message(error_code_string(c)) {}
|
|
||||||
|
|
||||||
Error(error_code c, std::string msg)
|
|
||||||
: code(c), message(std::move(msg)) {}
|
|
||||||
|
|
||||||
Error(error_code c, std::string msg, std::string ctx)
|
|
||||||
: code(c), message(std::move(msg)), context(std::move(ctx)) {}
|
|
||||||
|
|
||||||
std::string description() const
|
|
||||||
{
|
|
||||||
if (context.empty())
|
|
||||||
return message;
|
|
||||||
return message + " [" + context + "]";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class [[nodiscard]] Result
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::variant<T, Error> m_data;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Result(T value) : m_data(std::move(value)) {}
|
|
||||||
|
|
||||||
Result(Error error) : m_data(std::move(error)) {}
|
|
||||||
|
|
||||||
bool is_ok() const { return std::holds_alternative<T>(m_data); }
|
|
||||||
|
|
||||||
bool is_error() const { return std::holds_alternative<Error>(m_data); }
|
|
||||||
|
|
||||||
explicit operator bool() const { return is_ok(); }
|
|
||||||
|
|
||||||
T& value() & { return std::get<T>(m_data); }
|
|
||||||
const T& value() const & { return std::get<T>(m_data); }
|
|
||||||
T&& value() && { return std::get<T>(std::move(m_data)); }
|
|
||||||
|
|
||||||
const Error& error() const { return std::get<Error>(m_data); }
|
|
||||||
|
|
||||||
T value_or(T default_value) const
|
|
||||||
{
|
|
||||||
return is_ok() ? std::get<T>(m_data) : std::move(default_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<T> ok() const
|
|
||||||
{
|
|
||||||
if (is_ok())
|
|
||||||
return std::get<T>(m_data);
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<Error> err() const
|
|
||||||
{
|
|
||||||
if (is_error())
|
|
||||||
return std::get<Error>(m_data);
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename F>
|
|
||||||
auto map(F&& func) -> Result<decltype(func(std::declval<T>()))>
|
|
||||||
{
|
|
||||||
using U = decltype(func(std::declval<T>()));
|
|
||||||
if (is_ok())
|
|
||||||
return Result<U>(func(std::get<T>(m_data)));
|
|
||||||
return Result<U>(std::get<Error>(m_data));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename F>
|
|
||||||
auto and_then(F&& func) -> decltype(func(std::declval<T>()))
|
|
||||||
{
|
|
||||||
if (is_ok())
|
|
||||||
return func(std::get<T>(m_data));
|
|
||||||
using ResultType = decltype(func(std::declval<T>()));
|
|
||||||
return ResultType(std::get<Error>(m_data));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class [[nodiscard]] Result<void>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::optional<Error> m_error;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Result() : m_error(std::nullopt) {}
|
|
||||||
|
|
||||||
Result(Error error) : m_error(std::move(error)) {}
|
|
||||||
|
|
||||||
bool is_ok() const { return !m_error.has_value(); }
|
|
||||||
|
|
||||||
bool is_error() const { return m_error.has_value(); }
|
|
||||||
|
|
||||||
explicit operator bool() const { return is_ok(); }
|
|
||||||
|
|
||||||
const Error& error() const { return *m_error; }
|
|
||||||
|
|
||||||
std::optional<Error> err() const { return m_error; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
Result<T> Ok(T value)
|
|
||||||
{
|
|
||||||
return Result<T>(std::move(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Result<void> Ok()
|
|
||||||
{
|
|
||||||
return Result<void>();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
Result<T> Err(Error error)
|
|
||||||
{
|
|
||||||
return Result<T>(std::move(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
Result<T> Err(error_code code)
|
|
||||||
{
|
|
||||||
return Result<T>(Error(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
Result<T> Err(error_code code, std::string message)
|
|
||||||
{
|
|
||||||
return Result<T>(Error(code, std::move(message)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
Result<T> Err(error_code code, std::string message, std::string context)
|
|
||||||
{
|
|
||||||
return Result<T>(Error(code, std::move(message), std::move(context)));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace clrsync::core
|
|
||||||
|
|
||||||
#endif // CLRSYNC_CORE_ERROR_HPP
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef CLRSYNC_CORE_IO_FILE_HPP
|
#ifndef CLRSYNC_CORE_IO_FILE_HPP
|
||||||
#define CLRSYNC_CORE_IO_FILE_HPP
|
#define CLRSYNC_CORE_IO_FILE_HPP
|
||||||
|
#include "core/common/error.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <core/error.hpp>
|
|
||||||
|
|
||||||
using value_type = std::variant<std::string, uint32_t, int, bool>;
|
using value_type = std::variant<std::string, uint32_t, int, bool>;
|
||||||
|
|
||||||
@@ -16,7 +16,10 @@ class file
|
|||||||
file() = default;
|
file() = default;
|
||||||
file(std::string path) {};
|
file(std::string path) {};
|
||||||
virtual ~file() = default;
|
virtual ~file() = default;
|
||||||
virtual Result<void> parse() { return Ok(); };
|
virtual Result<void> parse()
|
||||||
|
{
|
||||||
|
return Ok();
|
||||||
|
};
|
||||||
virtual const std::string get_string_value(const std::string §ion,
|
virtual const std::string get_string_value(const std::string §ion,
|
||||||
const std::string &key) const
|
const std::string &key) const
|
||||||
{
|
{
|
||||||
@@ -42,7 +45,10 @@ class file
|
|||||||
virtual void insert_or_update_value(const std::string §ion, const std::string &key,
|
virtual void insert_or_update_value(const std::string §ion, const std::string &key,
|
||||||
const value_type &value) {};
|
const value_type &value) {};
|
||||||
virtual void remove_section(const std::string §ion) {};
|
virtual void remove_section(const std::string §ion) {};
|
||||||
virtual Result<void> save_file() { return Ok(); };
|
virtual Result<void> save_file()
|
||||||
|
{
|
||||||
|
return Ok();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} // namespace clrsync::core::io
|
} // namespace clrsync::core::io
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "toml_file.hpp"
|
#include "core/io/toml_file.hpp"
|
||||||
#include "core/utils.hpp"
|
#include "core/common/utils.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -113,9 +113,12 @@ void toml_file::remove_section(const std::string §ion)
|
|||||||
|
|
||||||
Result<void> toml_file::save_file()
|
Result<void> toml_file::save_file()
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
std::filesystem::create_directories(std::filesystem::path(m_path).parent_path());
|
std::filesystem::create_directories(std::filesystem::path(m_path).parent_path());
|
||||||
} catch (const std::exception& e) {
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
return Err<void>(error_code::dir_create_failed, e.what(), m_path);
|
return Err<void>(error_code::dir_create_failed, e.what(), m_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CLRSYNC_CORE_IO_TOML_FILE_HPP
|
#ifndef CLRSYNC_CORE_IO_TOML_FILE_HPP
|
||||||
#define CLRSYNC_CORE_IO_TOML_FILE_HPP
|
#define CLRSYNC_CORE_IO_TOML_FILE_HPP
|
||||||
#include <core/io/file.hpp>
|
#include "core/common/error.hpp"
|
||||||
#include <core/error.hpp>
|
#include "core/io/file.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <toml/toml.hpp>
|
#include <toml/toml.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
@@ -112,14 +111,17 @@ void color::from_hex_string(const std::string &str)
|
|||||||
if (str.empty() || str[0] != '#')
|
if (str.empty() || str[0] != '#')
|
||||||
throw std::invalid_argument("Invalid hex color format");
|
throw std::invalid_argument("Invalid hex color format");
|
||||||
|
|
||||||
if (str.size() == 7) {
|
if (str.size() == 7)
|
||||||
|
{
|
||||||
uint32_t rgb = static_cast<uint32_t>(std::stoul(str.substr(1), nullptr, 16));
|
uint32_t rgb = static_cast<uint32_t>(std::stoul(str.substr(1), nullptr, 16));
|
||||||
m_hex = (rgb << 8) | 0xFF;
|
m_hex = (rgb << 8) | 0xFF;
|
||||||
}
|
}
|
||||||
else if (str.size() == 9) {
|
else if (str.size() == 9)
|
||||||
|
{
|
||||||
m_hex = static_cast<uint32_t>(std::stoul(str.substr(1), nullptr, 16));
|
m_hex = static_cast<uint32_t>(std::stoul(str.substr(1), nullptr, 16));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
throw std::invalid_argument("Invalid hex color format");
|
throw std::invalid_argument("Invalid hex color format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,30 +140,38 @@ const std::string color::to_hex_string_with_alpha() const
|
|||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string color::format(const std::string& field) const
|
std::string color::format(const std::string &field) const
|
||||||
{
|
{
|
||||||
auto rgb = to_rgb();
|
auto rgb = to_rgb();
|
||||||
auto rgba = to_rgba();
|
auto rgba = to_rgba();
|
||||||
auto hslv = to_hsl();
|
auto hslv = to_hsl();
|
||||||
auto hslav = to_hsla();
|
auto hslav = to_hsla();
|
||||||
|
|
||||||
if (field == "hex") return to_hex_string();
|
if (field == "hex")
|
||||||
if (field == "hex_stripped") {
|
return to_hex_string();
|
||||||
|
if (field == "hex_stripped")
|
||||||
|
{
|
||||||
auto s = to_hex_string();
|
auto s = to_hex_string();
|
||||||
return s.substr(1);
|
return s.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field == "hexa") return to_hex_string_with_alpha();
|
if (field == "hexa")
|
||||||
if (field == "hexa_stripped") {
|
return to_hex_string_with_alpha();
|
||||||
|
if (field == "hexa_stripped")
|
||||||
|
{
|
||||||
auto s = to_hex_string_with_alpha();
|
auto s = to_hex_string_with_alpha();
|
||||||
return s.substr(1);
|
return s.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field == "r") return std::to_string(rgb.r);
|
if (field == "r")
|
||||||
if (field == "g") return std::to_string(rgb.g);
|
return std::to_string(rgb.r);
|
||||||
if (field == "b") return std::to_string(rgb.b);
|
if (field == "g")
|
||||||
|
return std::to_string(rgb.g);
|
||||||
|
if (field == "b")
|
||||||
|
return std::to_string(rgb.b);
|
||||||
|
|
||||||
if (field == "a") {
|
if (field == "a")
|
||||||
|
{
|
||||||
float af = rgba.a / 255.0f;
|
float af = rgba.a / 255.0f;
|
||||||
return std::format("{:.2f}", af);
|
return std::format("{:.2f}", af);
|
||||||
}
|
}
|
||||||
@@ -170,9 +180,7 @@ std::string color::format(const std::string& field) const
|
|||||||
return std::format("rgb({},{},{})", rgb.r, rgb.g, rgb.b);
|
return std::format("rgb({},{},{})", rgb.r, rgb.g, rgb.b);
|
||||||
|
|
||||||
if (field == "rgba")
|
if (field == "rgba")
|
||||||
return std::format("rgba({},{},{},{:.2f})",
|
return std::format("rgba({},{},{},{:.2f})", rgba.r, rgba.g, rgba.b, rgba.a / 255.0f);
|
||||||
rgba.r, rgba.g, rgba.b,
|
|
||||||
rgba.a / 255.0f);
|
|
||||||
|
|
||||||
if (field == "h")
|
if (field == "h")
|
||||||
return std::format("{:.0f}", hslv.h);
|
return std::format("{:.0f}", hslv.h);
|
||||||
@@ -186,12 +194,10 @@ std::string color::format(const std::string& field) const
|
|||||||
return std::format("{:.2f}", hslav.a);
|
return std::format("{:.2f}", hslav.a);
|
||||||
|
|
||||||
if (field == "hsl")
|
if (field == "hsl")
|
||||||
return std::format("hsl({:.0f},{:.2f},{:.2f})",
|
return std::format("hsl({:.0f},{:.2f},{:.2f})", hslv.h, hslv.s, hslv.l);
|
||||||
hslv.h, hslv.s, hslv.l);
|
|
||||||
|
|
||||||
if (field == "hsla")
|
if (field == "hsla")
|
||||||
return std::format("hsla({:.0f},{:.2f},{:.2f},{:.2f})",
|
return std::format("hsla({:.0f},{:.2f},{:.2f},{:.2f})", hslav.h, hslav.s, hslav.l, hslav.a);
|
||||||
hslav.h, hslav.s, hslav.l, hslav.a);
|
|
||||||
|
|
||||||
throw std::runtime_error("Unknown color format: " + field);
|
throw std::runtime_error("Unknown color format: " + field);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class color
|
|||||||
|
|
||||||
const std::string to_hex_string_with_alpha() const;
|
const std::string to_hex_string_with_alpha() const;
|
||||||
|
|
||||||
std::string format(const std::string& field) const;
|
std::string format(const std::string &field) const;
|
||||||
|
|
||||||
void set(uint32_t hex);
|
void set(uint32_t hex);
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <unordered_map>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
constexpr const char* COLOR_KEYS[] = {
|
constexpr const char *COLOR_KEYS[] = {
|
||||||
// General UI
|
// General UI
|
||||||
"background",
|
"background",
|
||||||
"on_background",
|
"on_background",
|
||||||
@@ -26,6 +26,7 @@ constexpr const char* COLOR_KEYS[] = {
|
|||||||
|
|
||||||
"cursor",
|
"cursor",
|
||||||
"accent",
|
"accent",
|
||||||
|
"accent_secondary",
|
||||||
|
|
||||||
// Semantic
|
// Semantic
|
||||||
"success",
|
"success",
|
||||||
@@ -77,65 +78,66 @@ constexpr const char* COLOR_KEYS[] = {
|
|||||||
constexpr size_t NUM_COLOR_KEYS = std::size(COLOR_KEYS);
|
constexpr size_t NUM_COLOR_KEYS = std::size(COLOR_KEYS);
|
||||||
|
|
||||||
inline const std::unordered_map<std::string, uint32_t> DEFAULT_COLORS = {
|
inline const std::unordered_map<std::string, uint32_t> DEFAULT_COLORS = {
|
||||||
{"background", 0x1e1e1eff},
|
{"background", 0x111111ff},
|
||||||
{"on_background", 0xd4d4d4ff},
|
{"on_background", 0xd4d4d4ff},
|
||||||
|
|
||||||
{"surface", 0x252526ff},
|
{"surface", 0x111111ff},
|
||||||
{"on_surface", 0xe8e8e8ff},
|
{"on_surface", 0xd4d4d4ff},
|
||||||
|
|
||||||
{"surface_variant", 0x2d2d30ff},
|
{"surface_variant", 0x191919ff},
|
||||||
{"on_surface_variant", 0xccccccff},
|
{"on_surface_variant", 0xd4d4d4ff},
|
||||||
|
|
||||||
{"border_focused", 0x007accff},
|
{"border_focused", 0x2e2e2eff},
|
||||||
{"border", 0x3e3e42ff},
|
{"border", 0x242424ff},
|
||||||
|
|
||||||
{"foreground", 0xccccccff},
|
{"foreground", 0xd2d2d2ff},
|
||||||
|
|
||||||
{"cursor", 0xaeafadff},
|
{"cursor", 0xd2d2d2ff},
|
||||||
{"accent", 0x0e639cff},
|
{"accent", 0x9a8652ff},
|
||||||
|
{"accent_secondary", 0x9a8652ff},
|
||||||
|
|
||||||
{"success", 0x4ec9b0ff},
|
{"success", 0x668a51ff},
|
||||||
{"info", 0x4fc1ffff},
|
{"info", 0x3a898cff},
|
||||||
{"warning", 0xdcdcaaff},
|
{"warning", 0xb47837ff},
|
||||||
{"error", 0xf48771ff},
|
{"error", 0xaa4e4aff},
|
||||||
|
|
||||||
{"on_success", 0x000000ff},
|
{"on_success", 0xd2d2d2ff},
|
||||||
{"on_info", 0x000000ff},
|
{"on_info", 0xd2d2d2ff},
|
||||||
{"on_warning", 0x000000ff},
|
{"on_warning", 0xd2d2d2ff},
|
||||||
{"on_error", 0xffffffff},
|
{"on_error", 0xd2d2d2ff},
|
||||||
|
|
||||||
{"editor_background", 0x1e1e1eff},
|
{"editor_background", 0x111111ff},
|
||||||
{"editor_command", 0xd7ba7dff},
|
{"editor_command", 0x3a898cff},
|
||||||
{"editor_comment", 0x6a9955ff},
|
{"editor_comment", 0x849899ff},
|
||||||
{"editor_disabled", 0x808080ff},
|
{"editor_disabled", 0x849899ff},
|
||||||
{"editor_emphasis", 0x569cd6ff},
|
{"editor_emphasis", 0xa9dc86ff},
|
||||||
{"editor_error", 0xf44747ff},
|
{"editor_error", 0xaa4e4aff},
|
||||||
{"editor_inactive", 0x858585ff},
|
{"editor_inactive", 0x849899ff},
|
||||||
{"editor_line_number", 0x858585ff},
|
{"editor_line_number", 0x849899ff},
|
||||||
{"editor_link", 0x3794ffff},
|
{"editor_link", 0xb0779eff},
|
||||||
{"editor_main", 0xd4d4d4ff},
|
{"editor_main", 0xd2d2d2ff},
|
||||||
{"editor_selected", 0x264f78ff},
|
{"editor_selected", 0x242424ff},
|
||||||
{"editor_selection_inactive", 0x3a3d41ff},
|
{"editor_selection_inactive", 0x1d1c1cff},
|
||||||
{"editor_string", 0xce9178ff},
|
{"editor_string", 0x9a8652ff},
|
||||||
{"editor_success", 0x89d185ff},
|
{"editor_success", 0x668a51ff},
|
||||||
{"editor_warning", 0xcca700ff},
|
{"editor_warning", 0xb47837ff},
|
||||||
|
|
||||||
{"base00", 0x181818ff},
|
{"base00", 0x111111ff},
|
||||||
{"base01", 0x282828ff},
|
{"base01", 0x668a51ff},
|
||||||
{"base02", 0x383838ff},
|
{"base02", 0x9a8652ff},
|
||||||
{"base03", 0x585858ff},
|
{"base03", 0xb47837ff},
|
||||||
{"base04", 0xb8b8b8ff},
|
{"base04", 0x9a5552ff},
|
||||||
{"base05", 0xd8d8d8ff},
|
{"base05", 0xaa477bff},
|
||||||
{"base06", 0xe8e8e8ff},
|
{"base06", 0x3a898cff},
|
||||||
{"base07", 0xf8f8f8ff},
|
{"base07", 0xb5b5b5ff},
|
||||||
{"base08", 0xab4642ff},
|
{"base08", 0xaa4e4aff},
|
||||||
{"base09", 0xdc9656ff},
|
{"base09", 0xa9dc86ff},
|
||||||
{"base0A", 0xf7ca88ff},
|
{"base0A", 0xb6ab82ff},
|
||||||
{"base0B", 0xa1b56cff},
|
{"base0B", 0xc5916bff},
|
||||||
{"base0C", 0x86c1b9ff},
|
{"base0C", 0xac7676ff},
|
||||||
{"base0D", 0x7cafc2ff},
|
{"base0D", 0xb0779eff},
|
||||||
{"base0E", 0xba8bafff},
|
{"base0E", 0x849899ff},
|
||||||
{"base0F", 0xa16946ff},
|
{"base0F", 0xd2d2d2ff},
|
||||||
};
|
};
|
||||||
} // namespace clrsync::core
|
} // namespace clrsync::core
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
19
src/core/palette/generator.hpp
Normal file
19
src/core/palette/generator.hpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef CLRSYNC_CORE_PALETTE_GENERATOR_HPP
|
||||||
|
#define CLRSYNC_CORE_PALETTE_GENERATOR_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "core/palette/palette.hpp"
|
||||||
|
|
||||||
|
namespace clrsync::core
|
||||||
|
{
|
||||||
|
class generator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
generator() = default;
|
||||||
|
virtual ~generator() = default;
|
||||||
|
|
||||||
|
virtual palette generate_from_image(const std::string &image_path) = 0;
|
||||||
|
};
|
||||||
|
} // namespace clrsync::core
|
||||||
|
|
||||||
|
#endif
|
||||||
181
src/core/palette/hellwal_generator.cpp
Normal file
181
src/core/palette/hellwal_generator.cpp
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
#include "hellwal_generator.hpp"
|
||||||
|
|
||||||
|
#include "core/palette/color.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define popen _popen
|
||||||
|
#define pclose _pclose
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace clrsync::core
|
||||||
|
{
|
||||||
|
static std::string run_command_capture_output(const std::string &cmd)
|
||||||
|
{
|
||||||
|
std::array<char, 4096> buffer;
|
||||||
|
std::string result;
|
||||||
|
FILE *pipe = popen(cmd.c_str(), "r");
|
||||||
|
if (!pipe)
|
||||||
|
return {};
|
||||||
|
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe) != nullptr)
|
||||||
|
{
|
||||||
|
result += buffer.data();
|
||||||
|
}
|
||||||
|
int rc = pclose(pipe);
|
||||||
|
(void)rc;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
palette hellwal_generator::generate_from_image(const std::string &image_path)
|
||||||
|
{
|
||||||
|
options default_opts{};
|
||||||
|
return generate_from_image(image_path, default_opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
palette hellwal_generator::generate_from_image(const std::string &image_path, const options &opts)
|
||||||
|
{
|
||||||
|
palette pal;
|
||||||
|
|
||||||
|
std::filesystem::path p(image_path);
|
||||||
|
pal.set_name("hellwal:" + p.filename().string());
|
||||||
|
pal.set_file_path(image_path);
|
||||||
|
|
||||||
|
std::string cmd = "hellwal -i '" + image_path + "' --json";
|
||||||
|
if (opts.neon)
|
||||||
|
cmd += " --neon-mode";
|
||||||
|
if (opts.dark)
|
||||||
|
cmd += " --dark";
|
||||||
|
if (opts.light)
|
||||||
|
cmd += " --light";
|
||||||
|
if (opts.color)
|
||||||
|
cmd += " --color";
|
||||||
|
if (opts.dark_offset > 0.0f)
|
||||||
|
cmd += " --dark-offset " + std::to_string(opts.dark_offset);
|
||||||
|
if (opts.bright_offset > 0.0f)
|
||||||
|
cmd += " --bright-offset " + std::to_string(opts.bright_offset);
|
||||||
|
if (opts.invert)
|
||||||
|
cmd += " --invert";
|
||||||
|
if (opts.gray_scale > 0.0f)
|
||||||
|
cmd += " --gray-scale " + std::to_string(opts.gray_scale);
|
||||||
|
|
||||||
|
std::string out = run_command_capture_output(cmd);
|
||||||
|
if (out.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
std::regex special_re(
|
||||||
|
"\"(background|foreground|cursor|border)\"\\s*:\\s*\"(#[0-9A-Fa-f]{6,8})\"");
|
||||||
|
for (std::sregex_iterator it(out.begin(), out.end(), special_re), end; it != end; ++it)
|
||||||
|
{
|
||||||
|
std::smatch m = *it;
|
||||||
|
std::string key = m[1].str();
|
||||||
|
std::string hex = m[2].str();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
color col;
|
||||||
|
col.from_hex_string(hex);
|
||||||
|
pal.set_color(key, col);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::regex color_re("\"color(\\d{1,2})\"\\s*:\\s*\"(#[0-9A-Fa-f]{6,8})\"");
|
||||||
|
for (std::sregex_iterator it(out.begin(), out.end(), color_re), end; it != end; ++it)
|
||||||
|
{
|
||||||
|
std::smatch m = *it;
|
||||||
|
int idx = std::stoi(m[1].str());
|
||||||
|
if (idx < 0 || idx > 15)
|
||||||
|
continue;
|
||||||
|
std::string hex = m[2].str();
|
||||||
|
|
||||||
|
std::string key = "base0";
|
||||||
|
if (idx < 10)
|
||||||
|
key += std::to_string(idx);
|
||||||
|
else
|
||||||
|
key += static_cast<char>('A' + (idx - 10));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
color col;
|
||||||
|
col.from_hex_string(hex);
|
||||||
|
pal.set_color(key, col);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto get_color_by_index = [&](int idx) -> const color & {
|
||||||
|
std::string key = "base0";
|
||||||
|
if (idx < 10)
|
||||||
|
key += std::to_string(idx);
|
||||||
|
else
|
||||||
|
key += static_cast<char>('A' + (idx - 10));
|
||||||
|
return pal.get_color(key);
|
||||||
|
};
|
||||||
|
|
||||||
|
pal.set_color("base00", get_color_by_index(0));
|
||||||
|
pal.set_color("base01", get_color_by_index(8));
|
||||||
|
pal.set_color("base02", get_color_by_index(8));
|
||||||
|
pal.set_color("base03", get_color_by_index(8));
|
||||||
|
pal.set_color("base04", get_color_by_index(7));
|
||||||
|
pal.set_color("base05", get_color_by_index(7));
|
||||||
|
pal.set_color("base06", get_color_by_index(15));
|
||||||
|
pal.set_color("base07", get_color_by_index(15));
|
||||||
|
pal.set_color("base08", get_color_by_index(1));
|
||||||
|
pal.set_color("base09", get_color_by_index(9));
|
||||||
|
pal.set_color("base0A", get_color_by_index(3));
|
||||||
|
pal.set_color("base0B", get_color_by_index(2));
|
||||||
|
pal.set_color("base0C", get_color_by_index(6));
|
||||||
|
pal.set_color("base0D", get_color_by_index(4));
|
||||||
|
pal.set_color("base0E", get_color_by_index(5));
|
||||||
|
pal.set_color("base0F", get_color_by_index(11));
|
||||||
|
|
||||||
|
pal.set_color("accent", get_color_by_index(4));
|
||||||
|
pal.set_color("accent_secondary", get_color_by_index(6));
|
||||||
|
|
||||||
|
pal.set_color("border", get_color_by_index(8));
|
||||||
|
pal.set_color("border_focused", get_color_by_index(4));
|
||||||
|
|
||||||
|
pal.set_color("error", get_color_by_index(1));
|
||||||
|
pal.set_color("warning", get_color_by_index(3));
|
||||||
|
pal.set_color("success", get_color_by_index(2));
|
||||||
|
pal.set_color("info", get_color_by_index(4));
|
||||||
|
|
||||||
|
pal.set_color("on_error", get_color_by_index(0));
|
||||||
|
pal.set_color("on_warning", get_color_by_index(0));
|
||||||
|
pal.set_color("on_success", get_color_by_index(0));
|
||||||
|
pal.set_color("on_info", get_color_by_index(0));
|
||||||
|
|
||||||
|
pal.set_color("surface", get_color_by_index(0));
|
||||||
|
pal.set_color("surface_variant", get_color_by_index(8));
|
||||||
|
pal.set_color("on_surface", get_color_by_index(7));
|
||||||
|
pal.set_color("on_surface_variant", get_color_by_index(7));
|
||||||
|
pal.set_color("on_background", get_color_by_index(7));
|
||||||
|
|
||||||
|
pal.set_color("editor_background", get_color_by_index(0));
|
||||||
|
pal.set_color("editor_main", get_color_by_index(7));
|
||||||
|
pal.set_color("editor_comment", get_color_by_index(8));
|
||||||
|
pal.set_color("editor_disabled", get_color_by_index(8));
|
||||||
|
pal.set_color("editor_inactive", get_color_by_index(8));
|
||||||
|
pal.set_color("editor_string", get_color_by_index(2));
|
||||||
|
pal.set_color("editor_command", get_color_by_index(5));
|
||||||
|
pal.set_color("editor_emphasis", get_color_by_index(11));
|
||||||
|
pal.set_color("editor_link", get_color_by_index(4));
|
||||||
|
pal.set_color("editor_line_number", get_color_by_index(8));
|
||||||
|
pal.set_color("editor_selected", get_color_by_index(8));
|
||||||
|
pal.set_color("editor_selection_inactive", get_color_by_index(8));
|
||||||
|
pal.set_color("editor_error", get_color_by_index(1));
|
||||||
|
pal.set_color("editor_warning", get_color_by_index(3));
|
||||||
|
pal.set_color("editor_success", get_color_by_index(2));
|
||||||
|
|
||||||
|
return pal;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace clrsync::core
|
||||||
32
src/core/palette/hellwal_generator.hpp
Normal file
32
src/core/palette/hellwal_generator.hpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef CLRSYNC_CORE_PALETTE_HELLWAL_GENERATOR_HPP
|
||||||
|
#define CLRSYNC_CORE_PALETTE_HELLWAL_GENERATOR_HPP
|
||||||
|
|
||||||
|
#include "core/palette/palette.hpp"
|
||||||
|
#include "generator.hpp"
|
||||||
|
|
||||||
|
namespace clrsync::core
|
||||||
|
{
|
||||||
|
class hellwal_generator : public generator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
hellwal_generator() = default;
|
||||||
|
~hellwal_generator() override = default;
|
||||||
|
|
||||||
|
struct options
|
||||||
|
{
|
||||||
|
bool neon = false;
|
||||||
|
bool dark = true;
|
||||||
|
bool light = false;
|
||||||
|
bool color = false;
|
||||||
|
float dark_offset = 0.0f;
|
||||||
|
float bright_offset = 0.0f;
|
||||||
|
bool invert = false;
|
||||||
|
float gray_scale = 0.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
palette generate_from_image(const std::string &image_path) override;
|
||||||
|
palette generate_from_image(const std::string &image_path, const options &opts);
|
||||||
|
};
|
||||||
|
} // namespace clrsync::core
|
||||||
|
|
||||||
|
#endif
|
||||||
226
src/core/palette/matugen_generator.cpp
Normal file
226
src/core/palette/matugen_generator.cpp
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
#include "matugen_generator.hpp"
|
||||||
|
|
||||||
|
#include "core/palette/color.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define popen _popen
|
||||||
|
#define pclose _pclose
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace clrsync::core
|
||||||
|
{
|
||||||
|
static std::string run_command_capture_output(const std::string &cmd)
|
||||||
|
{
|
||||||
|
std::array<char, 4096> buffer;
|
||||||
|
std::string result;
|
||||||
|
FILE *pipe = popen(cmd.c_str(), "r");
|
||||||
|
if (!pipe)
|
||||||
|
return {};
|
||||||
|
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe) != nullptr)
|
||||||
|
{
|
||||||
|
result += buffer.data();
|
||||||
|
}
|
||||||
|
int rc = pclose(pipe);
|
||||||
|
(void)rc;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static palette parse_matugen_output(const std::string &out, const matugen_generator::options &opts,
|
||||||
|
const std::string &pal_name, const std::string &file_path)
|
||||||
|
{
|
||||||
|
if (out.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
auto extract_json_object = [&](const std::string &s,
|
||||||
|
const std::string &obj_key) -> std::string {
|
||||||
|
std::regex re("\"" + obj_key + "\"\\s*:\\s*\\{");
|
||||||
|
std::smatch m;
|
||||||
|
if (!std::regex_search(s, m, re))
|
||||||
|
return {};
|
||||||
|
size_t open_pos = s.find('{', m.position(0));
|
||||||
|
if (open_pos == std::string::npos)
|
||||||
|
return {};
|
||||||
|
size_t i = open_pos + 1;
|
||||||
|
int depth = 1;
|
||||||
|
for (; i < s.size(); ++i)
|
||||||
|
{
|
||||||
|
if (s[i] == '{')
|
||||||
|
++depth;
|
||||||
|
else if (s[i] == '}')
|
||||||
|
{
|
||||||
|
--depth;
|
||||||
|
if (depth == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (depth != 0)
|
||||||
|
return {};
|
||||||
|
return s.substr(open_pos + 1, i - open_pos - 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string mode_section = extract_json_object(out, "colors");
|
||||||
|
std::string target_section;
|
||||||
|
if (!mode_section.empty())
|
||||||
|
{
|
||||||
|
std::string wrapped = std::string("{") + mode_section + std::string("}");
|
||||||
|
target_section = extract_json_object(wrapped, opts.mode);
|
||||||
|
}
|
||||||
|
if (target_section.empty())
|
||||||
|
{
|
||||||
|
target_section = extract_json_object(out, opts.mode);
|
||||||
|
}
|
||||||
|
const std::string &parse_src = (target_section.empty() ? out : target_section);
|
||||||
|
|
||||||
|
std::regex kv_re("\"([a-zA-Z0-9_-]+)\"\\s*:\\s*\"(#?[A-Fa-f0-9]{6,8})\"");
|
||||||
|
|
||||||
|
std::unordered_map<std::string, std::string> clrsync_to_matu = {
|
||||||
|
{"accent", "primary"},
|
||||||
|
{"accent_secondary", "secondary"},
|
||||||
|
{"background", "background"},
|
||||||
|
{"foreground", "on_surface"},
|
||||||
|
{"on_background", "on_background"},
|
||||||
|
|
||||||
|
{"surface", "surface_container"},
|
||||||
|
{"on_surface", "on_surface"},
|
||||||
|
{"surface_variant", "surface_variant"},
|
||||||
|
{"on_surface_variant", "on_surface_variant"},
|
||||||
|
|
||||||
|
{"border", "outline_variant"},
|
||||||
|
{"border_focused", "outline"},
|
||||||
|
{"cursor", "on_surface"},
|
||||||
|
|
||||||
|
{"success", "primary"},
|
||||||
|
{"on_success", "on_primary"},
|
||||||
|
{"info", "tertiary"},
|
||||||
|
{"on_info", "on_tertiary"},
|
||||||
|
{"warning", "secondary"},
|
||||||
|
{"on_warning", "on_secondary"},
|
||||||
|
{"error", "error"},
|
||||||
|
{"on_error", "on_error"},
|
||||||
|
|
||||||
|
{"editor_background", "background"},
|
||||||
|
{"editor_main", "on_surface"},
|
||||||
|
{"editor_comment", "outline"},
|
||||||
|
{"editor_string", "tertiary"},
|
||||||
|
{"editor_emphasis", "primary"},
|
||||||
|
{"editor_command", "secondary"},
|
||||||
|
{"editor_link", "primary_container"},
|
||||||
|
{"editor_error", "error"},
|
||||||
|
{"editor_warning", "secondary"},
|
||||||
|
{"editor_success", "primary"},
|
||||||
|
{"editor_disabled", "outline_variant"},
|
||||||
|
{"editor_inactive", "outline_variant"},
|
||||||
|
{"editor_line_number", "outline"},
|
||||||
|
{"editor_selected", "primary_container"},
|
||||||
|
{"editor_selection_inactive", "surface_container_low"},
|
||||||
|
|
||||||
|
{"base00", "background"},
|
||||||
|
{"base01", "surface_container_lowest"},
|
||||||
|
{"base02", "surface_container_low"},
|
||||||
|
{"base03", "outline_variant"},
|
||||||
|
{"base04", "on_surface_variant"},
|
||||||
|
{"base05", "on_surface"},
|
||||||
|
{"base06", "inverse_on_surface"},
|
||||||
|
{"base07", "surface_bright"},
|
||||||
|
{"base08", "error"},
|
||||||
|
{"base09", "tertiary"},
|
||||||
|
{"base0A", "secondary"},
|
||||||
|
{"base0B", "primary"},
|
||||||
|
{"base0C", "tertiary_container"},
|
||||||
|
{"base0D", "primary_container"},
|
||||||
|
{"base0E", "secondary_container"},
|
||||||
|
{"base0F", "on_primary_container"},
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unordered_map<std::string, std::string> matu_kv_map;
|
||||||
|
auto begin = std::sregex_iterator(parse_src.begin(), parse_src.end(), kv_re);
|
||||||
|
auto endit = std::sregex_iterator();
|
||||||
|
for (auto it = begin; it != endit; ++it)
|
||||||
|
{
|
||||||
|
std::smatch match = *it;
|
||||||
|
std::string key = match[1].str();
|
||||||
|
for (auto &c : key)
|
||||||
|
if (c == '-')
|
||||||
|
c = '_';
|
||||||
|
std::string val = match[2].str();
|
||||||
|
matu_kv_map[key] = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
palette pal;
|
||||||
|
pal.set_name(pal_name);
|
||||||
|
pal.set_file_path(file_path);
|
||||||
|
|
||||||
|
for (const auto &[clrsync_key, matu_key] : clrsync_to_matu)
|
||||||
|
{
|
||||||
|
auto matu_it = matu_kv_map.find(matu_key);
|
||||||
|
if (matu_it == matu_kv_map.end())
|
||||||
|
continue;
|
||||||
|
color col;
|
||||||
|
col.from_hex_string(matu_it->second);
|
||||||
|
pal.set_color(clrsync_key, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pal;
|
||||||
|
}
|
||||||
|
|
||||||
|
palette matugen_generator::generate_from_image(const std::string &image_path)
|
||||||
|
{
|
||||||
|
options default_opts{};
|
||||||
|
return generate_from_image(image_path, default_opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
palette matugen_generator::generate_from_image(const std::string &image_path, const options &opts)
|
||||||
|
{
|
||||||
|
std::filesystem::path p(image_path);
|
||||||
|
std::string cmd = "matugen image '" + image_path + "'";
|
||||||
|
if (!opts.type.empty())
|
||||||
|
cmd += " --type '" + opts.type + "'";
|
||||||
|
if (!opts.mode.empty())
|
||||||
|
cmd += " --mode " + opts.mode;
|
||||||
|
if (opts.contrast != 0.0f)
|
||||||
|
cmd += " --contrast " + std::to_string(opts.contrast);
|
||||||
|
cmd += " --json hex --dry-run";
|
||||||
|
|
||||||
|
|
||||||
|
std::string out = run_command_capture_output(cmd);
|
||||||
|
if (out.empty())
|
||||||
|
return {};
|
||||||
|
return parse_matugen_output(out, opts, std::string("matugen:") + p.filename().string(),
|
||||||
|
image_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
palette matugen_generator::generate_from_color(const std::string &color_hex)
|
||||||
|
{
|
||||||
|
options default_opts{};
|
||||||
|
return generate_from_color(color_hex, default_opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
palette matugen_generator::generate_from_color(const std::string &color_hex, const options &opts)
|
||||||
|
{
|
||||||
|
std::string c = color_hex;
|
||||||
|
if (!c.empty() && c[0] == '#')
|
||||||
|
c = c.substr(1);
|
||||||
|
std::string cmd = "matugen color hex '" + c + "'";
|
||||||
|
if (!opts.type.empty())
|
||||||
|
cmd += " --type '" + opts.type + "'";
|
||||||
|
if (!opts.mode.empty())
|
||||||
|
cmd += " --mode " + opts.mode;
|
||||||
|
if (opts.contrast != 0.0f)
|
||||||
|
cmd += " --contrast " + std::to_string(opts.contrast);
|
||||||
|
cmd += " --json hex --dry-run";
|
||||||
|
|
||||||
|
|
||||||
|
std::string out = run_command_capture_output(cmd);
|
||||||
|
if (out.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return parse_matugen_output(out, opts, std::string("matugen:color:") + color_hex, color_hex);
|
||||||
|
}
|
||||||
|
} // namespace clrsync::core
|
||||||
29
src/core/palette/matugen_generator.hpp
Normal file
29
src/core/palette/matugen_generator.hpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef CLRSYNC_CORE_PALETTE_MATUGEN_GENERATOR_HPP
|
||||||
|
#define CLRSYNC_CORE_PALETTE_MATUGEN_GENERATOR_HPP
|
||||||
|
|
||||||
|
#include "core/palette/palette.hpp"
|
||||||
|
#include "generator.hpp"
|
||||||
|
|
||||||
|
namespace clrsync::core
|
||||||
|
{
|
||||||
|
class matugen_generator : public generator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
matugen_generator() = default;
|
||||||
|
~matugen_generator() override = default;
|
||||||
|
|
||||||
|
struct options
|
||||||
|
{
|
||||||
|
std::string type = "scheme-tonal-spot";
|
||||||
|
std::string mode = "dark";
|
||||||
|
float contrast = 0.0f; // -1..1
|
||||||
|
};
|
||||||
|
|
||||||
|
palette generate_from_image(const std::string &image_path) override;
|
||||||
|
palette generate_from_image(const std::string &image_path, const options &opts);
|
||||||
|
palette generate_from_color(const std::string &color_hex);
|
||||||
|
palette generate_from_color(const std::string &color_hex, const options &opts);
|
||||||
|
};
|
||||||
|
} // namespace clrsync::core
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <core/palette/color.hpp>
|
#include "core/palette/color.hpp"
|
||||||
#include <core/palette/color_keys.hpp>
|
#include "core/palette/color_keys.hpp"
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <core/io/file.hpp>
|
#include "core/io/file.hpp"
|
||||||
#include <core/palette/color_keys.hpp>
|
#include "core/palette/color_keys.hpp"
|
||||||
#include <core/palette/palette.hpp>
|
#include "core/palette/palette.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#ifndef CLRSYNC_CORE_PALETTE_PALETTE_MANAGER_HPP
|
#ifndef CLRSYNC_CORE_PALETTE_PALETTE_MANAGER_HPP
|
||||||
#define CLRSYNC_CORE_PALETTE_PALETTE_MANAGER_HPP
|
#define CLRSYNC_CORE_PALETTE_PALETTE_MANAGER_HPP
|
||||||
|
|
||||||
#include "core/utils.hpp"
|
#include "core/common/utils.hpp"
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <core/config/config.hpp>
|
#include "core/config/config.hpp"
|
||||||
#include <core/palette/palette.hpp>
|
#include "core/palette/palette.hpp"
|
||||||
#include <core/palette/palette_file.hpp>
|
#include "core/palette/palette_file.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
#ifndef CLRSYNC_CORE_THEME_TEMPLATE_MANAGER_HPP
|
#ifndef CLRSYNC_CORE_THEME_TEMPLATE_MANAGER_HPP
|
||||||
#define CLRSYNC_CORE_THEME_TEMPLATE_MANAGER_HPP
|
#define CLRSYNC_CORE_THEME_TEMPLATE_MANAGER_HPP
|
||||||
|
|
||||||
#include <core/config/config.hpp>
|
#include "core/config/config.hpp"
|
||||||
#include <core/theme/theme_template.hpp>
|
#include "core/theme/theme_template.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename FileType>
|
template <typename FileType> class template_manager
|
||||||
class template_manager
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template_manager() = default;
|
template_manager() = default;
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#ifndef CLRSYNC_CORE_THEME_THEME_RENDERER_HPP
|
#ifndef CLRSYNC_CORE_THEME_THEME_RENDERER_HPP
|
||||||
#define CLRSYNC_CORE_THEME_THEME_RENDERER_HPP
|
#define CLRSYNC_CORE_THEME_THEME_RENDERER_HPP
|
||||||
#include <core/config/config.hpp>
|
#include "core/common/error.hpp"
|
||||||
#include <core/palette/palette_manager.hpp>
|
#include "core/config/config.hpp"
|
||||||
#include <core/theme/template_manager.hpp>
|
#include "core/palette/palette_manager.hpp"
|
||||||
#include <core/error.hpp>
|
#include "core/theme/template_manager.hpp"
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
{
|
{
|
||||||
@@ -57,11 +59,15 @@ template <typename FileType> class theme_renderer
|
|||||||
|
|
||||||
if (!tmpl.reload_command().empty())
|
if (!tmpl.reload_command().empty())
|
||||||
{
|
{
|
||||||
int result = std::system(tmpl.reload_command().c_str());
|
std::string cmd = tmpl.reload_command();
|
||||||
|
std::thread([cmd]() {
|
||||||
|
int result = std::system(cmd.c_str());
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Warning: Command " << tmpl.reload_command() << " failed with code " << result << "\n";
|
std::cerr << "Warning: Reload command '" << cmd
|
||||||
|
<< "' failed with code " << result << "\n";
|
||||||
}
|
}
|
||||||
|
}).detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok();
|
return Ok();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "theme_template.hpp"
|
#include "theme_template.hpp"
|
||||||
#include "core/utils.hpp"
|
#include "core/common/utils.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -47,13 +47,15 @@ Result<void> theme_template::load_template()
|
|||||||
{
|
{
|
||||||
if (!std::filesystem::exists(m_template_path))
|
if (!std::filesystem::exists(m_template_path))
|
||||||
{
|
{
|
||||||
return Err<void>(error_code::template_not_found, "Template file is missing", m_template_path);
|
return Err<void>(error_code::template_not_found, "Template file is missing",
|
||||||
|
m_template_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream input(m_template_path, std::ios::binary);
|
std::ifstream input(m_template_path, std::ios::binary);
|
||||||
if (!input)
|
if (!input)
|
||||||
{
|
{
|
||||||
return Err<void>(error_code::template_load_failed, "Failed to open template file", m_template_path);
|
return Err<void>(error_code::template_load_failed, "Failed to open template file",
|
||||||
|
m_template_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_template_data.assign(std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>());
|
m_template_data.assign(std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>());
|
||||||
@@ -64,7 +66,7 @@ void theme_template::apply_palette(const core::palette &palette)
|
|||||||
{
|
{
|
||||||
m_processed_data = m_template_data;
|
m_processed_data = m_template_data;
|
||||||
|
|
||||||
for (const auto& [key, color] : palette.colors())
|
for (const auto &[key, color] : palette.colors())
|
||||||
{
|
{
|
||||||
// simple replacement: {foreground}
|
// simple replacement: {foreground}
|
||||||
replace_all(m_processed_data, "{" + key + "}", color.format("hex"));
|
replace_all(m_processed_data, "{" + key + "}", color.format("hex"));
|
||||||
@@ -96,7 +98,7 @@ Result<void> theme_template::save_output() const
|
|||||||
{
|
{
|
||||||
std::filesystem::create_directories(std::filesystem::path(m_output_path).parent_path());
|
std::filesystem::create_directories(std::filesystem::path(m_output_path).parent_path());
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
return Err<void>(error_code::dir_create_failed, e.what(), m_output_path);
|
return Err<void>(error_code::dir_create_failed, e.what(), m_output_path);
|
||||||
}
|
}
|
||||||
@@ -104,13 +106,15 @@ Result<void> theme_template::save_output() const
|
|||||||
std::ofstream output(m_output_path, std::ios::binary);
|
std::ofstream output(m_output_path, std::ios::binary);
|
||||||
if (!output)
|
if (!output)
|
||||||
{
|
{
|
||||||
return Err<void>(error_code::file_write_failed, "Failed to open output file for writing", m_output_path);
|
return Err<void>(error_code::file_write_failed, "Failed to open output file for writing",
|
||||||
|
m_output_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
output << m_processed_data;
|
output << m_processed_data;
|
||||||
if (!output)
|
if (!output)
|
||||||
{
|
{
|
||||||
return Err<void>(error_code::file_write_failed, "Failed to write to output file", m_output_path);
|
return Err<void>(error_code::file_write_failed, "Failed to write to output file",
|
||||||
|
m_output_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef clrsync_CORE_IO_THEME_TEMPLATE_HPP
|
#ifndef clrsync_CORE_IO_THEME_TEMPLATE_HPP
|
||||||
#define clrsync_CORE_IO_THEME_TEMPLATE_HPP
|
#define clrsync_CORE_IO_THEME_TEMPLATE_HPP
|
||||||
|
|
||||||
#include <core/palette/palette.hpp>
|
#include "core/common/error.hpp"
|
||||||
#include <core/error.hpp>
|
#include "core/palette/palette.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace clrsync::core
|
namespace clrsync::core
|
||||||
|
|||||||
@@ -1,22 +1,52 @@
|
|||||||
set(GUI_SOURCES
|
set(GUI_SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
color_scheme_editor.cpp
|
theme/app_theme.cpp
|
||||||
color_table_renderer.cpp
|
views/color_scheme_editor.cpp
|
||||||
preview_renderer.cpp
|
views/color_table_renderer.cpp
|
||||||
theme_applier.cpp
|
views/preview_renderer.cpp
|
||||||
template_editor.cpp
|
views/template_editor.cpp
|
||||||
palette_controller.cpp
|
views/about_window.cpp
|
||||||
template_controller.cpp
|
views/settings_window.cpp
|
||||||
imgui_helpers.cpp
|
controllers/theme_applier.cpp
|
||||||
imgui_helpers.hpp
|
controllers/palette_controller.cpp
|
||||||
about_window.cpp
|
controllers/template_controller.cpp
|
||||||
settings_window.cpp
|
widgets/colors.cpp
|
||||||
font_loader.cpp
|
widgets/dialogs.cpp
|
||||||
file_browser.cpp
|
widgets/palette_selector.cpp
|
||||||
|
widgets/input_dialog.cpp
|
||||||
|
widgets/action_buttons.cpp
|
||||||
|
widgets/styled_checkbox.cpp
|
||||||
|
widgets/autocomplete.cpp
|
||||||
|
widgets/form_field.cpp
|
||||||
|
widgets/error_message.cpp
|
||||||
|
widgets/settings_buttons.cpp
|
||||||
|
widgets/section_header.cpp
|
||||||
|
widgets/link_button.cpp
|
||||||
|
widgets/centered_text.cpp
|
||||||
|
widgets/validation_message.cpp
|
||||||
|
widgets/template_controls.cpp
|
||||||
|
layout/main_layout.cpp
|
||||||
|
platform/windows/font_loader_windows.cpp
|
||||||
|
platform/linux/font_loader_linux.cpp
|
||||||
|
platform/macos/font_loader_macos.cpp
|
||||||
|
platform/linux/file_browser_linux.cpp
|
||||||
|
platform/windows/file_browser_windows.cpp
|
||||||
${CMAKE_SOURCE_DIR}/lib/color_text_edit/TextEditor.cpp
|
${CMAKE_SOURCE_DIR}/lib/color_text_edit/TextEditor.cpp
|
||||||
|
backend/glfw_opengl.cpp
|
||||||
|
ui_manager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(clrsync_gui ${GUI_SOURCES})
|
if(MACOS)
|
||||||
|
list(APPEND GUI_SOURCES
|
||||||
|
platform/macos/file_browser_macos.mm
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_executable(clrsync_gui WIN32 ${GUI_SOURCES})
|
||||||
|
else()
|
||||||
|
add_executable(clrsync_gui ${GUI_SOURCES})
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(clrsync_gui PRIVATE
|
target_include_directories(clrsync_gui PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/src
|
${CMAKE_SOURCE_DIR}/src
|
||||||
@@ -35,6 +65,9 @@ if(WIN32)
|
|||||||
comdlg32
|
comdlg32
|
||||||
shlwapi
|
shlwapi
|
||||||
)
|
)
|
||||||
|
if (MSVC)
|
||||||
|
target_link_options(clrsync_gui PRIVATE /ENTRY:mainCRTStartup)
|
||||||
|
endif()
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
target_link_libraries(clrsync_gui PRIVATE
|
target_link_libraries(clrsync_gui PRIVATE
|
||||||
clrsync_core
|
clrsync_core
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
#include "about_window.hpp"
|
|
||||||
#include "core/version.hpp"
|
|
||||||
#include "imgui_helpers.hpp"
|
|
||||||
#include "imgui.h"
|
|
||||||
|
|
||||||
about_window::about_window()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void about_window::render(const clrsync::core::palette& pal)
|
|
||||||
{
|
|
||||||
if (!m_visible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
|
|
||||||
|
|
||||||
if (ImGui::Begin("About clrsync", &m_visible, ImGuiWindowFlags_NoResize))
|
|
||||||
{
|
|
||||||
const float window_width = ImGui::GetContentRegionAvail().x;
|
|
||||||
|
|
||||||
ImGui::PushFont(ImGui::GetFont());
|
|
||||||
const char *title = "clrsync";
|
|
||||||
const float title_size = ImGui::CalcTextSize(title).x;
|
|
||||||
ImGui::SetCursorPosX((window_width - title_size) * 0.5f);
|
|
||||||
ImVec4 title_color = palette_utils::get_color(pal, "info", "accent");
|
|
||||||
ImGui::TextColored(title_color, "%s", title);
|
|
||||||
ImGui::PopFont();
|
|
||||||
|
|
||||||
std::string version = "Version " + clrsync::core::version_string();
|
|
||||||
const float version_size = ImGui::CalcTextSize(version.c_str()).x;
|
|
||||||
ImGui::SetCursorPosX((window_width - version_size) * 0.5f);
|
|
||||||
ImVec4 subtitle_color = palette_utils::get_color(pal, "editor_inactive", "foreground");
|
|
||||||
ImGui::TextColored(subtitle_color, "%s", version.c_str());
|
|
||||||
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::Separator();
|
|
||||||
ImGui::Spacing();
|
|
||||||
|
|
||||||
ImGui::TextWrapped("A color scheme management tool.");
|
|
||||||
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::Spacing();
|
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
ImGui::Spacing();
|
|
||||||
|
|
||||||
ImGui::Text("Links:");
|
|
||||||
|
|
||||||
const float button_width = 200.0f;
|
|
||||||
const float spacing = ImGui::GetStyle().ItemSpacing.x;
|
|
||||||
const float total_width = 2.0f * button_width + spacing;
|
|
||||||
ImGui::SetCursorPosX((window_width - total_width) * 0.5f);
|
|
||||||
|
|
||||||
if (ImGui::Button("GitHub Repository", ImVec2(button_width, 0)))
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
system("start https://github.com/obsqrbtz/clrsync");
|
|
||||||
#elif __APPLE__
|
|
||||||
system("open https://github.com/obsqrbtz/clrsync");
|
|
||||||
#else
|
|
||||||
system("xdg-open https://github.com/obsqrbtz/clrsync");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (ImGui::Button("Documentation", ImVec2(button_width, 0)))
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
system("start https://binarygoose.dev/projects/clrsync/overview/");
|
|
||||||
#elif __APPLE__
|
|
||||||
system("open https://binarygoose.dev/projects/clrsync/overview/");
|
|
||||||
#else
|
|
||||||
system("xdg-open https://binarygoose.dev/projects/clrsync/overview/");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::Separator();
|
|
||||||
ImGui::Spacing();
|
|
||||||
|
|
||||||
ImVec4 license_color = palette_utils::get_color(pal, "editor_inactive", "foreground");
|
|
||||||
ImGui::TextColored(license_color, "MIT License");
|
|
||||||
ImGui::TextWrapped(
|
|
||||||
"Copyright (c) 2025 Daniel Dada\n\n"
|
|
||||||
"Permission is hereby granted, free of charge, to any person obtaining a copy "
|
|
||||||
"of this software and associated documentation files (the \"Software\"), to deal "
|
|
||||||
"in the Software without restriction, including without limitation the rights "
|
|
||||||
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell "
|
|
||||||
"copies of the Software, and to permit persons to whom the Software is "
|
|
||||||
"furnished to do so, subject to the following conditions:\n\n"
|
|
||||||
"The above copyright notice and this permission notice shall be included in all "
|
|
||||||
"copies or substantial portions of the Software.");
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#ifndef CLRSYNC_GUI_ABOUT_WINDOW_HPP
|
|
||||||
#define CLRSYNC_GUI_ABOUT_WINDOW_HPP
|
|
||||||
|
|
||||||
#include "core/palette/palette.hpp"
|
|
||||||
|
|
||||||
class about_window
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
about_window();
|
|
||||||
void render(const clrsync::core::palette& pal);
|
|
||||||
void render() { render(m_default_palette); }
|
|
||||||
void show() { m_visible = true; }
|
|
||||||
void hide() { m_visible = false; }
|
|
||||||
bool is_visible() const { return m_visible; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_visible{false};
|
|
||||||
clrsync::core::palette m_default_palette;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CLRSYNC_GUI_ABOUT_WINDOW_HPP
|
|
||||||
37
src/gui/backend/backend.hpp
Normal file
37
src/gui/backend/backend.hpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef CLRSYNC_BACKEND_HPP
|
||||||
|
#define CLRSYNC_BACKEND_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace clrsync::gui::backend{
|
||||||
|
|
||||||
|
struct window_config{
|
||||||
|
std::string title = "clrsync";
|
||||||
|
int width = 1280;
|
||||||
|
int height = 720;
|
||||||
|
bool decorated = true;
|
||||||
|
bool transparent_framebuffer = true;
|
||||||
|
float clear_color[4] = {0.1f, 0.1f, 0.1f, 0.0f};
|
||||||
|
};
|
||||||
|
class backend_interface{
|
||||||
|
public:
|
||||||
|
virtual ~backend_interface() = default;
|
||||||
|
|
||||||
|
virtual bool initialize(const window_config& config) = 0;
|
||||||
|
virtual void shutdown() = 0;
|
||||||
|
virtual bool should_close() const = 0;
|
||||||
|
virtual void begin_frame() = 0;
|
||||||
|
virtual void end_frame() = 0;
|
||||||
|
|
||||||
|
virtual void* get_native_window() const = 0;
|
||||||
|
virtual void* get_graphics_context() const = 0;
|
||||||
|
|
||||||
|
virtual bool init_imgui_backend() = 0;
|
||||||
|
virtual void shutdown_imgui_backend() = 0;
|
||||||
|
virtual void imgui_new_frame() = 0;
|
||||||
|
virtual void imgui_render_draw_data(void* draw_data) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CLRSYNC_BACKEND_HPP
|
||||||
164
src/gui/backend/glfw_opengl.cpp
Normal file
164
src/gui/backend/glfw_opengl.cpp
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
#include "gui/backend/glfw_opengl.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <imgui_impl_glfw.h>
|
||||||
|
#include <imgui_impl_opengl3.h>
|
||||||
|
|
||||||
|
namespace clrsync::gui::backend
|
||||||
|
{
|
||||||
|
|
||||||
|
glfw_opengl_backend::glfw_opengl_backend() = default;
|
||||||
|
|
||||||
|
glfw_opengl_backend::~glfw_opengl_backend()
|
||||||
|
{
|
||||||
|
glfw_opengl_backend::shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfw_opengl_backend::focus_callback(GLFWwindow*, int focused)
|
||||||
|
{
|
||||||
|
glfwSwapInterval(focused ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool glfw_opengl_backend::initialize(const window_config &config)
|
||||||
|
{
|
||||||
|
glfwSetErrorCallback([](int error, const char* description) {
|
||||||
|
std::cerr << "GLFW Error " << error << ": " << description << std::endl;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to initialize GLFW" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||||
|
#else
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
|
#endif
|
||||||
|
glfwWindowHint(GLFW_RESIZABLE,GLFW_TRUE);
|
||||||
|
glfwWindowHint(GLFW_DECORATED, config.decorated ? GLFW_TRUE : GLFW_FALSE);
|
||||||
|
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, config.transparent_framebuffer ? GLFW_TRUE : GLFW_FALSE);
|
||||||
|
|
||||||
|
m_window = glfwCreateWindow(config.width, config.height, config.title.c_str(), nullptr, nullptr);
|
||||||
|
if (!m_window)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to create GLFW window" << std::endl;
|
||||||
|
glfwTerminate();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(m_window);
|
||||||
|
glfwSwapInterval(1);
|
||||||
|
glfwSetWindowFocusCallback(m_window, focus_callback);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfw_opengl_backend::shutdown()
|
||||||
|
{
|
||||||
|
if (m_window)
|
||||||
|
{
|
||||||
|
glfwDestroyWindow(m_window);
|
||||||
|
m_window = nullptr;
|
||||||
|
}
|
||||||
|
glfwTerminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool glfw_opengl_backend::should_close() const
|
||||||
|
{
|
||||||
|
return m_window && glfwWindowShouldClose(m_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfw_opengl_backend::begin_frame()
|
||||||
|
{
|
||||||
|
glfwPollEvents();
|
||||||
|
|
||||||
|
if (m_window)
|
||||||
|
{
|
||||||
|
int display_w, display_h;
|
||||||
|
glfwGetFramebufferSize(m_window, &display_w, &display_h);
|
||||||
|
glViewport(0, 0, display_w, display_h);
|
||||||
|
glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfw_opengl_backend::end_frame()
|
||||||
|
{
|
||||||
|
if (m_window)
|
||||||
|
{
|
||||||
|
glfwSwapBuffers(m_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *glfw_opengl_backend::get_native_window() const
|
||||||
|
{
|
||||||
|
return static_cast<void *>(m_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *glfw_opengl_backend::get_graphics_context() const
|
||||||
|
{
|
||||||
|
return static_cast<void *>(m_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string glfw_opengl_backend::get_glfw_version() const
|
||||||
|
{
|
||||||
|
return glfwGetVersionString();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string glfw_opengl_backend::get_glfw_platform() const
|
||||||
|
{
|
||||||
|
switch (glfwGetPlatform()) {
|
||||||
|
case GLFW_PLATFORM_WAYLAND: return "Wayland";
|
||||||
|
case GLFW_PLATFORM_X11: return "X11";
|
||||||
|
case GLFW_PLATFORM_COCOA: return "Cocoa";
|
||||||
|
case GLFW_PLATFORM_WIN32: return "Win32";
|
||||||
|
default: return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool glfw_opengl_backend::init_imgui_backend()
|
||||||
|
{
|
||||||
|
if (!m_window)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!ImGui_ImplGlfw_InitForOpenGL(m_window, true))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
const char* glsl_version = "#version 150";
|
||||||
|
#else
|
||||||
|
const char* glsl_version = "#version 120";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!ImGui_ImplOpenGL3_Init(glsl_version))
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfw_opengl_backend::shutdown_imgui_backend()
|
||||||
|
{
|
||||||
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
|
ImGui_ImplGlfw_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfw_opengl_backend::imgui_new_frame()
|
||||||
|
{
|
||||||
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
ImGui_ImplGlfw_NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void glfw_opengl_backend::imgui_render_draw_data(void* draw_data)
|
||||||
|
{
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(static_cast<ImDrawData*>(draw_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace clrsync::gui::backend
|
||||||
41
src/gui/backend/glfw_opengl.hpp
Normal file
41
src/gui/backend/glfw_opengl.hpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef CLRSYNC_GLFW_OPENGL_HPP
|
||||||
|
#define CLRSYNC_GLFW_OPENGL_HPP
|
||||||
|
|
||||||
|
#define GL_SILENCE_DEPRECATION
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include "gui/backend/backend.hpp"
|
||||||
|
|
||||||
|
namespace clrsync::gui::backend{
|
||||||
|
|
||||||
|
class glfw_opengl_backend : public backend_interface{
|
||||||
|
public:
|
||||||
|
glfw_opengl_backend();
|
||||||
|
~glfw_opengl_backend();
|
||||||
|
|
||||||
|
bool initialize(const window_config& config) override;
|
||||||
|
void shutdown() override;
|
||||||
|
bool should_close() const override;
|
||||||
|
void begin_frame() override;
|
||||||
|
void end_frame() override;
|
||||||
|
|
||||||
|
void* get_native_window() const override;
|
||||||
|
void* get_graphics_context() const override;
|
||||||
|
|
||||||
|
std::string get_glfw_version() const;
|
||||||
|
std::string get_glfw_platform() const;
|
||||||
|
|
||||||
|
bool init_imgui_backend() override;
|
||||||
|
void shutdown_imgui_backend() override;
|
||||||
|
void imgui_new_frame() override;
|
||||||
|
void imgui_render_draw_data(void* draw_data) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void focus_callback(GLFWwindow* window, int focused);
|
||||||
|
|
||||||
|
GLFWwindow* m_window = nullptr;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CLRSYNC_GLFW_OPENGL_HPP
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
#include "color_scheme_editor.hpp"
|
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_helpers.hpp"
|
|
||||||
#include "template_editor.hpp"
|
|
||||||
#include "settings_window.hpp"
|
|
||||||
#include "theme_applier.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
#include <ranges>
|
|
||||||
|
|
||||||
|
|
||||||
color_scheme_editor::color_scheme_editor()
|
|
||||||
{
|
|
||||||
const auto ¤t = m_controller.current_palette();
|
|
||||||
|
|
||||||
if (!current.colors().empty())
|
|
||||||
{
|
|
||||||
theme_applier::apply_to_imgui(current);
|
|
||||||
m_preview.apply_palette(current);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "WARNING: No palette loaded, skipping theme application\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void color_scheme_editor::notify_palette_changed()
|
|
||||||
{
|
|
||||||
if (m_template_editor)
|
|
||||||
{
|
|
||||||
m_template_editor->apply_current_palette(m_controller.current_palette());
|
|
||||||
}
|
|
||||||
if (m_settings_window)
|
|
||||||
{
|
|
||||||
m_settings_window->set_palette(m_controller.current_palette());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void color_scheme_editor::apply_themes()
|
|
||||||
{
|
|
||||||
const auto ¤t = m_controller.current_palette();
|
|
||||||
theme_applier::apply_to_imgui(current);
|
|
||||||
m_preview.apply_palette(current);
|
|
||||||
notify_palette_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void color_scheme_editor::render_controls_and_colors()
|
|
||||||
{
|
|
||||||
ImGui::Begin("Color Schemes");
|
|
||||||
|
|
||||||
render_controls();
|
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
ImGui::BeginChild("ColorTableContent", ImVec2(0, 0), false);
|
|
||||||
m_color_table.render(m_controller.current_palette(), m_controller,
|
|
||||||
[this]() { apply_themes(); });
|
|
||||||
ImGui::EndChild();
|
|
||||||
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
void color_scheme_editor::render_preview()
|
|
||||||
{
|
|
||||||
ImGui::Begin("Color Preview");
|
|
||||||
|
|
||||||
m_preview.render(m_controller.current_palette());
|
|
||||||
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
void color_scheme_editor::render_controls()
|
|
||||||
{
|
|
||||||
const auto ¤t = m_controller.current_palette();
|
|
||||||
const auto &palettes = m_controller.palettes();
|
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6, 8));
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8, 5));
|
|
||||||
|
|
||||||
ImGui::AlignTextToFramePadding();
|
|
||||||
ImGui::Text("Palette:");
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(200.0f);
|
|
||||||
if (ImGui::BeginCombo("##scheme", current.name().c_str()))
|
|
||||||
{
|
|
||||||
for (const auto &name : palettes | std::views::keys)
|
|
||||||
{
|
|
||||||
const bool selected = current.name() == name;
|
|
||||||
if (ImGui::Selectable(name.c_str(), selected))
|
|
||||||
{
|
|
||||||
m_controller.select_palette(name);
|
|
||||||
apply_themes();
|
|
||||||
}
|
|
||||||
if (selected)
|
|
||||||
ImGui::SetItemDefaultFocus();
|
|
||||||
}
|
|
||||||
ImGui::EndCombo();
|
|
||||||
}
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
ImGui::SetTooltip("Select a color palette to edit");
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8);
|
|
||||||
|
|
||||||
static char new_palette_name_buf[128] = "";
|
|
||||||
if (ImGui::Button(" + New "))
|
|
||||||
{
|
|
||||||
new_palette_name_buf[0] = 0;
|
|
||||||
ImGui::OpenPopup("New Palette");
|
|
||||||
}
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
ImGui::SetTooltip("Create a new palette");
|
|
||||||
|
|
||||||
if (ImGui::BeginPopupModal("New Palette", nullptr, ImGuiWindowFlags_AlwaysAutoResize))
|
|
||||||
{
|
|
||||||
ImGui::Text("Enter a name for the new palette:");
|
|
||||||
ImGui::Spacing();
|
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(250);
|
|
||||||
ImGui::InputTextWithHint("##new_palette_input", "Palette name...", new_palette_name_buf,
|
|
||||||
IM_ARRAYSIZE(new_palette_name_buf));
|
|
||||||
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::Separator();
|
|
||||||
ImGui::Spacing();
|
|
||||||
|
|
||||||
bool can_create = strlen(new_palette_name_buf) > 0;
|
|
||||||
|
|
||||||
if (!can_create)
|
|
||||||
ImGui::BeginDisabled();
|
|
||||||
|
|
||||||
if (ImGui::Button("Create", ImVec2(120, 0)))
|
|
||||||
{
|
|
||||||
m_controller.create_palette(new_palette_name_buf);
|
|
||||||
m_controller.select_palette(new_palette_name_buf);
|
|
||||||
apply_themes();
|
|
||||||
new_palette_name_buf[0] = 0;
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!can_create)
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (ImGui::Button("Cancel", ImVec2(120, 0)))
|
|
||||||
{
|
|
||||||
new_palette_name_buf[0] = 0;
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button(" Save "))
|
|
||||||
{
|
|
||||||
m_controller.save_current_palette();
|
|
||||||
}
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
ImGui::SetTooltip("Save current palette to file");
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
auto error = palette_utils::get_color(current, "error");
|
|
||||||
auto error_hover = ImVec4(error.x * 1.1f, error.y * 1.1f, error.z * 1.1f,
|
|
||||||
error.w);
|
|
||||||
auto error_active = ImVec4(error.x * 0.8f, error.y * 0.8f, error.z * 0.8f,
|
|
||||||
error.w);
|
|
||||||
auto on_error = palette_utils::get_color(current, "on_error");
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Button, error);
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, error_hover);
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, error_active);
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, on_error);
|
|
||||||
if (ImGui::Button(" Delete "))
|
|
||||||
{
|
|
||||||
m_show_delete_confirmation = true;
|
|
||||||
}
|
|
||||||
ImGui::PopStyleColor(4);
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
ImGui::SetTooltip("Delete current palette");
|
|
||||||
|
|
||||||
if (m_show_delete_confirmation)
|
|
||||||
{
|
|
||||||
ImGui::OpenPopup("Delete Palette?");
|
|
||||||
m_show_delete_confirmation = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
palette_utils::render_delete_confirmation_popup("Delete Palette?", current.name(), "palette",
|
|
||||||
current, [this]() {
|
|
||||||
m_controller.delete_current_palette();
|
|
||||||
apply_themes();
|
|
||||||
});
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 16);
|
|
||||||
|
|
||||||
if (ImGui::Button(" Apply Theme "))
|
|
||||||
{
|
|
||||||
m_controller.apply_current_theme();
|
|
||||||
}
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
ImGui::SetTooltip("Apply current palette to all enabled templates");
|
|
||||||
|
|
||||||
ImGui::PopStyleVar(2);
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#ifndef CLRSYNC_GUI_COLOR_SCHEME_EDITOR_HPP
|
|
||||||
#define CLRSYNC_GUI_COLOR_SCHEME_EDITOR_HPP
|
|
||||||
|
|
||||||
#include "palette_controller.hpp"
|
|
||||||
#include "color_table_renderer.hpp"
|
|
||||||
#include "preview_renderer.hpp"
|
|
||||||
|
|
||||||
class template_editor;
|
|
||||||
class settings_window;
|
|
||||||
|
|
||||||
class color_scheme_editor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
color_scheme_editor();
|
|
||||||
|
|
||||||
void render_controls_and_colors();
|
|
||||||
void render_preview();
|
|
||||||
void set_template_editor(template_editor* editor) { m_template_editor = editor; }
|
|
||||||
void set_settings_window(settings_window* window) { m_settings_window = window; }
|
|
||||||
const palette_controller& controller() const { return m_controller; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void render_controls();
|
|
||||||
void apply_themes();
|
|
||||||
void notify_palette_changed();
|
|
||||||
|
|
||||||
palette_controller m_controller;
|
|
||||||
color_table_renderer m_color_table;
|
|
||||||
preview_renderer m_preview;
|
|
||||||
template_editor* m_template_editor{nullptr};
|
|
||||||
settings_window* m_settings_window{nullptr};
|
|
||||||
bool m_show_delete_confirmation{false};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CLRSYNC_GUI_COLOR_SCHEME_EDITOR_HPP
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifndef CLRSYNC_GUI_COLOR_TABLE_RENDERER_HPP
|
|
||||||
#define CLRSYNC_GUI_COLOR_TABLE_RENDERER_HPP
|
|
||||||
|
|
||||||
#include "core/palette/palette.hpp"
|
|
||||||
#include "palette_controller.hpp"
|
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class color_table_renderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using OnColorChangedCallback = std::function<void()>;
|
|
||||||
|
|
||||||
void render(const clrsync::core::palette& palette,
|
|
||||||
palette_controller& controller,
|
|
||||||
const OnColorChangedCallback& on_changed);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void render_color_row(const std::string& name,
|
|
||||||
const clrsync::core::palette& palette,
|
|
||||||
palette_controller& controller,
|
|
||||||
const OnColorChangedCallback& on_changed);
|
|
||||||
|
|
||||||
bool matches_filter(const std::string& name) const;
|
|
||||||
|
|
||||||
char m_filter_text[128] = {0};
|
|
||||||
bool m_show_only_modified{false};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CLRSYNC_GUI_COLOR_TABLE_RENDERER_HPP
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "palette_controller.hpp"
|
#include "gui/controllers/palette_controller.hpp"
|
||||||
#include "core/config/config.hpp"
|
#include "core/config/config.hpp"
|
||||||
#include "core/theme/theme_renderer.hpp"
|
#include "core/theme/theme_renderer.hpp"
|
||||||
|
|
||||||
@@ -13,26 +13,30 @@ palette_controller::palette_controller()
|
|||||||
|
|
||||||
auto default_theme = clrsync::core::config::instance().default_theme();
|
auto default_theme = clrsync::core::config::instance().default_theme();
|
||||||
auto it = m_palettes.find(default_theme);
|
auto it = m_palettes.find(default_theme);
|
||||||
if (it != m_palettes.end()) {
|
if (it != m_palettes.end())
|
||||||
|
{
|
||||||
m_current_palette = it->second;
|
m_current_palette = it->second;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_current_palette = m_palettes.begin()->second;
|
m_current_palette = m_palettes.begin()->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void palette_controller::select_palette(const std::string& name)
|
void palette_controller::select_palette(const std::string &name)
|
||||||
{
|
{
|
||||||
auto it = m_palettes.find(name);
|
auto it = m_palettes.find(name);
|
||||||
if (it != m_palettes.end()) {
|
if (it != m_palettes.end())
|
||||||
|
{
|
||||||
m_current_palette = it->second;
|
m_current_palette = it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void palette_controller::create_palette(const std::string& name)
|
void palette_controller::create_palette(const std::string &name)
|
||||||
{
|
{
|
||||||
clrsync::core::palette new_palette(name);
|
clrsync::core::palette new_palette(name);
|
||||||
|
|
||||||
for (const auto& [key, hex_value] : clrsync::core::DEFAULT_COLORS)
|
for (const auto &[key, hex_value] : clrsync::core::DEFAULT_COLORS)
|
||||||
{
|
{
|
||||||
new_palette.set_color(key, clrsync::core::color(hex_value));
|
new_palette.set_color(key, clrsync::core::color(hex_value));
|
||||||
}
|
}
|
||||||
@@ -57,13 +61,21 @@ void palette_controller::delete_current_palette()
|
|||||||
reload_palettes();
|
reload_palettes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void palette_controller::import_palette(const clrsync::core::palette &pal)
|
||||||
|
{
|
||||||
|
auto dir = clrsync::core::config::instance().palettes_path();
|
||||||
|
m_palette_manager.save_palette_to_file(pal, dir);
|
||||||
|
reload_palettes();
|
||||||
|
m_current_palette = pal;
|
||||||
|
}
|
||||||
|
|
||||||
void palette_controller::apply_current_theme() const
|
void palette_controller::apply_current_theme() const
|
||||||
{
|
{
|
||||||
clrsync::core::theme_renderer<clrsync::core::io::toml_file> theme_renderer;
|
clrsync::core::theme_renderer<clrsync::core::io::toml_file> theme_renderer;
|
||||||
(void)theme_renderer.apply_theme(m_current_palette.name());
|
(void)theme_renderer.apply_theme(m_current_palette.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void palette_controller::set_color(const std::string& key, const clrsync::core::color& color)
|
void palette_controller::set_color(const std::string &key, const clrsync::core::color &color)
|
||||||
{
|
{
|
||||||
m_current_palette.set_color(key, color);
|
m_current_palette.set_color(key, color);
|
||||||
}
|
}
|
||||||
@@ -6,21 +6,29 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class palette_controller {
|
class palette_controller
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
palette_controller();
|
palette_controller();
|
||||||
|
|
||||||
const clrsync::core::palette& current_palette() const { return m_current_palette; }
|
const clrsync::core::palette ¤t_palette() const
|
||||||
const std::unordered_map<std::string, clrsync::core::palette>& palettes() const { return m_palettes; }
|
{
|
||||||
|
return m_current_palette;
|
||||||
|
}
|
||||||
|
const std::unordered_map<std::string, clrsync::core::palette> &palettes() const
|
||||||
|
{
|
||||||
|
return m_palettes;
|
||||||
|
}
|
||||||
|
|
||||||
void select_palette(const std::string& name);
|
void select_palette(const std::string &name);
|
||||||
void create_palette(const std::string& name);
|
void create_palette(const std::string &name);
|
||||||
void save_current_palette();
|
void save_current_palette();
|
||||||
void delete_current_palette();
|
void delete_current_palette();
|
||||||
void apply_current_theme() const;
|
void apply_current_theme() const;
|
||||||
void set_color(const std::string& key, const clrsync::core::color& color);
|
void import_palette(const clrsync::core::palette &pal);
|
||||||
|
void set_color(const std::string &key, const clrsync::core::color &color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reload_palettes();
|
void reload_palettes();
|
||||||
|
|
||||||
clrsync::core::palette_manager<clrsync::core::io::toml_file> m_palette_manager;
|
clrsync::core::palette_manager<clrsync::core::io::toml_file> m_palette_manager;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "template_controller.hpp"
|
#include "gui/controllers/template_controller.hpp"
|
||||||
#include "core/config/config.hpp"
|
#include "core/config/config.hpp"
|
||||||
|
|
||||||
template_controller::template_controller()
|
template_controller::template_controller()
|
||||||
@@ -6,46 +6,52 @@ template_controller::template_controller()
|
|||||||
m_templates = m_template_manager.templates();
|
m_templates = m_template_manager.templates();
|
||||||
}
|
}
|
||||||
|
|
||||||
void template_controller::set_template_enabled(const std::string& key, bool enabled)
|
void template_controller::set_template_enabled(const std::string &key, bool enabled)
|
||||||
{
|
{
|
||||||
auto it = m_templates.find(key);
|
auto it = m_templates.find(key);
|
||||||
if (it != m_templates.end()) {
|
if (it != m_templates.end())
|
||||||
|
{
|
||||||
it->second.set_enabled(enabled);
|
it->second.set_enabled(enabled);
|
||||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void template_controller::set_template_input_path(const std::string& key, const std::string& path)
|
void template_controller::set_template_input_path(const std::string &key, const std::string &path)
|
||||||
{
|
{
|
||||||
auto it = m_templates.find(key);
|
auto it = m_templates.find(key);
|
||||||
if (it != m_templates.end()) {
|
if (it != m_templates.end())
|
||||||
|
{
|
||||||
it->second.set_template_path(path);
|
it->second.set_template_path(path);
|
||||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void template_controller::set_template_output_path(const std::string& key, const std::string& path)
|
void template_controller::set_template_output_path(const std::string &key, const std::string &path)
|
||||||
{
|
{
|
||||||
auto it = m_templates.find(key);
|
auto it = m_templates.find(key);
|
||||||
if (it != m_templates.end()) {
|
if (it != m_templates.end())
|
||||||
|
{
|
||||||
it->second.set_output_path(path);
|
it->second.set_output_path(path);
|
||||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void template_controller::set_template_reload_command(const std::string& key, const std::string& cmd)
|
void template_controller::set_template_reload_command(const std::string &key,
|
||||||
|
const std::string &cmd)
|
||||||
{
|
{
|
||||||
auto it = m_templates.find(key);
|
auto it = m_templates.find(key);
|
||||||
if (it != m_templates.end()) {
|
if (it != m_templates.end())
|
||||||
|
{
|
||||||
it->second.set_reload_command(cmd);
|
it->second.set_reload_command(cmd);
|
||||||
(void)clrsync::core::config::instance().update_template(key, it->second);
|
(void)clrsync::core::config::instance().update_template(key, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool template_controller::remove_template(const std::string& key)
|
bool template_controller::remove_template(const std::string &key)
|
||||||
{
|
{
|
||||||
auto result = clrsync::core::config::instance().remove_template(key);
|
auto result = clrsync::core::config::instance().remove_template(key);
|
||||||
if (result) {
|
if (result)
|
||||||
|
{
|
||||||
m_templates.erase(key);
|
m_templates.erase(key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,29 @@
|
|||||||
#ifndef CLRSYNC_GUI_TEMPLATE_CONTROLLER_HPP
|
#ifndef CLRSYNC_GUI_TEMPLATE_CONTROLLER_HPP
|
||||||
#define CLRSYNC_GUI_TEMPLATE_CONTROLLER_HPP
|
#define CLRSYNC_GUI_TEMPLATE_CONTROLLER_HPP
|
||||||
|
|
||||||
#include "core/theme/theme_template.hpp"
|
|
||||||
#include "core/theme/template_manager.hpp"
|
|
||||||
#include "core/io/toml_file.hpp"
|
#include "core/io/toml_file.hpp"
|
||||||
|
#include "core/theme/template_manager.hpp"
|
||||||
|
#include "core/theme/theme_template.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class template_controller {
|
class template_controller
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
template_controller();
|
template_controller();
|
||||||
[[nodiscard]] const std::unordered_map<std::string, clrsync::core::theme_template>& templates() const { return m_templates; }
|
[[nodiscard]] const std::unordered_map<std::string, clrsync::core::theme_template> &templates()
|
||||||
void set_template_enabled(const std::string& key, bool enabled);
|
const
|
||||||
void set_template_input_path(const std::string& key, const std::string& path);
|
{
|
||||||
void set_template_output_path(const std::string& key, const std::string& path);
|
return m_templates;
|
||||||
void set_template_reload_command(const std::string& key, const std::string& cmd);
|
}
|
||||||
bool remove_template(const std::string& key);
|
void set_template_enabled(const std::string &key, bool enabled);
|
||||||
|
void set_template_input_path(const std::string &key, const std::string &path);
|
||||||
|
void set_template_output_path(const std::string &key, const std::string &path);
|
||||||
|
void set_template_reload_command(const std::string &key, const std::string &cmd);
|
||||||
|
bool remove_template(const std::string &key);
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
clrsync::core::template_manager<clrsync::core::io::toml_file> m_template_manager;
|
clrsync::core::template_manager<clrsync::core::io::toml_file> m_template_manager;
|
||||||
std::unordered_map<std::string, clrsync::core::theme_template> m_templates;
|
std::unordered_map<std::string, clrsync::core::theme_template> m_templates;
|
||||||
};
|
};
|
||||||
53
src/gui/controllers/theme_applier.cpp
Normal file
53
src/gui/controllers/theme_applier.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include "gui/controllers/theme_applier.hpp"
|
||||||
|
#include "gui/theme/app_theme.hpp"
|
||||||
|
|
||||||
|
namespace theme_applier
|
||||||
|
{
|
||||||
|
|
||||||
|
void apply_to_editor(TextEditor &editor, const clrsync::core::palette ¤t)
|
||||||
|
{
|
||||||
|
using namespace clrsync::gui::theme;
|
||||||
|
|
||||||
|
auto get_color_u32 = [&](const std::string &key) -> uint32_t {
|
||||||
|
const auto &col = current.get_color(key);
|
||||||
|
return color_utils::to_imgui_u32(col.hex());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto palette = editor.GetPalette();
|
||||||
|
|
||||||
|
palette[int(TextEditor::PaletteIndex::Default)] = get_color_u32("editor_main");
|
||||||
|
palette[int(TextEditor::PaletteIndex::Keyword)] = get_color_u32("editor_command");
|
||||||
|
palette[int(TextEditor::PaletteIndex::Number)] = get_color_u32("editor_warning");
|
||||||
|
palette[int(TextEditor::PaletteIndex::String)] = get_color_u32("editor_string");
|
||||||
|
palette[int(TextEditor::PaletteIndex::CharLiteral)] = get_color_u32("editor_string");
|
||||||
|
palette[int(TextEditor::PaletteIndex::Punctuation)] = get_color_u32("editor_main");
|
||||||
|
palette[int(TextEditor::PaletteIndex::Preprocessor)] = get_color_u32("editor_emphasis");
|
||||||
|
palette[int(TextEditor::PaletteIndex::Identifier)] = get_color_u32("editor_main");
|
||||||
|
palette[int(TextEditor::PaletteIndex::KnownIdentifier)] = get_color_u32("editor_link");
|
||||||
|
palette[int(TextEditor::PaletteIndex::PreprocIdentifier)] = get_color_u32("editor_link");
|
||||||
|
|
||||||
|
palette[int(TextEditor::PaletteIndex::Comment)] = get_color_u32("editor_comment");
|
||||||
|
palette[int(TextEditor::PaletteIndex::MultiLineComment)] = get_color_u32("editor_comment");
|
||||||
|
|
||||||
|
palette[int(TextEditor::PaletteIndex::Background)] = get_color_u32("editor_background");
|
||||||
|
palette[int(TextEditor::PaletteIndex::Cursor)] = get_color_u32("cursor");
|
||||||
|
|
||||||
|
palette[int(TextEditor::PaletteIndex::Selection)] = get_color_u32("editor_selected");
|
||||||
|
palette[int(TextEditor::PaletteIndex::ErrorMarker)] = get_color_u32("editor_error");
|
||||||
|
palette[int(TextEditor::PaletteIndex::Breakpoint)] = get_color_u32("editor_error");
|
||||||
|
|
||||||
|
palette[int(TextEditor::PaletteIndex::LineNumber)] = get_color_u32("editor_line_number");
|
||||||
|
|
||||||
|
palette[int(TextEditor::PaletteIndex::CurrentLineFill)] = get_color_u32("surface_variant");
|
||||||
|
palette[int(TextEditor::PaletteIndex::CurrentLineFillInactive)] = get_color_u32("surface");
|
||||||
|
palette[int(TextEditor::PaletteIndex::CurrentLineEdge)] = get_color_u32("border_focused");
|
||||||
|
|
||||||
|
editor.SetPalette(palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
void apply_to_imgui(const clrsync::core::palette ¤t)
|
||||||
|
{
|
||||||
|
clrsync::gui::theme::set_theme(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace theme_applier
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
#ifndef CLRSYNC_GUI_THEME_APPLIER_HPP
|
#ifndef CLRSYNC_GUI_THEME_APPLIER_HPP
|
||||||
#define CLRSYNC_GUI_THEME_APPLIER_HPP
|
#define CLRSYNC_GUI_THEME_APPLIER_HPP
|
||||||
|
|
||||||
#include "core/palette/palette.hpp"
|
|
||||||
#include "color_text_edit/TextEditor.h"
|
#include "color_text_edit/TextEditor.h"
|
||||||
|
#include "core/palette/palette.hpp"
|
||||||
|
|
||||||
namespace theme_applier
|
namespace theme_applier
|
||||||
{
|
{
|
||||||
void apply_to_imgui(const clrsync::core::palette& pal);
|
void apply_to_imgui(const clrsync::core::palette &pal);
|
||||||
void apply_to_editor(TextEditor& editor, const clrsync::core::palette& pal);
|
|
||||||
}
|
void apply_to_editor(TextEditor &editor, const clrsync::core::palette &pal);
|
||||||
|
} // namespace theme_applier
|
||||||
|
|
||||||
#endif // CLRSYNC_GUI_THEME_APPLIER_HPP
|
#endif // CLRSYNC_GUI_THEME_APPLIER_HPP
|
||||||
@@ -1,338 +0,0 @@
|
|||||||
#include "file_browser.hpp"
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#include <commdlg.h>
|
|
||||||
#include <shlobj.h>
|
|
||||||
#include <shlwapi.h>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
namespace file_dialogs {
|
|
||||||
|
|
||||||
std::string open_file_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path,
|
|
||||||
const std::vector<std::string>& filters) {
|
|
||||||
OPENFILENAMEA ofn;
|
|
||||||
char file[MAX_PATH] = "";
|
|
||||||
|
|
||||||
std::string filter_str = "All Files (*.*)\0*.*\0";
|
|
||||||
|
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
|
||||||
ofn.lStructSize = sizeof(ofn);
|
|
||||||
ofn.hwndOwner = GetActiveWindow();
|
|
||||||
ofn.lpstrFile = file;
|
|
||||||
ofn.nMaxFile = sizeof(file);
|
|
||||||
ofn.lpstrFilter = filter_str.c_str();
|
|
||||||
ofn.nFilterIndex = 1;
|
|
||||||
ofn.lpstrTitle = title.c_str();
|
|
||||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
|
|
||||||
|
|
||||||
if (!initial_path.empty() && std::filesystem::exists(initial_path)) {
|
|
||||||
std::filesystem::path p(initial_path);
|
|
||||||
if (std::filesystem::is_directory(p)) {
|
|
||||||
ofn.lpstrInitialDir = initial_path.c_str();
|
|
||||||
} else {
|
|
||||||
std::string dir = p.parent_path().string();
|
|
||||||
std::string name = p.filename().string();
|
|
||||||
ofn.lpstrInitialDir = dir.c_str();
|
|
||||||
strncpy(file, name.c_str(), sizeof(file) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetOpenFileNameA(&ofn)) {
|
|
||||||
return std::string(file);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string save_file_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path,
|
|
||||||
const std::vector<std::string>& filters) {
|
|
||||||
OPENFILENAMEA ofn;
|
|
||||||
char file[MAX_PATH] = "";
|
|
||||||
|
|
||||||
std::string filter_str = "All Files\0*.*\0\0";
|
|
||||||
|
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
|
||||||
ofn.lStructSize = sizeof(ofn);
|
|
||||||
ofn.hwndOwner = GetActiveWindow();
|
|
||||||
ofn.lpstrFile = file;
|
|
||||||
ofn.nMaxFile = sizeof(file);
|
|
||||||
ofn.lpstrFilter = filter_str.c_str();
|
|
||||||
ofn.nFilterIndex = 1;
|
|
||||||
ofn.lpstrTitle = title.c_str();
|
|
||||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
|
|
||||||
|
|
||||||
if (!initial_path.empty()) {
|
|
||||||
std::filesystem::path p(initial_path);
|
|
||||||
if (std::filesystem::exists(p) && std::filesystem::is_directory(p)) {
|
|
||||||
ofn.lpstrInitialDir = initial_path.c_str();
|
|
||||||
} else {
|
|
||||||
std::string dir = p.parent_path().string();
|
|
||||||
std::string name = p.filename().string();
|
|
||||||
if (std::filesystem::exists(dir)) {
|
|
||||||
ofn.lpstrInitialDir = dir.c_str();
|
|
||||||
strncpy(file, name.c_str(), sizeof(file) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetSaveFileNameA(&ofn)) {
|
|
||||||
return std::string(file);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string select_folder_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path) {
|
|
||||||
IFileOpenDialog *pFileOpen;
|
|
||||||
|
|
||||||
HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
|
|
||||||
IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
DWORD dwFlags;
|
|
||||||
if (SUCCEEDED(pFileOpen->GetOptions(&dwFlags))) {
|
|
||||||
pFileOpen->SetOptions(dwFlags | FOS_PICKFOLDERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring wtitle(title.begin(), title.end());
|
|
||||||
pFileOpen->SetTitle(wtitle.c_str());
|
|
||||||
|
|
||||||
if (!initial_path.empty() && std::filesystem::exists(initial_path)) {
|
|
||||||
IShellItem *psi = NULL;
|
|
||||||
std::wstring winitial(initial_path.begin(), initial_path.end());
|
|
||||||
hr = SHCreateItemFromParsingName(winitial.c_str(), NULL, IID_IShellItem, (void**)&psi);
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
pFileOpen->SetFolder(psi);
|
|
||||||
psi->Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = pFileOpen->Show(GetActiveWindow());
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
IShellItem *pItem;
|
|
||||||
hr = pFileOpen->GetResult(&pItem);
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
PWSTR pszFilePath;
|
|
||||||
hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
std::wstring wpath(pszFilePath);
|
|
||||||
std::string result(wpath.begin(), wpath.end());
|
|
||||||
CoTaskMemFree(pszFilePath);
|
|
||||||
pItem->Release();
|
|
||||||
pFileOpen->Release();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
pItem->Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pFileOpen->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <Cocoa/Cocoa.h>
|
|
||||||
|
|
||||||
namespace file_dialogs {
|
|
||||||
|
|
||||||
std::string open_file_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path,
|
|
||||||
const std::vector<std::string>& filters) {
|
|
||||||
@autoreleasepool {
|
|
||||||
NSOpenPanel* panel = [NSOpenPanel openPanel];
|
|
||||||
[panel setTitle:[NSString stringWithUTF8String:title.c_str()]];
|
|
||||||
[panel setCanChooseFiles:YES];
|
|
||||||
[panel setCanChooseDirectories:NO];
|
|
||||||
[panel setAllowsMultipleSelection:NO];
|
|
||||||
|
|
||||||
if (!initial_path.empty()) {
|
|
||||||
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:initial_path.c_str()]];
|
|
||||||
[panel setDirectoryURL:url];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([panel runModal] == NSModalResponseOK) {
|
|
||||||
NSURL* url = [[panel URLs] objectAtIndex:0];
|
|
||||||
return std::string([[url path] UTF8String]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string save_file_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path,
|
|
||||||
const std::vector<std::string>& filters) {
|
|
||||||
@autoreleasepool {
|
|
||||||
NSSavePanel* panel = [NSSavePanel savePanel];
|
|
||||||
[panel setTitle:[NSString stringWithUTF8String:title.c_str()]];
|
|
||||||
|
|
||||||
if (!initial_path.empty()) {
|
|
||||||
std::filesystem::path p(initial_path);
|
|
||||||
if (std::filesystem::exists(p.parent_path())) {
|
|
||||||
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:p.parent_path().c_str()]];
|
|
||||||
[panel setDirectoryURL:url];
|
|
||||||
[panel setNameFieldStringValue:[NSString stringWithUTF8String:p.filename().c_str()]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([panel runModal] == NSModalResponseOK) {
|
|
||||||
NSURL* url = [panel URL];
|
|
||||||
return std::string([[url path] UTF8String]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string select_folder_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path) {
|
|
||||||
@autoreleasepool {
|
|
||||||
NSOpenPanel* panel = [NSOpenPanel openPanel];
|
|
||||||
[panel setTitle:[NSString stringWithUTF8String:title.c_str()]];
|
|
||||||
[panel setCanChooseFiles:NO];
|
|
||||||
[panel setCanChooseDirectories:YES];
|
|
||||||
[panel setAllowsMultipleSelection:NO];
|
|
||||||
|
|
||||||
if (!initial_path.empty()) {
|
|
||||||
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:initial_path.c_str()]];
|
|
||||||
[panel setDirectoryURL:url];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([panel runModal] == NSModalResponseOK) {
|
|
||||||
NSURL* url = [[panel URLs] objectAtIndex:0];
|
|
||||||
return std::string([[url path] UTF8String]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
namespace file_dialogs {
|
|
||||||
|
|
||||||
std::string open_file_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path,
|
|
||||||
const std::vector<std::string>& filters) {
|
|
||||||
if (!gtk_init_check(nullptr, nullptr)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget* dialog = gtk_file_chooser_dialog_new(
|
|
||||||
title.c_str(),
|
|
||||||
nullptr,
|
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
||||||
"Cancel", GTK_RESPONSE_CANCEL,
|
|
||||||
"Open", GTK_RESPONSE_ACCEPT,
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
if (!initial_path.empty()) {
|
|
||||||
std::filesystem::path p(initial_path);
|
|
||||||
if (std::filesystem::exists(p)) {
|
|
||||||
if (std::filesystem::is_directory(p)) {
|
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), initial_path.c_str());
|
|
||||||
} else {
|
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), p.parent_path().c_str());
|
|
||||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), p.filename().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string result;
|
|
||||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
|
||||||
char* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
||||||
if (filename) {
|
|
||||||
result = filename;
|
|
||||||
g_free(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string save_file_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path,
|
|
||||||
const std::vector<std::string>& filters) {
|
|
||||||
if (!gtk_init_check(nullptr, nullptr)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget* dialog = gtk_file_chooser_dialog_new(
|
|
||||||
title.c_str(),
|
|
||||||
nullptr,
|
|
||||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
||||||
"Cancel", GTK_RESPONSE_CANCEL,
|
|
||||||
"Save", GTK_RESPONSE_ACCEPT,
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
|
|
||||||
|
|
||||||
if (!initial_path.empty()) {
|
|
||||||
std::filesystem::path p(initial_path);
|
|
||||||
if (std::filesystem::exists(p.parent_path())) {
|
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), p.parent_path().c_str());
|
|
||||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), p.filename().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string result;
|
|
||||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
|
||||||
char* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
||||||
if (filename) {
|
|
||||||
result = filename;
|
|
||||||
g_free(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string select_folder_dialog(const std::string& title,
|
|
||||||
const std::string& initial_path) {
|
|
||||||
if (!gtk_init_check(nullptr, nullptr)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkWidget* dialog = gtk_file_chooser_dialog_new(
|
|
||||||
title.c_str(),
|
|
||||||
nullptr,
|
|
||||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
|
||||||
"Cancel", GTK_RESPONSE_CANCEL,
|
|
||||||
"Select", GTK_RESPONSE_ACCEPT,
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
if (!initial_path.empty() && std::filesystem::exists(initial_path)) {
|
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), initial_path.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string result;
|
|
||||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
|
||||||
char* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
||||||
if (filename) {
|
|
||||||
result = filename;
|
|
||||||
g_free(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#ifndef CLRSYNC_GUI_FILE_BROWSER_HPP
|
|
||||||
#define CLRSYNC_GUI_FILE_BROWSER_HPP
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace file_dialogs {
|
|
||||||
std::string open_file_dialog(const std::string& title = "Open File",
|
|
||||||
const std::string& initial_path = "",
|
|
||||||
const std::vector<std::string>& filters = {});
|
|
||||||
|
|
||||||
std::string save_file_dialog(const std::string& title = "Save File",
|
|
||||||
const std::string& initial_path = "",
|
|
||||||
const std::vector<std::string>& filters = {});
|
|
||||||
|
|
||||||
std::string select_folder_dialog(const std::string& title = "Select Folder",
|
|
||||||
const std::string& initial_path = "");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // CLRSYNC_GUI_FILE_BROWSER_HPP
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user