| 216 | | |
|---|
| 217 | | ;; |
|---|
| 218 | | ;; Section: X geometry (-g option) |
|---|
| 219 | | ;; |
|---|
| 220 | | |
|---|
| 221 | | (defun x-parse-geometry (str) |
|---|
| 222 | | (let* ((size-regexp "\\([0-9]+\\)?\\(?:[xX]\\([0-9]+\\)\\)?") |
|---|
| 223 | | (location-regexp "\\([+\\-][+\\-]?[0-9]+\\)") |
|---|
| 224 | | (func (lambda (x) |
|---|
| 225 | | (cond ((null x) nil) |
|---|
| 226 | | ((= (aref x 0) ?+) |
|---|
| 227 | | (list '+ (string-to-number |
|---|
| 228 | | (substring x 1)))) |
|---|
| 229 | | ((= (aref x 0) ?-) |
|---|
| 230 | | (list '- (string-to-number |
|---|
| 231 | | (substring x 1)))) |
|---|
| 232 | | (t nil)))) |
|---|
| 233 | | location-x location-y size-x size-y result) |
|---|
| 234 | | (if (string-match "^=?" str) |
|---|
| 235 | | (setq str (substring str (match-end 0)))) |
|---|
| 236 | | (if (string-match |
|---|
| 237 | | (concat "^" size-regexp) |
|---|
| 238 | | str) |
|---|
| 239 | | (setq size-x (and (match-string 1 str) |
|---|
| 240 | | (string-to-number (match-string 1 str))) |
|---|
| 241 | | size-y (and (match-string 2 str) |
|---|
| 242 | | (string-to-number (match-string 2 str))) |
|---|
| 243 | | str (substring str (match-end 0)))) |
|---|
| 244 | | (if (string-match |
|---|
| 245 | | (concat "^" location-regexp "\\(" location-regexp "\\)?") |
|---|
| 246 | | str) |
|---|
| 247 | | (setq location-x (match-string 1 str) |
|---|
| 248 | | location-y (match-string 2 str) |
|---|
| 249 | | location-x (funcall func location-x) |
|---|
| 250 | | location-y (funcall func location-y))) |
|---|
| 251 | | (if location-x |
|---|
| 252 | | (setq result (cons (cons 'left location-x) result))) |
|---|
| 253 | | (if location-y |
|---|
| 254 | | (setq result (cons (cons 'top location-y) result))) |
|---|
| 255 | | (if size-x |
|---|
| 256 | | (setq result (cons (cons 'width size-x) result))) |
|---|
| 257 | | (if size-y |
|---|
| 258 | | (setq result (cons (cons 'height size-y) result))) |
|---|
| 259 | | result)) |
|---|