HiTECNOLOGYs / cl-charms

More up-to-date version of cl-charms. Forked it because it was, apparently, abandoned by author and I couldn't contact him.
https://gitorious.org/cl-charms
Other
158 stars 29 forks source link

Fix window dimensions problem #31

Closed MatthewRock closed 8 years ago

MatthewRock commented 8 years ago

This is a response for issue #28 .

When creating a window, it's not updated and reports back wrong dimensions, which doesn't happen in programs written in C. The fix for this issue is updating the window right after its creation.

Example code that was failing previously, but works now:

(defun test ()
  (charms:with-curses ()
    (multiple-value-bind (width height) (charms:window-dimensions cl-charms:*standard-window*)
      (print (list width height)))))
stylewarning commented 8 years ago

There's double refreshing. Question: Is it better to refresh in INITIALIZE or is it better within WITH-CURSES? I suspect from within WITH-CURSES but I have no solid rationale as to why.

MatthewRock commented 8 years ago

I'm sorry. I thought I got rid of it.

I think that INITIALIZE should do refreshing, not the WITH-CURSES. Here's why:

INITIALIZE's job is to provide everything you need to start working with curses. After that, you use FINALIZE (if I remember the name correctly) to clean up after yourself.

The WITH-CURSES macro is a utility that basically does this for you.

Now if we put this in INITIALIZE, we both fix the issue, and make sure that anybody has usable console window from the beginning. The window that is initialised should have proper dimensions. If we shift this towards macro, we might find a user who decides to write some other macro, and he'll have to remember to refresh the window. This might be confusing, and is really outside the scope of with-curses macro, I guess.