home *** CD-ROM | disk | FTP | other *** search
- * Windows.prg
- *
- * Windows class
-
- #include "system.h"
-
- * CHARACTER win_save(t, l, b, r)
- *
- * NUMERIC t, l, b, r - Window coordinates. Optional, default to
- * 0, 0, 24, 79 (full screen)
- *
- * Return combined coordinates and screen area
-
- FUNCTION win_save
-
- PARAM t, l, b, r
-
- * Assign defaults to optional parameters
- P_DEF(t, 0)
- P_DEF(l, 0)
- P_DEF(b, 24)
- P_DEF(r, 79)
-
- RETURN chr(t) + chr(l) + chr(b) + chr(r) + ;
- savescreen(t, l, b, r)
-
-
-
-
- * Windows.h
- *
- * Windows class
-
- #define GET_T(win_str) asc(substr(win_str, 1, 1))
- #define GET_L(win_str) asc(substr(win_str, 2, 1))
- #define GET_B(win_str) asc(substr(win_str, 3, 1))
- #define GET_R(win_str) asc(substr(win_str, 4, 1))
-
-
- * Windows.h
- *
- * Windows class
- *
- * GET_WIN() Return window from window structure
-
- * Number of characters occupied by the coordinates
- #define COORD_SIZE 4
-
- * The actual window
- #define GET_WIN(win_str) substr(win_str, COORD_SIZE + 1)
-
-
-
- * Windows.prg
- *
- * Windows class
-
- #include "system.h"
- #include "windows.h"
-
- * VOID win_rest(scr_str)
- *
- * CHARACTER scr_str - A character string returned from win_save
- *
- * Restore sceeen from a packed screen structure ...
-
- FUNCTION win_rest
-
- PARAM scr_str
-
- restscreen(GET_T(scr_str), GET_L(scr_str), ;
- GET_B(scr_str), GET_R(scr_str), ;
- GET_WIN(scr_str))
-
- RETURN VOID
-
-
-
- * Windows.prg
- *
- * Windows class
-
- #include "system.h"
- #include "windows.h"
-
-
- * NUMERIC win_size(win_coords)
- *
- * CHARACTER win_coords
- *
- * Return size of window defined by win_coords
- *
- * This could be a compiler macro, but the line would be too long ...
-
- FUNCTION win_size
-
- PARAM win_coords
-
- RETURN ((GET_B(win_coords) - GET_T(win_coords) + 1) * ;
- (GET_R(win_coords) - GET_L(win_coords) + 1)) * 2 + ;
- COORD_SIZE
-
-
-
-
- * Windows.prg
- *
- * Windows class
-
- #include "system.h"
- #include "windows.h"
-
-
- * VOID win_init()
- *
- * Initialization of screen stack
-
- FUNCTION win_init
-
- PUBLIC scr_stk && The stack variable
-
- scr_stk = NULLC && Empty character string
-
- RETURN VOID
-
-
- * VOID win_end()
- *
- * Release this Class's data
-
- FUNCTION win_end
-
- RELEASE scr_stk
-
- RETURN VOID
-
-
- * VOID win_push(t, l, b, r)
- *
- * NUMERIC t, l, b, r - Window coordinates. Optional.
- * - Default to 0, 0, 24, 79 (full screen)
- *
- *
- * Push a screen structure on scr_stk
-
- FUNCTION win_push
-
- PARAM t, l, b, r
-
- * Assign defaults to optional parameters
- P_DEF(t, 0)
- P_DEF(l, 0)
- P_DEF(b, 24)
- P_DEF(r, 79)
-
- * Push on stack (LHS of string)
- scr_stk = win_save(t, l, b, r) + scr_stk
-
- RETURN VOID
-
-
- * VOID win_pop()
- *
- * Pop a screen structure off scr_stk, restoring screen
-
- FUNCTION win_pop
-
- PRIVATE saved_scr_len
-
- saved_scr_len = win_size(scr_stk)
-
- win_rest(substr(scr_stk, 1, saved_scr_len))
-
- * pop off stack
- scr_stk = substr(scr_stk, saved_scr_len + 1)
-
- RETURN VOID
-
-
- #ifdef WIN_TEST
- * Initialize windows class
- win_init()
-
- SET CURSOR OFF
- CLEAR
- inkey(0)
-
- * save the empty screen
- win_push()
-
- * draw the first window and pause
- @ 10, 10 TO 20, 20 DOUBLE
- @ 11, 11 SAY "WIN 1"
- inkey(0)
-
- * Push this window onto the stack
- win_push(10, 10, 20, 20)
-
- * Draw the second window and pause
- @ 12, 12 TO 18, 19
- @ 13, 13 SAY "WIN 2"
- inkey(0)
-
- * restore the first window and pause
- win_pop()
- inkey(0)
-
- * restore the empty screen and pause
- win_pop()
- inkey(0)
-
- * Close the windows class
- win_end()
- #endif
-
-
-
- * files.h
- *
- * Header file for low level file handling primitives
-
- #define OPEN_RDONLY 0
- #define OPEN_WRONLY 1
- #define OPEN_RDWR 2
-
- #define CREAT_RDWR 0
- #define CREAT_RDONLY 1
- #define CREAT_HIDDEN 2
- #define CREAT_SYSTEM 4
- #define CREAT_LABEL 8
- #define CREAT_SUBDIR 16
- #define CREAT_ARCHIVE 32
-
- #define SEEK_BOF 0
- #define SEEK_CUR 1
- #define SEEK_EOF 2
-
- * Return current file position
- #define FTELL(f_handle) fseek(f_handle, 0, SEEK_CUR)
-
-
-
-
- * VOID win_init()
- *
- * Initialization of screen stack
-
- FUNCTION win_init
-
- PUBLIC f_handle, ; && The file handle
- f_ptrs && File pointers stack
-
- f_handle = fcreate("_fwindow")
- f_ptrs = NULLC
-
- RETURN VOID
-
-
- * VOID win_end()
- *
- * Release this Class's data
-
- FUNCTION win_end
-
- fclose(f_handle)
- RELEASE f_handle, f_ptrs
-
- RETURN VOID
-
-
-
- #define LEN_PTR 5
-
- * VOID win_push(t, l, b, r)
- *
- * NUMERIC t, l, b, r - Window coordinates. Optional.
- * - Default to 0, 0, 24, 79 (full screen)
- *
- *
- * Push a screen structure on scr_stk
-
- FUNCTION win_push
-
- PARAM t, l, b, r
-
- * Assign defaults to optional parameters
- P_DEF(t, 0)
- P_DEF(l, 0)
- P_DEF(b, 24)
- P_DEF(r, 79)
-
- * Push current file position onto pointers stack
- f_ptrs = str(FTELL(f_handle), LEN_PTR) + f_ptrs
-
- * Write to file
- fwrite(f_handle, win_save(t, l, b, r))
-
- RETURN VOID
-
-
-
- * VOID win_pop()
- *
- * Pop a screen structure off scr_stk, restoring screen
-
- FUNCTION win_pop
-
- PRIVATE f_ptr, saved_scr_len, win
-
- * Pop pointers
- f_ptr = val(substr(f_ptrs, 1, LEN_PTR))
- f_ptrs = substr(f_ptrs, LEN_PTR + 1)
-
- * Seek to start of this saved entry
- fseek(f_handle, f_ptr)
-
- * Determine size so we can allocate space and read it
- saved_scr_len = win_size()
-
- * Now read this window. Note, we cannot use freadstr here, because
- * it stops with a NULL (chr(0))
- win = space(saved_scr_len)
- fread(f_handle, @win, len(win))
-
- * Restore this window
- win_rest(win)
-
- * Now reposition file pointer
- fseek(f_handle, f_ptr)
-
- RETURN VOID
-
-
-
- * NUMERIC win_size()
- *
- * PARAM win_coords
- *
- * Return size of window at current file position
-
- FUNCTION win_size
-
- PRIVATE save_pos, win_coords
-
- * we can't disturb current file position. Save it first ...
- save_pos = FTELL(f_handle)
-
- * allocate space for coordinates and read them
- win_coords = space(COORD_SIZE)
- fread(f_handle, @win_coords, len(win_coords))
-
- * now reposition file pointer
- fseek(f_handle, save_pos)
-
- RETURN ((GET_B(win_coords) - GET_T(win_coords) + 1) * ;
- (GET_R(win_coords) - GET_L(win_coords) + 1)) * 2 + ;
- COORD_SIZE
-
-
-
-
- * PRG.....: windows
- * CLASS...: windows
- * DESC....: Stack based windows save and restore, for 5.0
- * PREFIX..: win
- * EXPORT..: win_init()
- * win_end()
- * win_push()
- * win_pop()
- * USES....:
- * NOTES...: Must call win_init before any pushes
-
- #include "system.h"
- #include "windows.h"
-
- STATIC scr_stk := NULLC
-
- * NUMERIC win_size(win_coords)
- *
- * CHARACTER win_coords
- *
- * Return size of window defined by win_coords
- *
- * This could be a compiler macro, but the line would be too long ...
-
- STATIC FUNCTION win_size(win_coords)
-
- RETURN ((GET_B(win_coords) - GET_T(win_coords) + 1) * ;
- (GET_R(win_coords) - GET_L(win_coords) + 1)) * 2 + ;
- COORD_SIZE
-
- * CHARACTER win_save(t, l, b, r)
- *
- * NUMERIC t, l, b, r - Window coordinates. Optional, default to
- * 0, 0, 24, 79 (full screen)
- *
- * Return combined coordinates and screen area
-
- STATIC FUNCTION win_save(t, l, b, r)
-
- * Assign defaults to optional parameters
- P_DEF(t, 0)
- P_DEF(l, 0)
- P_DEF(b, 24)
- P_DEF(r, 79)
-
- RETURN chr(t) + chr(l) + chr(b) + chr(r) + ;
- savescreen(t, l, b, r)
-
-
- * VOID win_rest(scr_str)
- *
- * CHARACTER scr_str - A character string returned from win_save
- *
- * Restore sceeen from a packed screen structure ...
-
- STATIC FUNCTION win_rest(scr_str)
-
- restscreen(GET_T(scr_str), GET_L(scr_str), ;
- GET_B(scr_str), GET_R(scr_str), ;
- GET_WIN(scr_str))
-
- RETURN VOID
-
-
- * VOID win_push(t, l, b, r)
- *
- * NUMERIC t, l, b, r - Window coordinates. Optional.
- * - Default to 0, 0, 24, 79 (full screen)
- *
- *
- * Push a screen structure on scr_stk
-
- FUNCTION win_push(t, l, b, r)
-
- * Assign defaults to optional parameters
- P_DEF(t, 0)
- P_DEF(l, 0)
- P_DEF(b, 24)
- P_DEF(r, 79)
-
- * Push on stack (LHS of string)
- scr_stk = win_save(t, l, b, r) + scr_stk
-
- RETURN VOID
-
-
- * VOID win_pop()
- *
- * Pop a screen structure off scr_stk, restoring screen
-
- FUNCTION win_pop
-
- LOCAL saved_scr_len
-
- saved_scr_len = win_size(scr_stk)
-
- win_rest(substr(scr_stk, 1, saved_scr_len))
-
- * pop off stack
- scr_stk = substr(scr_stk, saved_scr_len + 1)
-
- RETURN VOID
-
-
-
-
- * PRG.....: fwindows
- * CLASS...: windows
- * DESC....: File based windows save and restore
- * PREFIX..: win
- * EXPORT..: win_init()
- * win_end()
- * win_push()
- * win_pop()
- * USES....:
- * NOTES...: Must call win_init before any pushes
-
- #include "system.h"
- #include "windows.h"
- #include "files.h"
-
- #define LEN_PTR 5
- #define FTELL(f_handle) fseek(f_handle, 0, SEEK_CUR)
-
- STATIC f_ptrs := NULLC && The pointers stack
- STATIC f_handle && The file handle
-
- * CHARACTER win_save(t, l, b, r)
- *
- * NUMERIC t, l, b, r - Window coordinates. Optional, default to
- * 0, 0, 24, 79 (full screen)
- *
- * Return combined coordinates and screen area
-
- STATIC FUNCTION win_save(t, l, b, r)
-
- * Assign defaults to optional parameters
- P_DEF(t, 0)
- P_DEF(l, 0)
- P_DEF(b, 24)
- P_DEF(r, 79)
-
- RETURN chr(t) + chr(l) + chr(b) + chr(r) + ;
- savescreen(t, l, b, r)
-
-
- * VOID win_rest(scr_str)
- *
- * CHARACTER scr_str - A character string returned from win_save
- *
- * Restore sceeen from a packed screen structure ...
-
- STATIC FUNCTION win_rest(scr_str)
-
- restscreen(GET_T(scr_str), GET_L(scr_str), ;
- GET_B(scr_str), GET_R(scr_str), ;
- GET_WIN(scr_str))
-
- RETURN VOID
-
-
- * NUMERIC win_size()
- *
- * PARAM win_coords
- *
- * Return size of window at current file position
-
- STATIC FUNCTION win_size
-
- LOCAL save_pos, win_coords
-
- * we can't disturb current file position. Save it first ...
- save_pos = FTELL(f_handle)
-
- * allocate space for coordinates and read them
- win_coords = space(COORD_SIZE)
- fread(f_handle, @win_coords, len(win_coords))
-
- * now reposition file pointer
- fseek(f_handle, save_pos)
-
- RETURN ((GET_B(win_coords) - GET_T(win_coords) + 1) * ;
- (GET_R(win_coords) - GET_L(win_coords) + 1)) * 2 + ;
- COORD_SIZE
-
-
- * VOID win_init()
- *
- * Initialization of screen stack
-
- FUNCTION win_init
-
- f_handle = fcreate("_fwindow")
-
- RETURN VOID
-
-
- * VOID win_end()
- *
- * Release this Class's data
-
- FUNCTION win_end
-
- fclose(f_handle)
-
- RETURN VOID
-
-
- * VOID win_push(t, l, b, r)
- *
- * NUMERIC t, l, b, r - Window coordinates. Optional.
- * - Default to 0, 0, 24, 79 (full screen)
- *
- *
- * Push a screen structure on scr_stk
-
- FUNCTION win_push(t, l, b, r)
-
- * Assign defaults to optional parameters
- P_DEF(t, 0)
- P_DEF(l, 0)
- P_DEF(b, 24)
- P_DEF(r, 79)
-
- * Push current file position onto pointers stack
- f_ptrs = str(FTELL(f_handle), LEN_PTR) + f_ptrs
-
- * Write to file
- fwrite(f_handle, win_save(t, l, b, r))
-
- RETURN VOID
-
-
- * VOID win_pop()
- *
- * Pop a screen structure off scr_stk, restoring screen
-
- FUNCTION win_pop
-
- LOCAL f_ptr, saved_scr_len, win
-
- * Pop pointers
- f_ptr = val(substr(f_ptrs, 1, LEN_PTR))
- f_ptrs = substr(f_ptrs, LEN_PTR + 1)
-
- * Seek to start of this saved entry
- fseek(f_handle, f_ptr)
-
- * Determine size so we can allocate space and read it
- saved_scr_len = win_size()
-
- * Now read this window. Note, we cannot use freadstr here, because
- * it stops with a NULL (chr(0))
- win = space(saved_scr_len)
- fread(f_handle, @win, len(win))
-
- * Restore this window
- win_rest(win)
-
- * Now reposition file pointer
- fseek(f_handle, f_ptr)
-
- RETURN VOID
-
-