home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_HRULER.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  2.1 KB  |  80 lines

  1. *****************************************************************
  2. FUNCTION HRULER
  3. *****************************************************************
  4.  
  5. * Display a calibrated horizontal ruler line
  6.  
  7. * Copyright(c) 1991 - James Occhiogrosso
  8.  
  9. #include "inkey.ch"
  10. #include "setcurs.ch"
  11. # define RULER  '└┴┴┴┼┴┴┴┘'
  12.  
  13. LOCAL colcount, h_col := 0, h_row := INT(MAXROW()/2), ;
  14.       h_ruler := '', keypress := 0, old_col := COL(), old_color, ;
  15.       old_cursor, old_row := ROW(), old_screen
  16.  
  17. * Save entry conditions
  18. old_cursor = SETCURSOR(SC_NONE)
  19. old_color  = SETCOLOR(colbarhi)
  20. old_screen = SCRNSAVE(h_row, 0, h_row, MAXCOL())
  21.  
  22. * Define horizontal ruler
  23. FOR colcount = 0 TO MAXCOL() STEP 10
  24.     IF colcount % 10 = 0 .AND. colcount < 100
  25.         * Each 10th column less than 100
  26.         h_ruler := h_ruler + PAD(colcount, 1)
  27.     ELSEIF colcount % 10 = 0
  28.         * Each 10th column greater than 100
  29.         h_ruler := h_ruler + PAD(colcount-100, 1)
  30.     ENDIF
  31.     h_ruler := h_ruler +  RULER
  32. NEXT
  33.  
  34. * Display horizontal ruler
  35. @ h_row, 0 SAY h_ruler
  36.  
  37. * Process arrow keys for ruler movement
  38. DO WHILE keypress != K_ESC
  39.     keypress = INKEY(0)
  40.     SCRNREST(old_screen)
  41.  
  42.     * Adjust row and column for each arrow key pressed
  43.     IF keypress = K_RIGHT
  44.          h_col = IF(h_col < MAXCOL(), h_col+1, MAXCOL())
  45.  
  46.     ELSEIF keypress = K_LEFT
  47.          h_col = IF(h_col > 0, h_col-1, 0)
  48.  
  49.     ELSEIF keypress = K_UP
  50.          h_row = IF(h_row > 0, h_row-1, 0)
  51.          old_screen = SCRNSAVE(h_row, 0, h_row, MAXCOL())
  52.  
  53.     ELSEIF keypress = K_DOWN
  54.          h_row = IF(h_row < MAXROW(), h_row+1, MAXROW())
  55.          old_screen = SCRNSAVE(h_row, 0, h_row, MAXCOL())
  56.     ENDIF
  57.  
  58.     * Display ruler in new position
  59.     @ h_row, h_col SAY SUBSTR(h_ruler, 1, (MAXCOL() - h_col)+1)
  60.  
  61.     IF keypress = K_ALT_V
  62.         * Display vertical ruler
  63.         DO vruler
  64.     ENDIF
  65.  
  66.     IF keypress = K_ALT_H
  67.         * Display another horizontal ruler
  68.         DO hruler
  69.     ENDIF
  70.  
  71. ENDDO
  72.  
  73. * Restore entry conditions and return
  74. SCRNREST(old_screen)
  75. SETPOS(old_row, old_col)
  76. SETCOLOR(old_color)
  77. SETCURSOR(old_cursor)
  78. RETURN NIL
  79.  
  80.