diff --git a/core/fg42/system.el b/core/fg42/system.el deleted file mode 100644 index abd833e..0000000 --- a/core/fg42/system.el +++ /dev/null @@ -1,51 +0,0 @@ -;;; system --- System library of FG42 -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors -;; -;; Author: Sameer Rahmani -;; URL: https://gitlab.com/FG42/FG42 -;; Version: 3.0.0 -;; -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; `System' is just a state monad which holds the state of the editor. -;; Each system has to have a `start' function to start the setup process. -;; -;;; Code: -(defvar fg42/system '() - "The default system of FG42.") - - -;;;###autoload -(defun fg42/system-start (system) - "Start the given SYSTEM." - (require 'fg42/utils) - (require 'fg42/system/core) - (require 'fg42/system/dependencies) - (require 'fg42/system/cubes) - - (let* ((system-map (funcall system '()))) - ;; Weird right ? Well, I've tried the functional state passing style - ;; but as it turns out the performance isn't great in elisp - (setq fg42/system (fg42/system-install-dependencies system-map)) - (setq fg42/system (fg42/system-setup-cubes fg42/system)) - (setq fg42/system (fg42/system-setup-modes-hook fg42/system)) - - (message "SYSTEM: %s" - (fg42/system-get fg42/system :cubes)))) - - -(provide 'fg42/system) -;;; system.el ends here diff --git a/core/fg42/system/core.el b/core/fg42/system/core.el deleted file mode 100644 index d91b83a..0000000 --- a/core/fg42/system/core.el +++ /dev/null @@ -1,77 +0,0 @@ -;;; system --- System library of FG42 -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2021 Sameer Rahmani -;; -;; Author: Sameer Rahmani -;; URL: https://gitlab.com/FG42/FG42 -;; Version: 3.0.0 -;; -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; `System' is just a state monad which holds the state of the editor. -;; Each system has to have a `start' function to start the setup process. -;; -;;; Code: -(require 'seq) -(require 'fg42/utils) - - -(defun fg42/system-cons (system k v) - "Set the given key K to the given value V in the SYSTEM." - (cons (cons k v) system)) - - -(defun fg42/system-cons-to (system k v) - "Add the given value V to the value of key K in SYSTEM." - (let* ((value (fg42/system-get system k)) - (m (fg42/system-cons system k (cons v value)))) - m)) - - -(defun fg42/system-get (system k) - "Return the value of the given key K in the SYSTEM." - (cdr (assoc k system))) - -(comment - (fg42/system-get (fg42/system-cons '((:1 . 4)) :1 2) :1) - (fg42/system-get '((:a . ((1 . 2)))) :a) - (fg42/system-get - (fg42/system-cons-to '() :a '((x . 5))) - :a)) - - -(defun fg42/system-register-cube (system name cube) - "Add the given CUBE with the given NAME to the SYSTEM." - (fg42/system-cons-to system :cubes (cons name cube))) - - -(defmacro defsystem (name props &rest body) - "Define a system with the given NAME, PROPS and BODY." - (declare (indent 1)) - `(defun ,name () - (if ,props - (lambda (___system___) - (funcall - (fg42/cube-compose ,@body) - (seq-reduce - (lambda (system pair) - (fg42/system-cons (car pair) (cadr pair))) - (seq-partition ,props 2) - ___system___))) - (fg42/cube-compose ,@body)))) - - -(provide 'fg42/system/core) -;;; core.el ends here diff --git a/core/fg42/system/cubes.el b/core/fg42/system/cubes.el deleted file mode 100644 index c505dbc..0000000 --- a/core/fg42/system/cubes.el +++ /dev/null @@ -1,107 +0,0 @@ -;;; system --- System library of FG42 -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors -;; -;; Author: Sameer Rahmani -;; URL: https://gitlab.com/FG42/FG42 -;; Version: 3.0.0 -;; -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; `System' is just a state monad which holds the state of the editor. -;; Each system has to have a `start' function to start the setup process. -;; -;;; Code: -(require 'seq) -(require 'fg42/system/core) - -(defun fg42/system-get-cube (system cube-name) - "Return the cube with CUBE-NAME ins the SYSTEM." - ;; car is the name cdr is the cube itself - (cdr (assoc cube-name (fg42/system-get system :cubes)))) - - -(defun fg42/system-get-cube-property (system cube-name prop) - "Return the value of the given property PROP of CUBE-NAME in SYSTEM." - (let ((cube (fg42/system-get-cube system cube-name))) - (plist-get cube prop))) - - -(defun fg42/system-set-cube-property (system cube-name prop v) - "Set the given property PROP of CUBE-NAME to V in SYSTEM." - (let ((cube (append (list prop v) - (fg42/system-get-cube system cube-name)))) - - (fg42/system-register-cube system cube-name cube))) - - -(defun fg42/system-setup-cube (system cube-name) - "Setup the given CUBE-NAME using the given SYSTEM." - (if (eq t (fg42/system-get-cube-property system cube-name :setup-finished)) - system - (let ((cube (fg42/system-get-cube system cube-name))) - - (when (null cube) - (error "Can't find cube '%s' in the system" cube-name)) - - (message "Setting up '%s' cube..." cube-name) - (let ((updated-system - (seq-reduce - (lambda (sys requirement) - (fg42/system-setup-cube sys requirement)) - (plist-get cube :requires) - system))) - - ;; Run the init function the cube. - ;; The init function is just for setup, the return value of it - ;; and the changes that it might make to the system will be discarded. - (funcall (or (plist-get cube :init) (lambda () ()))) - - - ;; Setup the automods - (fg42/system-cube-auto-modes system cube) - - ;; Setup the hooks - (fg42/system-cube-hooks system cube) - - (fg42/system-set-cube-property updated-system cube-name :setup-finished t))))) - - -(defun fg42/system-setup-cubes (system) - "Setup the cubes in the given SYSTEM by creating a dependency tree." - (let ((cubes (fg42/system-get system :cubes))) - (seq-reduce - (lambda (sys cube-pair) - (fg42/system-setup-cube sys (car cube-pair))) - cubes - system))) - - -(defun fg42/system-cube-auto-modes (system cube) - "Setup the auto modes of the given CUBE using the given SYSTEM." - (dolist (automod (plist-get cube :auto-modes)) - (when automod - (add-to-list 'auto-mode-alist automod)))) - - -(defun fg42/system-cube-hooks (system cube) - "Setup the auto modes of the given CUBE using the given SYSTEM." - (dolist (hook (plist-get cube :hooks)) - (when hook - (add-hook (car hook) (cdr hook))))) - - -(provide 'fg42/system/cubes) -;;; cubes.el ends here diff --git a/core/fg42/system/dependencies.el b/core/fg42/system/dependencies.el deleted file mode 100644 index 1d7a087..0000000 --- a/core/fg42/system/dependencies.el +++ /dev/null @@ -1,87 +0,0 @@ -;;; dependencies --- System library of FG42 -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors -;; -;; Author: Sameer Rahmani -;; URL: https://gitlab.com/FG42/FG42 -;; Version: 3.0.0 -;; -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; `System' is just a state monad which holds the state of the editor. -;; Each system has to have a `start' function to start the setup process. -;; -;;; Code: -(require 'fpkg) -(require 'fg42/system/core) - - -(defun fg42/system-merge-dependencies (system cube-name deps) - "Retun an updated SYSTEM with the given dependencies DEPS for CUBE-NAME." - (if deps - ;; TODO: Validate the deps here - (fg42/system-cons-to system :dependencies (cons cube-name deps)) - system)) - - -(defun fg42/system-dependencies (system) - "Return a flat list of dependencies of the SYSTEM." - (seq-reduce - (lambda (lst pair) - (append lst (cdr pair))) - (fg42/system-get system :dependencies) - '())) - -(defun fg42/system-install-dependency (dep) - "Install the given dependency list DEP. -dep is in (cube-name (...dependencies...)) format." - (message "Installing dependencies of '%s' cube..." (car dep)) - (mapcar #'fpkg/install-package (cdr dep))) - - -(defun fg42/system-install-dependencies (system) - "Install the dependencies in the SYSTEM." - (when (not (fg42/system-dependencies-installed? system)) - (fg42/system-refresh-package-index system) - (mapc #'fg42/system-install-dependency - (fg42/system-get system :dependencies))) - system) - - -(defun fg42/system-refresh-package-index (system) - "Refresh the package index of the SYSTEM is dependencies were missing." - (unless (fg42/system-dependencies-installed? system) - ;; check for new packages (package versions) - (message "Refreshing package database...") - ;; TODO: call different function to update every source - ;; in the system. Something similar to what we do - ;; with package-install on FPKG - (fpkg/initialize system) - (package-refresh-contents))) - - -(defun fg42/system-dependencies-installed? (system) - "Return t if all the dependencies of the given SYSTEM are installed." - (let ((pkgs (fg42/system-dependencies system))) - (seq-reduce - (lambda (all-installed? pkg) - (and all-installed? - (fpkg/package-installed? pkg))) - pkgs - t))) - - -(provide 'fg42/system/dependencies) -;;; dependencies.el ends here diff --git a/core/fg42/system/keys.el b/core/fg42/system/keys.el deleted file mode 100644 index 990cf7b..0000000 --- a/core/fg42/system/keys.el +++ /dev/null @@ -1,136 +0,0 @@ -;;; dependencies --- System library of FG42 -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors -;; -;; Author: Sameer Rahmani -;; URL: https://gitlab.com/FG42/FG42 -;; Version: 3.0.0 -;; -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; `System' is just a state monad which holds the state of the editor. -;; Each system has to have a `start' function to start the setup process. -;; -;;; Code: -(require 'seq) -(require 'fg42/system/core) - - -(defun fg42/system-is-good? (system) - "Return non-nil if the keyset on the given SYSTEM is set to :good." - (eq (or (fg42/system-get system :i-am) :good) :good)) - - -(defun fg42/system-is-evil? (system) - "Return non-nil if the keyset on the given SYSTEM is set to :good." - (eq (or (fg42/system-get system :i-am) :good) :evil)) - - -(defun fg42/system-merge-keys (system cube-name keys) - "Retun an updated SYSTEM with the given keys KEYS for CUBE-NAME. -It converts the `:keys' of the cube to the following format and adds -them to the system. (cube-nam mode (key f)s...)." - (let ((keyset :good)) - (if keys - ;; TODO: Validate the deps here - (fg42/system-cons-to system - :keys - (car - (seq-reduce - (lambda (bindings keys) - (let ((mode (car keys)) - (pair-list (plist-get (cdr keys) keyset))) - (cons - (list cube-name mode pair-list) - bindings))) - keys - '()))) - - system))) - - -(defun fg42/system-setup-keys (system) - "Setup the key binding through out the SYSTEM." - (let ((keyset :good)) - (mapcar - (lambda (key-desc) - (let ((cube-name (car key-desc)) - (map (cadr key-desc)) - (binding (caddr key-desc)) - (f (cadddr key-desc))) - (message "Set keybinding %s" key-desc) - (if (eq keyset :good) - (define-in-keymap map binding f) - (define-evil-in-keymap map binding f)))) - (fg42/system-get system :keys))) - system) - - -(defmacro define-in-keymap (map binding f) - "Set the given key BINDING in the given MAP to F." - (if (eq map :global) - `(global-set-key (kbd ,binding) ,f) - `(define-key ,map (kbd ,binding) ,f))) - - -(defmacro define-evil-in-keymap (map binding f) - "Set the given key BINDING in the given MAP to F (evil mode only)." - (message "TBD") - nil) - - -(defun fg42/defkey--good (map key fn) - "Set the given KEY on key map MAP to FN." - (message "SSSSSSSSSSSS %s %s" (type-of map) map) - (funcall #'define-key map (kbd key) fn)) - - -(defun fg42/defkey--evil (map state-keys fn) - "Set the given STATE-KEYS on key map MAP to FN." - (let ((normal-key (plist-get state-keys :normal)) - (visual-key (plist-get state-keys :visual)) - (insert-key (plist-get state-keys :insert)) - (emacs-key (plist-get state-keys :emacs))) - (cond - ((not (null normal-key)) (evil-define-key 'normal map (kbd normal-key) fn)) - ((not (null visual-key)) (evil-define-key 'visual map (kbd visual-key) fn)) - ((not (null insert-key)) (evil-define-key 'insert map (kbd insert-key) fn)) - ((not (null emacs-key)) (evil-define-key 'emacs map (kbd emacs-key) fn))))) - - -(defmacro defkey (map fn &rest keys) - "Defines a key binding for FG42 for different types. -Defines a keybinding in the given MAP for the given KEYS that maps -to the given FN with the given DOCSTRING. -Example usage : -\\(defkey `'global-map`' 'goto-line - :evil \\(:normal \"SPC s u\"\\) - :good \"\"\\)" - (declare (indent defun)) - (let ((good-key (plist-get keys :good)) - (evil-state-key (plist-get keys :evil))) - (when (and (fg42/system-is-evil? fg42/system) (null evil-state-key)) - (error "You should pass :evil keys when you are evil user")) - (when (and (fg42/system-is-good? fg42/system) (null good-key)) - (error "You should pass :good keys when you are a good user")) - (cond - ((fg42/system-is-good? fg42/system) - `(fg42/defkey--good ,map ,good-key ,fn)) - ((fg42/system-is-evil? fg42/system) - `(fg42/defkey-evil ,map (quote ,evil-state-key) ,fn))))) - - -(provide 'fg42/system/keys) -;;; keys.el ends here diff --git a/core/fg42/system/modes.el b/core/fg42/system/modes.el deleted file mode 100644 index 9921700..0000000 --- a/core/fg42/system/modes.el +++ /dev/null @@ -1,59 +0,0 @@ -;;; dependencies --- System library of FG42 -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors -;; -;; Author: Sameer Rahmani -;; URL: https://gitlab.com/FG42/FG42 -;; Version: 3.0.0 -;; -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; `System' is just a state monad which holds the state of the editor. -;; Each system has to have a `start' function to start the setup process. -;; -;;; Code: - -(require 'fg42/system/core) - -(defun fg42/system-merge-modes (system cube-name modes) - "Retun an updated SYSTEM with the given mode config MODES for CUBE-NAME." - (if modes - ;; TODO: Validate the modes here - (fg42/system-cons-to system :modes (cons cube-name modes)) - system)) - - -(defun fg42/system-setup-mode-hook (system mode-pair) - "Setup the given MODE-PAIR which is a (mode . f) in SYSTEM." - (add-hook (intern (format "%s-hook" (car mode-pair))) - (lambda () - ;; TODO: Setup key bindings here - (funcall (cdr mode-pair))))) - - - -(defun fg42/system-setup-modes-hook (system) - "Setup the mode hook of every mode in the SYSTEM." - (mapcar - (lambda (cube-modes) - (let ((cube-name (car cube-modes)) - (modes (cdr cube-modes))) - (mapcar (lambda (x) (fg42/system-setup-mode-hook system x)) modes))) - (fg42/system-get system :modes)) - system) - - -(provide 'fg42/system/modes) -;;; modes.el ends here diff --git a/share/images/FG42_tetris_style.svg b/share/images/FG42_tetris_style.svg index 2a5cb56..0ac03b0 100644 --- a/share/images/FG42_tetris_style.svg +++ b/share/images/FG42_tetris_style.svg @@ -23,17 +23,17 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="1" - inkscape:cx="637.02839" - inkscape:cy="7.7827113" + inkscape:zoom="1.1614743" + inkscape:cx="1020.0021" + inkscape:cy="505.73639" inkscape:document-units="px" - inkscape:current-layer="layer1" + inkscape:current-layer="g1163" inkscape:document-rotation="0" showgrid="false" inkscape:window-width="1920" - inkscape:window-height="994" + inkscape:window-height="1048" inkscape:window-x="0" - inkscape:window-y="28" + inkscape:window-y="0" inkscape:window-maximized="1" inkscape:snap-nodes="true" inkscape:object-paths="true" /> @@ -45,7 +45,7 @@ image/svg+xml - + @@ -972,5 +972,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +