As we discussed, the goal is to have something like:
In libindep.c: move() line_to() line() text()
in libdev.c: move_() line_to_() line_() text_()
Here line_to() is the same as connect() - I may use either name at times. We also could name the libdec files as move_dev() etc.
Some of these may do nothing or not even be called. For example, move() just moves the CP in world coords. Therefore unless you decide to track an image of the CP in screen coords, there is no reason to need a move_() - but see below.
Also only one of line() or line_to() is needed because the other one can be written in terms of the first.
One strategy is to regard line() as the basic one. You would then write:
libindep.c:
move(x,y) double x,y; { CPx = x; CPy = y; }
line(x1,y1,x2,y2) { call line_() with suitable arguments move(x2,y2) }
line_to(x,y) { line(CPx,CPy,x,y) }
There would then be no move_() and no line_to_() The only device dependent routine would be line_(), In assignment 1, line_() will just draw a horiz or vert line and in assignment 2 it will be improved to do a full bresenham type algorithm allowing a line at any angle.
One problem with this is the text() operation. The text() operation is supposed to place the text at the CP - or rather at its image on the screen. But with the above plan, the libdev.c has no idea where the CP is. One way around this: is to create a move_() whose only purpose is to track the CP on the screen and then modify move() by adding a call to move_() as its last line. That way after every move or line is done, the libdev file will know where on the screen the CP lies. However one should add a warning: if the CP is outside the window, then the corresponding point on the screen does not exist. Clipping is supposed to take care of this issue.
Another solution is to keep a CP_ = cps_, cpt_ in libdev.c. Since the only device routine that manipulates CP_ is line_(), you would end line_ with a line that sets CP_ to the end of the line. Then if a text call is made, text_ will know where the text is to go. It should also reset CP_.