POV-Ray : Newsgroups : povray.general : Problem making macro work right : Re: Problem making macro work right Server Time
8 Aug 2024 06:14:24 EDT (-0400)
  Re: Problem making macro work right  
From: Warp
Date: 20 Feb 2001 06:03:59
Message: <3a924f1f@news.povray.org>
Dan Johnson <zap### [at] hotmailcom> wrote:
:>   By the way, I think that you are missing some #breaks in your #switch.

: Well the POV-Ray docs said that the #breaks were optional, and I usually do things
the easy way.

  Well, they are optional in the sense that they are not obligatory. Povray
will not give you an error if you don't put them there.
  However, if the docs say just that they are optional giving the impression
that the behaviour doesn't change whether you put the #break or not, then
the docs are misleading.
  Yes, you can leave out the #breaks, but then the behaviour of the #switch
changes. And it changes in a way which you probably don't want.
  A #case not ending with a #break will continue with the next #case. That
is, here:

#declare Var=1;
#switch(Var)
  #case(1) #declare Res=1; #break
  #case(2) #declare Res=2; #break
#end

the value of 'Res' will be 1. However, here:

#declare Var=1;
#switch(Var)
  #case(1) #declare Res=1;
  #case(2) #declare Res=2;
#end

the value of 'Res' will be 2.

  And before you ask: Yes, it has some practical uses when working this way.
And yes, this behaviour comes from C.

: I know now that I can never truly be
: happy with windows, because most of the truly powerful computers in the world use
unix.

  Well, the power of those computers come more from the hardware than from
the OS. Those computers usually have hundreds of processors and gigabytes
of RAM.
  Of course it's true that unices can handle that amount of resources a lot
more efficiently than any version of windows (AFAIK even NT freezes when
there are 16 processors or something like that in the computer; I don't know
about w2k). However, in a 1-processor computer with a regular amount of RAM,
having a unix variant will probably not give you any considerable speed
increase (except perhaps in cases where you are running LOTS of processes;
however povray is not one of these cases).
  Unix variants, however, have many other handy features by default that
are either missing completely in Windows or are quite expensive. This doesn't
mean, of course, that there aren't things that are handier in Windows than
in Unix.
  Perhaps the biggest problem with Unix variants is the higher learning
curve and a completely different ideology and application field. Whether
you will be needing unix or not depends a lot on what you are doing (as
your hobby or even as your work).
  In my work Unix is almost essential. If I had to use Windows, I would have
grown gray hair long time ago (because of, among another things, the lack
of versatility, tools and stability).
  However, at home I have win98 in my computer. I have tried Linux, but
deleted it afterwards because I just don't use it at home (the main reason
being perhaps that I don't have internet connection at home). For the things
I do at home (playing games, music, graphics...) win98 is more than enough
(although sometimes I really miss some handy features of unices).

: Maybe one of the code gurus can tell me how to make emacs look a
: little more like this

: http://www.cs.tut.fi/~warp/snapshot.gif

  Although emacs is extremely versatile and powerful, it has one very big
problem: It's extremely difficult to configure. I have always cursed that
and always will.
  In later versions of emacs (I don't know from which version) some
improvements has been added: A customize mode has been added, which makes
configuring emacs a lot easier. It still isn't that easy to configure
everything after all, but it helps a lot (for example with the colors).

  Anyways, this is the essential part of my .emacs which configures not
only pov-mode but also colors and many key combinations (to work more like
in windows editors, for example shift+cursor movement paints the text,
ctrl-ins copies and shift-ins pastes, etc; these work only when emacs is
run from X and they don't work with xemacs (don't ask me why)).
  I commented it a bit so that you can see what features it adds:

-------------8<-------------8<-------------8<-------------8<-------------
;;; This line adds LOTS of stuff in emacs (doesn't work with xemacs).
;;; Among other things it adds ctrl+cursor movement painting and other
;;; typical windows-editor editing keys:
(pc-selection-mode)

;;; Show also column number besides line number:
(column-number-mode t)

;;; Doesn't add new lines at the end of the doc when pressing return:
(setq next-line-add-newlines nil)

;;; Misc settings:
(setq auto-save-default nil)
(setq scroll-step 1)
(set-background-color "black")
(set-foreground-color "white")
(set-cursor-color "yellow")
(standard-display-european t) 
(set-input-mode (car (current-input-mode)) 
                (nth 1 (current-input-mode)) 
                0) 

;;; Fix home, end and delete to work as in windows:
(global-set-key '[home] 'beginning-of-line)
(global-set-key '[end] 'end-of-line)
(global-set-key '[delete] 'delete-char)

;;; Use ctrl-y to immediately kill a line. Handier than ctrl-k
(global-set-key "\C-y" 'kill-complete-line)

;;; Other key settings. Should be self-explanatory:
(global-set-key [(alt x)] 'save-buffers-kill-emacs)
(global-set-key [(alt f3)] 'delete-window)
(global-set-key '[f2] 'save-buffer)
(global-set-key '[f9] 'compile)
(global-set-key "\C-r" 'insert-file)

;;; Fix backspace to delete chars instead of popping up the help. To pop
;;; up the help, press F1:
(global-set-key "\C-h" 'delete-backward-char)

;;; Misc help functions:
(auto-fill-mode)
(defun kill-complete-line () 
  "Kill the complete line." 
  (interactive) 
  (beginning-of-line) 
  (if (eobp) (error "End of buffer")) 
  (let ((beg (point))) 
    (forward-line 1) 
    (kill-region beg (point)))) 

(setq font-lock-maximum-decoration t) 
(global-font-lock-mode t) 

(setq backup-inhibited 't)

(defun contents-move (dir checkpoint)
  (let ((oldColumn (current-column)))
    (if (not (pos-visible-in-window-p checkpoint))
        ((lambda ()
           (save-excursion
             (goto-char (window-start))
             (forward-line dir)
             (set-window-start (selected-window) (point))))))
    (forward-line dir)
    (move-to-column oldColumn)))
 
(defun contents-one-down ()
  (interactive)
  (contents-move -1 (point-min)))
 
(defun contents-one-up ()
  (interactive)
  (contents-move 1 (point-max)))
 
(defun generic-page-scroll (lines)
  (let ((oldColumn (current-column)))
    (save-excursion
      (goto-char (window-start))
      (forward-line lines)
      (set-window-start (selected-window) (point)))
    (forward-line lines)
    (move-to-column oldColumn)))
 
(defun page-scroll-up ()
  (interactive)
  (if (not (pos-visible-in-window-p (point-max)))
      (generic-page-scroll (- (1- (window-height)) next-screen-context-lines))
    (goto-char (point-max))))
 
(defun page-scroll-down ()
  (interactive)
  (if (not (pos-visible-in-window-p (point-min)))
      (generic-page-scroll (- next-screen-context-lines (1- (window-height))))
    (goto-char (point-min))))
 
;;; Use ctrl-up and ctrl-down to scroll the page
(global-set-key '[(control up)] 'contents-one-down)
(global-set-key '[(control down)] 'contents-one-up)

;;; Fix page up and page down behaviour to work as it should
(global-set-key '[next] 'page-scroll-up)
(global-set-key '[prior] 'page-scroll-down)

;; POV-Ray related stuff
;; =====================
;; Fix the path here:
(autoload 'pov-mode "/home/warp/temp/pov-mode.elc" "PoVray scene file mode" t)
(setq auto-mode-alist
      (append '(("\\.pov$" . pov-mode)
                ("\\.inc$" . pov-mode)
                ("\\.mcr$" . pov-mode))
              auto-mode-alist))
(add-hook 'pov-mode-hook 'turn-on-font-lock)


;;; Insert file at the current position uuencoded
(defun insert-file-uuencoded (filename)
  (interactive "fInsert file (uuencoded): ")
  (shell-command (concat "uuencode " filename " " (substring filename (string-match
"[^/]+$" filename)) " | sed 's/^ $/`/'") t)
)

(global-set-key [(control c) (control u)] 'insert-file-uuencoded)

;;; Kill all whitespace chars forward from cursor with ctrl-t
(defun kill-white-space()
  (interactive)
  (if (re-search-forward "\\(\\s-\\|\n\\)+" nil t)
      (replace-match "")))

(global-set-key '[(control t)] 'kill-white-space)


;; Color settings
(custom-set-variables)
(custom-set-faces
 '(font-lock-comment-face ((((class color) (background dark)) (:foreground
"ForestGreen"))))
 '(font-lock-string-face ((((class color) (background dark)) (:foreground
"Magenta"))))
 '(region ((t (:foreground "black" :background "#99CCFF"))))
 '(font-lock-keyword-face ((((class color) (background dark)) (:foreground
"Yellow"))))
 '(font-lock-constant-face ((((class color) (background dark)) (:foreground
"GreenYellow"))))
 '(font-lock-type-face ((((class color) (background dark)) (:foreground "#40A0FF"))))
 '(modeline ((t (:foreground "yellow" :background "Blue"))))
 '(font-lock-variable-name-face ((((class color) (background dark)) (:foreground
"thistle"))))
 '(font-lock-function-name-face ((((class color) (background dark)) (:foreground
"Coral"))))
 '(font-lock-builtin-face ((((class color) (background dark)) (:foreground
"Green")))))


;;; C indentation settings
(defun oma-c-mode-common-hook ()
  (interactive)
  (setq c-basic-offset 4)
  (c-set-offset 'substatement-open 0)
  (c-set-offset 'case-label 2)
  (c-set-offset 'block-open 0)
  (c-set-offset 'knr-argdecl-intro '-)
  (c-set-offset 'arglist-close 'c-lineup-arglist)
  (c-set-offset 'access-label -3)
  (c-set-offset 'inclass 4)	
  (c-set-offset 'inline-open 0)
  (setq tab-width 8
        ;; this will make sure spaces are used instead of tabs
        indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'oma-c-mode-common-hook)

-------------8<-------------8<-------------8<-------------8<-------------



-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.