changeset 591:e3b7e199a87d draft

Add-in for {column,row,cell}color
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 23 Sep 2022 18:42:59 +0900
parents 7810c4ec21fe
children 86ceef677ca2
files yatexadd.el yatexpkg.el
diffstat 2 files changed, 45 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/yatexadd.el	Fri Sep 23 06:46:32 2022 +0900
+++ b/yatexadd.el	Fri Sep 23 18:42:59 2022 +0900
@@ -1,6 +1,6 @@
 ;;; yatexadd.el --- YaTeX add-in functions -*- coding: sjis -*-
 ;;; (c)1991-2019 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Wed Sep 21 21:22:37 2022 on firestorm
+;;; Last modified Thu Sep 22 11:41:04 2022 on firestorm
 ;;; $Id$
 
 ;;; Code:
@@ -1993,6 +1993,48 @@
    ((= argp 2) (YaTeX::color-completing-read "Inner color: "))
    ((= argp 3) (YaTeX-read-string-or-skip "Colored string: "))))
 
+(defun YaTeX:columncolor ()
+  (let ((model (YaTeX-completing-read-or-skip
+		"Color model: " '(("rgb") ("gray") ("named")))))
+    (put 'YaTeX:columncolor 'model model)
+    (if (string= "" model) "" (concat "[" model "]"))))
+
+(fset 'YaTeX:rowcolor 'YaTeX:columncolor)
+(fset 'YaTeX:cellcolor 'YaTeX:columncolor)
+
+(defun YaTeX::columncolor (argp)
+  (let ((model (get 'YaTeX:columncolor 'model))
+	(type (cond ((string-match "column" YaTeX-section-name) "Column")
+		    ((string-match "row" YaTeX-section-name) "Row")
+		    ((string-match "cell" YaTeX-section-name) "Cell")
+		    (t "Table")))
+	(last (get 'YaTeX::columncolor 'last-color))
+	str)
+    (put 'YaTeX::columncolor 'last-color
+	 (cond
+	  ((equal model "rgb")
+	   (setq str (YaTeX-read-string-or-skip
+		      "R, G, B values: "
+		      (cons (or last "0.6, 0.8, 0.9") 0)))
+	   (cond
+	    ((string-match ",.*," str) str)
+	    ((string-match "\\(\\S +\\)\\s +\\(\\S +\\)\\s +\\(\\S +\\)" str)
+	     (format "%s, %s, %s" (YaTeX-match-string 1 1 str)
+		     (YaTeX-match-string 2 2 str)(YaTeX-match-string 3 3 str)))
+	    (t (message "%s may cause error on typesetting" str)
+	       str)))
+	  ((equal model "gray")
+	   (setq str (YaTeX-read-string-or-skip "Grayscale values(0.0 - 1.0): "))
+	   (if (<= (string-to-number str) 1)
+	       str
+	     (message "%s may be an error.  Values from 0.0 to 1.0 are acceptable")
+	     str))
+	  ((equal model "named")
+	   (YaTeX::color-completing-read (concat type " color")))
+	  ))))
+(fset 'YaTeX::rowcolor 'YaTeX::columncolor)
+(fset 'YaTeX::cellcolor 'YaTeX::columncolor)
+
 (defun YaTeX:scalebox ()
   "Add-in for \\scalebox"
   (let ((vmag (YaTeX-read-string-or-skip (if YaTeX-japan "”{—¦(•‰‚Å”½“]): "
--- a/yatexpkg.el	Fri Sep 23 06:46:32 2022 +0900
+++ b/yatexpkg.el	Fri Sep 23 18:42:59 2022 +0900
@@ -1,7 +1,7 @@
 ;;; yatexpkg.el --- YaTeX package manager -*- coding: sjis -*-
 ;;; 
 ;;; (c)2003-2019 by HIROSE, Yuuji [yuuji@yatex.org]
-;;; Last modified Sat May 25 14:46:27 2019 on firestorm
+;;; Last modified Thu Sep 22 20:20:37 2022 on firestorm
 ;;; $Id$
 
 ;;; Code:
@@ -76,6 +76,7 @@
     ("cases"	(env "numcases" "subnumcases"))
     ("subfigure"	(section "subfigure"))
     ("okumacro"	(section "ruby" "kenten"))
+    ("colortbl"	(section "columncolor" "rowcolor"))
     )
   "Default package vs. macro list.
 Alists contains '(PACKAGENAME . MACROLIST)

yatex.org