Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
polhuang committed Jan 14, 2025
1 parent e3abfe0 commit 8f4a9f3
Showing 1 changed file with 112 additions and 59 deletions.
171 changes: 112 additions & 59 deletions seoul256-theme.el
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
;;; cherry-seoul256-theme.el --- A cherry-blossom variant of seoul256 by junegunn

;; Copyright (C) 2023-2024 Paul Huang

;; Author: Paul Huang <paulleehuang@protonmail.com>
;; Maintainer: Paul Huang <paulleehuang@protonmail.com>
;; URL: http://github.com/polhuang/cherry-seoul256
;; Created: 22 November 2023
;; Modified:
;; Version: 0.0.0
;; Keywords: theme
;; Package-Requires: ((emacs "24.3"))

;;; Based on:
;;; seoul256-theme.el --- Low-contrast color scheme based on Seoul Colors.

;; Copyright (C) 2016-2018 Anand Iyer
Expand Down Expand Up @@ -51,24 +65,24 @@
(when (version< emacs-version "24.3")
(error "Requires Emacs 24.3 or later"))

(defgroup seoul256 nil
"seoul256 theme"
(defgroup cherry-seoul256 nil
"cherry-seoul256 theme"
:group 'faces)

(defcustom seoul256-background 237
"Background color for seoul256 scheme."
(defcustom cherry-seoul256-background 237
"Background color for cherry-seoul256 scheme."
:type 'number
:group 'seoul256)
:group 'cherry-seoul256)

(defcustom seoul256-alternate-background 253
"Alternate background color for seoul256 scheme."
(defcustom cherry-seoul256-alternate-background 253
"Alternate background color for cherry-seoul256 scheme."
:type 'number
:group 'seoul256)
:group 'cherry-seoul256)

(deftheme seoul256 "Low-contrast color scheme based on Seoul Colors")
(deftheme cherry-seoul256 "Low-contrast color scheme based on Cherry-Seoul Colors")

(defvar seoul256-default-colors-alist
'((16 . "#000000") (17 . "#00005F") (18 . "#000087")
(defvar cherry-seoul256-default-colors-alist
'((16 . "#191724") (17 . "#00005F") (18 . "#000087")
(19 . "#0000AF") (20 . "#0000D7") (21 . "#0000FF")
(22 . "#006F00") (23 . "#007173") (24 . "#007299")
(25 . "#0074BE") (26 . "#005FD7") (27 . "#005FFF")
Expand Down Expand Up @@ -116,11 +130,11 @@
(151 . "#BCDDBD") (152 . "#BCDEDE") (153 . "#BCE0FF")
(154 . "#AFFF00") (155 . "#AFFF5F") (156 . "#AFFF87")
(157 . "#AFFFAF") (158 . "#AFFFD7") (159 . "#AFFFFF")
(160 . "#D70000") (161 . "#E12672") (162 . "#D70087")
(160 . "#EB6F92") (161 . "#E12672") (162 . "#D70087")
(163 . "#D700AF") (164 . "#D700D7") (165 . "#D700FF")
(166 . "#D75F00") (167 . "#D75F5F") (168 . "#E17899")
(169 . "#D75FAF") (170 . "#D75FD7") (171 . "#D75FFF")
(172 . "#D78700") (173 . "#E19972") (174 . "#E09B99")
(172 . "#D78700") (173 . "#EBBCBA") (174 . "#E09B99")
(175 . "#D787AF") (176 . "#D787D7") (177 . "#D787FF")
(178 . "#D7AF00") (179 . "#DFBC72") (180 . "#D7AF87")
(181 . "#E0BEBC") (182 . "#D7AFD7") (183 . "#D7AFFF")
Expand Down Expand Up @@ -149,23 +163,23 @@
(250 . "#C8C8C8") (251 . "#D1D0D1") (252 . "#D9D9D9")
(253 . "#E1E1E1") (254 . "#E9E9E9") (255 . "#F1F1F1")))

(defvar seoul256-override-colors-alist
(defvar cherry-seoul256-override-colors-alist
'()
"Use this alist to override the theme's default colors.")

(defvar seoul256-colors-alist
(append seoul256-override-colors-alist seoul256-default-colors-alist))
(defvar cherry-seoul256-colors-alist
(append cherry-seoul256-override-colors-alist cherry-seoul256-default-colors-alist))

(defvar seoul256-current-bg nil
"Current background used by seoul256 theme.")
(defvar cherry-seoul256-current-bg nil
"Current background used by cherry-seoul256 theme.")

(defun seoul256-apply (theme style dark-fg light-fg dark-bg light-bg)
"Apply theme THEME, a STYLE variant of seoul256 theme using DARK-FG, LIGHT-FG, DARK-BG and LIGHT-BG as main colors."
(defun cherry-seoul256-apply (theme style dark-fg light-fg dark-bg light-bg)
"Apply theme THEME, a STYLE variant of cherry-seoul256 theme using DARK-FG, LIGHT-FG, DARK-BG and LIGHT-BG as main colors."
(cl-flet ((hex (dark light)
(let ((color-id dark))
(when (string= style "light")
(setq color-id light))
(cdr (assoc color-id seoul256-colors-alist)))))
(cdr (assoc color-id cherry-seoul256-colors-alist)))))

(custom-theme-set-faces
theme
Expand All @@ -179,14 +193,32 @@
`(default ((t (:foreground ,(hex dark-fg light-fg) :background ,(hex dark-bg light-bg)))))
`(fringe ((t (:inherit default))))
`(header-line ((t (:foreground ,(hex 256 16)))))
`(highlight ((t (:foreground ,(hex (+ dark-bg 1) 238) :background ,(hex 220 220)))))
`(highlight ((t (:foreground ,(hex (+ dark-bg 1) 238) :distant-foreground ,(hex (+ light-fg 12) (- dark-fg 12)) :background ,(hex 217 217)))))
`(hl-line ((t (:background ,(hex (- dark-bg 1) (- light-bg 1))))))
`(link ((t (:foreground ,(hex 73 23)))))
`(link ((t (:foreground ,(hex 73 23) :underline t))))
`(link-visited ((t (:foreground ,(hex 72 22)))))
`(match ((t (:foreground ,(hex dark-fg 255) :background ,(hex 24 74) :weight bold))))
`(minibuffer-prompt ((t (:foreground ,(hex 74 24) :weight bold))))
`(region ((t (:background ,(hex 23 152)))))

;; ansi
`(ansi-color-black ((t (:foreground "#1b1b23" :background "#1b1b23" ))))
`(ansi-color-red ((t (:foreground "#ebb9b9" :background "#ebb9b9" ))))
`(ansi-color-green ((t (:foreground "#caf6bb" :background "#caf6bb" ))))
`(ansi-color-yellow ((t (:foreground "#e6dfb8" :background "#e6dfb8" ))))
`(ansi-color-blue ((t (:foreground "#cddbf9" :background "#cddbf9" ))))
`(ansi-color-magenta ((t (:foreground "#f6bbe7" :background "#f6bbe7" ))))
`(ansi-color-cyan ((t (:foreground "#b8dceb" :background "#b8dceb" ))))
`(ansi-color-white ((t (:foreground "#c8cedc" :background "#c8cedc" ))))

`(ansi-color-bright-black ((t (:foreground "#1b1b23" :background "#1b1b23" ))))
`(ansi-color-bright-red ((t (:foreground "#d95e59" :background "#d95e59" ))))
`(ansi-color-bright-green ((t (:foreground "#8fc587" :background "#8fc587" ))))
`(ansi-color-bright-yellow ((t (:foreground "#ffcf85" :background "#ffcf85" ))))
`(ansi-color-bright-blue ((t (:foreground "#4a83c3" :background "#4a83c3" ))))
`(ansi-color-bright-magenta ((t (:foreground "#f6bbe7" :background "#f6bbe7" ))))
`(ansi-color-bright-cyan ((t (:foreground "#4eb3cd" :background "#4eb3cd" ))))

;; font-lock
`(font-lock-builtin-face ((t (:foreground ,(hex 187 58)))))
`(font-lock-comment-delimiter-face ((t (:foreground ,(hex 65 65)))))
Expand Down Expand Up @@ -216,22 +248,19 @@
`(isearch-fail ((t (:background ,(hex 196 196) :foreground ,(hex (+ dark-bg 3) 253)))))

;; line number
`(line-number ((t (:foreground ,(hex 101 101) :background ,(hex (+ dark-bg 1) (- light-bg 2))))))
`(line-number-current-line ((t (:foreground ,(hex 131 131) :background ,(hex (- dark-bg 1) (- light-bg 1))))))
`(line-number ((t (:foreground ,(hex (+ dark-bg 6) (- light-bg 6)) ))))
`(line-number-current-line ((t (:foreground ,(hex (+ dark-bg 20) (- light-bg 20)) :background ,(hex (- dark-bg 1) (- light-bg 1)) :weight bold))))

;; linum
`(linum ((t (:inherit line-number))))

;; mode-line
`(mode-line ((t (:foreground ,(hex 187 187) :background ,(hex 95 95)))))
`(mode-line ((t (:foreground ,(hex 187 187) :background ,(hex (+ dark-bg 1) (- light-bg 1))))))
`(mode-line-buffer-id ((t (:foreground ,(hex 230 230)))))
`(mode-line-emphasis ((t (:foreground ,(hex 256 256) :weight bold))))
`(mode-line-highlight ((t (:inherit highlight))))
`(mode-line-inactive ((t (:foreground ,(hex (+ dark-bg 10) (- light-bg 10)) :background ,(hex (+ dark-bg 2) (- light-bg 2) )))))

;; show-paren
`(show-paren-match ((t (:foreground ,(hex 226 200) :background ,(hex (+ dark-bg 3) (- light-bg 3)) :weight bold))))
`(show-paren-mismatch ((t (:foreground ,(hex 196 196) :inherit unspecified :strike-through t :weight bold))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; package-specific
Expand All @@ -255,6 +284,9 @@
`(company-tooltip-search-selection ((t (:inherit company-tooltip-search))))
`(company-tooltip-selection ((t (:foreground ,(hex 226 32) :background ,(hex 23 152)))))

;; dashboard
`(dashboard-text-banner ((t (:foreground ,(hex 217 217) :weight bold))))

;; git-gutter
`(git-gutter:added ((t (:foreground ,(hex 108 65) :background ,(hex (+ dark-bg 1) (- light-bg 2))))))
`(git-gutter:deleted ((t (:foreground ,(hex 161 161) :background ,(hex (+ dark-bg 1) (- light-bg 2))))))
Expand Down Expand Up @@ -292,6 +324,26 @@
;; nlinum-relative
`(nlinum-relative-current-face ((t (:inherit line-number-current-line))))

;; org
`(org-link ((t (:inherit link))))
`(org-block-begin-line ((t (:foreground "#333233" :distant-foreground "#fff0f5" :background "#ffbfbd"))))
`(org-block ((t (:background "#171717"))))
`(org-habit-clear-future-face ((t (:background "#4a83c3"))))
`(org-habit-clear-face ((t (:background "#caf6bb" :foreground "#333233" :distant-foreground "#fff0f5"))))
`(org-habit-alert-face ((t (:foreground "#333233" :distant-foreground "#fff0f5" :background "#ffff00" :weight bold))))
`(org-habit-ready-face ((t (:foreground "#171717":background "#8fc587"))))
`(org-habit-alert-future-face ((t (:inherit org-habit-alert-face))))
`(org-habit-overdue-future-face ((t (:background "#d95e59"))))
`(org-habit-overdue-face ((t (:foreground "#171717" :background "#ebb9b9" :weight bold))))
`(org-todo ((t (:foreground "#d95e59" :weight bold))))
`(org-done ((t (:foreground "#8fc587" :weight bold))))

;; (set-face-attribute 'org-block-begin-line nil :foreground "#333233" :distant-foreground "#fff0f5" :background "#ffbfbd")
;; (set-face-attribute 'org-block nil :background "#171717")

;; perspective
`(persp-selected-face ((t (:foreground "#cddbf9"))))

;; powerline
`(powerline-active0 ((t (:inherit mode-number))))
`(powerline-active1 ((t (:inherit line-number))))
Expand Down Expand Up @@ -320,10 +372,11 @@
`(tabbar-default ((t (:background ,(hex (+ dark-bg 2) (- light-bg 2))))))
`(tabbar-button ((t (:inherit tabbar-default))))
`(tabbar-selected ((t (:foreground ,(hex 23 66) :background ,(hex 187 187)))))
`(tabbar-unselected ((t (:foreground ,(hex (+ dark-bg 4) (- light-bg 4)) :background ,(hex (+ dark-bg 12) (- light-bg 12))) ))) )))
`(tabbar-unselected ((t (:foreground ,(hex (+ dark-bg 4) (- light-bg 4)) :background ,(hex (+ dark-bg 12) (- light-bg 12))) )))
)))

(defun seoul256-create (theme background)
"Create a seoul256 theme `THEME' using a given `BACKGROUND'."
(defun cherry-seoul256-create (theme background)
"Create a cherry-seoul256 theme `THEME' using a given `BACKGROUND'."
(let ((dark-bg 237)
(light-bg 253)
(dark-fg 252)
Expand All @@ -341,52 +394,52 @@
light-bg background))

(if (string= style "dark")
(setq seoul256-current-bg dark-bg)
(setq seoul256-current-bg light-bg))
(setq cherry-seoul256-current-bg dark-bg)
(setq cherry-seoul256-current-bg light-bg))

(if (member theme custom-enabled-themes)
(let ((custom--inhibit-theme-enable nil))
(cherry-seoul256-apply theme style dark-fg light-fg dark-bg light-bg))
(let ((custom--inhibit-theme-enable nil))
(cherry-seoul256-apply theme style dark-fg light-fg dark-bg light-bg))
(cherry-seoul256-apply theme style dark-fg light-fg dark-bg light-bg)

(seoul256-apply theme style dark-fg light-fg dark-bg light-bg)))
)
))

(defun seoul256-switch-background ()
"Switch the background of the current seoul256 theme."
(defun cherry-seoul256-switch-background ()
"Switch the background of the current cherry-seoul256 theme."
(interactive)
(let ((diff1 0)
(diff2 0))
(setq diff1 (abs (- seoul256-current-bg seoul256-alternate-background))
diff2 (abs (- seoul256-current-bg seoul256-background)))
(setq diff1 (abs (- cherry-seoul256-current-bg cherry-seoul256-alternate-background))
diff2 (abs (- cherry-seoul256-current-bg cherry-seoul256-background)))
(if (< diff1 diff2)
(seoul256-create 'seoul256 seoul256-background)
(seoul256-create 'seoul256 seoul256-alternate-background))))
(cherry-seoul256-create 'cherry-seoul256 cherry-seoul256-background)
(cherry-seoul256-create 'cherry-seoul256 cherry-seoul256-alternate-background))))

(defun seoul256-darken-background ()
(defun cherry-seoul256-darken-background ()
"Darken current background."
(interactive)
(when (or (and (> seoul256-current-bg 233)
(<= seoul256-current-bg 239))
(and (> seoul256-current-bg 252)
(<= seoul256-current-bg 256)))
(seoul256-create 'seoul256 (- seoul256-current-bg 1))))
(when (or (and (> cherry-seoul256-current-bg 233)
(<= cherry-seoul256-current-bg 239))
(and (> cherry-seoul256-current-bg 252)
(<= cherry-seoul256-current-bg 256)))
(cherry-seoul256-create 'cherry-seoul256 (- cherry-seoul256-current-bg 1))))

(defun seoul256-brighten-background ()
(defun cherry-seoul256-brighten-background ()
"Brighten current background."
(interactive)
(when (or (and (>= seoul256-current-bg 233)
(< seoul256-current-bg 239))
(and (>= seoul256-current-bg 252)
(< seoul256-current-bg 256)))
(seoul256-create 'seoul256 (+ 1 seoul256-current-bg))))
(when (or (and (>= cherry-seoul256-current-bg 233)
(< cherry-seoul256-current-bg 239))
(and (>= cherry-seoul256-current-bg 252)
(< cherry-seoul256-current-bg 256)))
(cherry-seoul256-create 'cherry-seoul256 (+ 1 cherry-seoul256-current-bg))))

(seoul256-create 'seoul256 seoul256-background)
(cherry-seoul256-create 'cherry-seoul256 cherry-seoul256-background)

;;;###autoload
(when (and (boundp 'custom-theme-load-path) load-file-name)
(add-to-list 'custom-theme-load-path
(file-name-as-directory (file-name-directory load-file-name))))

(provide-theme 'seoul256)
(provide-theme 'cherry-seoul256)

;;; seoul256-theme.el ends here
;;; cherry-seoul256-theme.el ends here

0 comments on commit 8f4a9f3

Please sign in to comment.