Adding clx-truetype font rendering as a module

This commit is contained in:
David Bjergaard 2014-03-13 23:49:43 -04:00
parent 682ae5d6f1
commit 879e53706c
9 changed files with 64 additions and 130 deletions

View file

@ -1 +0,0 @@
This is the stub README.txt for the "emacs" project.

View file

@ -1,11 +0,0 @@
;;;; emacs.asd
(asdf:defsystem #:emacs
:serial t
:description "Describe emacs here"
:author "David Bjergaard, Alexander aka 'CosmonauT' Vynnyk"
:license "GPLv3"
:depends-on (#:stumpwm)
:components ((:file "package")
(:file "emacs")))

View file

@ -1,45 +0,0 @@
;;;; emacs.lisp
(in-package #:emacs)
(export '(start-daemon
stop-daemon
restart-daemon
*emacs-start-daemon*
*emacs-stop-daemon*
eval-on-daemon))
;; These commands are/were inspired by DSS emacs module in github.com/dss-project/dss-modules/emacs
(defvar *emacs-start-daemon* "emacs --daemon"
"Command to start the emacs daemon")
(defvar *emacs-stop-daemon* "emacsclient -e \"(save-some-buffers)\" \"(kill-emacs)\" "
"Command to stop the emacs daemon")
(defun eval-on-daemon (expr)
(run-shell-command (concatenate 'string "emacsclient --eval "
(string-downcase
(prin1-to-string expr))) t))
(defun eval-and-raise-daemon (expr)
(run-shell-command (concatenate 'string "emacsclient -c --eval "
(string-downcase
(prin1-to-string expr)))))
(defun start-daemon-e ()
;;TODO load utils for interactive quitting of emacs
(run-shell-command *emacs-start-daemon* t))
(defun stop-daemon-e ()
(run-shell-command *emacs-stop-daemon*))
(defun restart-daemon-e ()
(and (stop-daemon-e)
(start-daemon-e)))
(add-hook *quit-hook* #'stop-daemon-e)
(defcommand start-daemon () ()
(if (start-daemon-e)
(message "Emacs daemon started!")
(error "Cannot start daemon!")))
(defcommand stop-daemon () ()
(if (stop-daemon-e)
(message "Emacs daemon stopped!")
(error "Cannot stop daemon!")))
(defcommand restart-daemon () ()
(restart-daemon-e))

View file

@ -1,5 +0,0 @@
;;;; package.lisp
(defpackage #:emacs
(:use #:cl :stumpwm))

View file

@ -1,68 +0,0 @@
;;; stumpwm-mode.el --- special lisp mode for evaluating code into running stumpwm
;; Copyright (C) 2007 Shawn Betts
;; Maintainer: Shawn Betts
;; Keywords: comm, lisp, tools
;; This file 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 2, or (at your option)
;; any later version.
;; This file 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 GNU Emacs; see the file COPYING. If not, see
;; <http://www.gnu.org/licenses/>.
;;; Commentary:
;; load this file, set stumpwm-shell-program to point to stumpish and
;; run M-x stumpwm-mode in your stumpwm lisp files. Now, you can
;; easily eval code into a running stumpwm using the regular bindings.
;;; Code:
(defvar stumpwm-shell-program "stumpish"
"program name, including path if needed, for the stumpish program.")
;;;###autoload
(define-minor-mode stumpwm-mode
"add some bindings to eval code into a running stumpwm using stumpish."
:global nil
:lighter " StumpWM"
:keymap (let ((m (make-sparse-keymap)))
(define-key m (kbd "C-M-x") 'stumpwm-eval-defun)
(define-key m (kbd "C-x C-e") 'stumpwm-eval-last-sexp)
m))
(defun stumpwm-eval-region (start end)
(interactive "r")
(let ((s (buffer-substring-no-properties start end)))
(message "%s"
(with-temp-buffer
(call-process stumpwm-shell-program nil (current-buffer) nil
"eval"
s)
(delete-char -1)
(buffer-string)))))
(defun stumpwm-eval-defun ()
(interactive)
(save-excursion
(end-of-defun)
(skip-chars-backward " \t\n\r\f")
(let ((end (point)))
(beginning-of-defun)
(stumpwm-eval-region (point) end))))
(defun stumpwm-eval-last-sexp ()
(interactive)
(stumpwm-eval-region (save-excursion (backward-sexp) (point)) (point)))
(provide 'stumpwm-mode)
;;; stumpwm-mode.el ends here

View file

@ -0,0 +1 @@
This is the stub README.txt for the "ttf-fonts" project.

View file

@ -0,0 +1,5 @@
;;;; package.lisp
(defpackage #:ttf-fonts
(:use #:cl #:stumpwm))

View file

@ -0,0 +1,11 @@
;;;; ttf-fonts.asd
(asdf:defsystem #:ttf-fonts
:serial t
:description "Describe ttf-fonts here"
:author "Michael Filonenko"
:license "GPLv3"
:depends-on (#:stumpwm #:clx-truetype)
:components ((:file "package")
(:file "ttf-fonts")))

View file

@ -0,0 +1,47 @@
;;;; ttf-fonts.lisp
(in-package #:ttf-fonts)
;;; "ttf-fonts" goes here. Hacks and glory await!
;;;; TTF fonts
(defmethod font-exists-p ((font xft:font))
;; if we can list the font then it exists
t)
(defmethod open-font ((display xlib:display) (font xft:font))
font)
(defmethod close-font ((font xft:font))
)
(defmethod font-ascent ((font xft:font))
(xft:font-ascent (screen-number (current-screen)) font))
(defmethod font-descent ((font xft:font))
(xft:font-descent (screen-number (current-screen)) font))
(defmethod font-height ((font xft:font))
(+ (font-ascent font)
(- (font-descent font))))
(defmethod text-line-width ((font xft:font) text &rest keys &key (start 0) end translate)
(declare (ignorable start end translate))
(apply 'xft:text-line-width (screen-number (current-screen)) font text
:allow-other-keys t keys))
(defmethod draw-image-glyphs (drawable
gcontext
(font xft:font)
x y
sequence &rest keys &key (start 0) end translate width size)
(declare (ignorable start end translate width size))
(apply 'xft:draw-text-line
drawable
gcontext
font
sequence
x y
:draw-background-p t
:allow-other-keys t
keys))