diff options
| author | Richard M. Stallman | 2008-01-03 09:57:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2008-01-03 09:57:40 +0000 |
| commit | a32c180455b2d910aa8855e42dfc4ac900d14d6e (patch) | |
| tree | 3cd2ca572bb97f70bb794ed6f8889654a965b877 | |
| parent | f8edc67ee2346ad2a569bd0575208a2504cbc616 (diff) | |
| download | emacs-a32c180455b2d910aa8855e42dfc4ac900d14d6e.tar.gz emacs-a32c180455b2d910aa8855e42dfc4ac900d14d6e.zip | |
(frame-geom-value-cons, frame-geom-spec-cons): New fns.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/frame.el | 62 |
2 files changed, 66 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index da4dd53eda3..9228f8e93c6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2008-01-03 Drew Adams <drew.adams@oracle.com> | ||
| 2 | |||
| 3 | * frame.el (frame-geom-value-cons, frame-geom-spec-cons): New fns. | ||
| 4 | |||
| 1 | 2008-01-03 Richard Stallman <rms@gnu.org> | 5 | 2008-01-03 Richard Stallman <rms@gnu.org> |
| 2 | 6 | ||
| 3 | * replace.el (occur-context-lines): New subroutine, | 7 | * replace.el (occur-context-lines): New subroutine, |
diff --git a/lisp/frame.el b/lisp/frame.el index df3ed16f574..431aa343555 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -1329,6 +1329,68 @@ The value is one of the symbols `static-gray', `gray-scale', | |||
| 1329 | 'static-gray)))) | 1329 | 'static-gray)))) |
| 1330 | 1330 | ||
| 1331 | 1331 | ||
| 1332 | ;;;; Frame geometry values | ||
| 1333 | |||
| 1334 | (defun frame-geom-value-cons (type value &optional frame) | ||
| 1335 | "Return equivalent geometry value for FRAME as a cons with car `+'. | ||
| 1336 | A geometry value equivalent to VALUE for FRAME is returned, | ||
| 1337 | where the value is a cons with car `+', not numeric. | ||
| 1338 | TYPE is the car of the original geometry spec (TYPE . VALUE). | ||
| 1339 | It is `top' or `left', depending on which edge VALUE is related to. | ||
| 1340 | VALUE is the cdr of a frame geometry spec: (left/top . VALUE). | ||
| 1341 | If VALUE is a number, then it is converted to a cons value, perhaps | ||
| 1342 | relative to the opposite frame edge from that in the original spec. | ||
| 1343 | FRAME defaults to the selected frame. | ||
| 1344 | |||
| 1345 | Examples (measures in pixels) - | ||
| 1346 | Assuming display height/width=1024, frame height/width=600: | ||
| 1347 | 300 inside display edge: 300 => (+ 300) | ||
| 1348 | (+ 300) => (+ 300) | ||
| 1349 | 300 inside opposite display edge: (- 300) => (+ 124) | ||
| 1350 | -300 => (+ 124) | ||
| 1351 | 300 beyond display edge | ||
| 1352 | (= 724 inside opposite display edge): (+ -300) => (+ -300) | ||
| 1353 | 300 beyond display edge | ||
| 1354 | (= 724 inside opposite display edge): (- -300) => (+ 724) | ||
| 1355 | |||
| 1356 | In the 3rd, 4th, and 6th examples, the returned value is relative to | ||
| 1357 | the opposite frame edge from the edge indicated in the input spec." | ||
| 1358 | (cond ((and (consp value) (eq '+ (car value))) ; e.g. (+ 300), (+ -300) | ||
| 1359 | value) | ||
| 1360 | ((natnump value) (list '+ value)) ; e.g. 300 => (+ 300) | ||
| 1361 | (t ; e.g. -300, (- 300), (- -300) | ||
| 1362 | (list '+ (- (if (eq 'left type) ; => (+ 124), (+ 124), (+ 724) | ||
| 1363 | (x-display-pixel-width) | ||
| 1364 | (x-display-pixel-height)) | ||
| 1365 | (if (integerp value) (- value) (cadr value)) | ||
| 1366 | (if (eq 'left type) | ||
| 1367 | (frame-pixel-width frame) | ||
| 1368 | (frame-pixel-height frame))))))) | ||
| 1369 | |||
| 1370 | (defun frame-geom-spec-cons (spec &optional frame) | ||
| 1371 | "Return equivalent geometry spec for FRAME as a cons with car `+'. | ||
| 1372 | A geometry specification equivalent to SPEC for FRAME is returned, | ||
| 1373 | where the value is a cons with car `+', not numeric. | ||
| 1374 | SPEC is a frame geometry spec: (left . VALUE) or (top . VALUE). | ||
| 1375 | If VALUE is a number, then it is converted to a cons value, perhaps | ||
| 1376 | relative to the opposite frame edge from that in the original spec. | ||
| 1377 | FRAME defaults to the selected frame. | ||
| 1378 | |||
| 1379 | Examples (measures in pixels) - | ||
| 1380 | Assuming display height=1024, frame height=600: | ||
| 1381 | top 300 below display top: (top . 300) => (top + 300) | ||
| 1382 | (top + 300) => (top + 300) | ||
| 1383 | bottom 300 above display bottom: (top - 300) => (top + 124) | ||
| 1384 | (top . -300) => (top + 124) | ||
| 1385 | top 300 above display top | ||
| 1386 | (= bottom 724 above display bottom): (top + -300) => (top + -300) | ||
| 1387 | bottom 300 below display bottom | ||
| 1388 | (= top 724 below display top): (top - -300) => (top + 724) | ||
| 1389 | |||
| 1390 | In the 3rd, 4th, and 6th examples, the returned value is relative to | ||
| 1391 | the opposite frame edge from the edge indicated in the input spec." | ||
| 1392 | (cons (car spec) (frame-geom-value-cons (car spec) (cdr spec)))) | ||
| 1393 | |||
| 1332 | ;;;; Aliases for backward compatibility with Emacs 18. | 1394 | ;;;; Aliases for backward compatibility with Emacs 18. |
| 1333 | (define-obsolete-function-alias 'screen-height 'frame-height) ;before 19.15 | 1395 | (define-obsolete-function-alias 'screen-height 'frame-height) ;before 19.15 |
| 1334 | (define-obsolete-function-alias 'screen-width 'frame-width) ;before 19.15 | 1396 | (define-obsolete-function-alias 'screen-width 'frame-width) ;before 19.15 |