home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / wrdwrp / edits.asm < prev    next >
Encoding:
Assembly Source File  |  1992-01-03  |  7.6 KB  |  292 lines

  1. ;/*------------------------------------------------------------*/
  2. ;/* filename -       edits.asm                                 */
  3. ;/*                                                            */
  4. ;/* function(s)                                                */
  5. ;/*                  TEditor member functions                  */
  6. ;/*------------------------------------------------------------*/
  7.  
  8. ;/*------------------------------------------------------------*/
  9. ;/*                                                            */
  10. ;/*    Turbo Vision -  Version 1.0                             */
  11. ;/*                                                            */
  12. ;/*                                                            */
  13. ;/*    Copyright (c) 1991 by Borland International             */
  14. ;/*    All Rights Reserved.                                    */
  15. ;/*                                                            */
  16. ;/*------------------------------------------------------------*/
  17.  
  18. ; Primatech Modifications History:
  19.  
  20. ;** JAH 11-12-91 Check for soft-return, allow variable-size tabs
  21. ;** JLS 01-02-92 Added CLD at end of lineStart function as in BC++ 3.0
  22.  
  23.  
  24.         IDEAL
  25.         MODEL LARGE, PROLOG
  26.  
  27.         INCLUDE "TVWRITE.INC"
  28.  
  29.         PUBLIC @TEditor@bufChar$qus
  30.         PUBLIC @TEditor@bufPtr$qus
  31.         PUBLIC @TEditor@formatLine$qnvusius
  32.         PUBLIC @TEditor@lineEnd$qus
  33.         PUBLIC @TEditor@lineStart$qus
  34.         PUBLIC @TEditor@nextChar$qus
  35.         PUBLIC @TEditor@prevChar$qus
  36.  
  37. CODESEG
  38.  
  39.  
  40. ;char TEditor::bufChar( ushort P )
  41. PROC    @TEditor@bufChar$qus
  42.  
  43.         ARG   thisPtr:FAR PTR, P:WORD
  44.         USES  DI
  45.  
  46.         LES   DI,[thisPtr]
  47.         MOV   BX,[P]
  48.         CMP   BX,[ES:DI+TEditorCurPtr]
  49.         JB    @@1
  50.         ADD   BX,[ES:DI+TEditorGapLen]
  51. @@1:    LES   DI,[ES:DI+TEditorBuffer]
  52.         MOV   AL,[ES:DI+BX]
  53.         RET
  54. ENDP
  55.  
  56.  
  57. ;function TEditor.bufPtr(P: Word): Word; assembler;
  58. PROC    @TEditor@bufPtr$qus
  59.  
  60.         ARG   thisPtr:FAR PTR, P:WORD
  61.         USES  DI
  62.  
  63.         LES   DI,[thisPtr]
  64.         MOV   AX,[P]
  65.         CMP   AX,[ES:DI+TEditorCurPtr]
  66.         JB    @@1
  67.         ADD   AX,[ES:DI+TEditorGapLen]
  68. @@1:    RET
  69. ENDP
  70.  
  71.  
  72. ;void TEditor::formatLine( void *DrawBuf,
  73. ;                          ushort LinePtr,
  74. ;                          int Wide,
  75. ;                          ushort Colors
  76. ;                        )
  77. PROC    @TEditor@formatLine$qnvusius
  78.  
  79.         ARG   thisPtr:FAR PTR, DrawBuf:FAR PTR, LinePtr:WORD, Wide:WORD, Colors:WORD
  80.         USES  DS,SI,DI
  81.         LOCAL TabSize:BYTE, Count:BYTE
  82.  
  83.         LDS   BX,[thisPtr]
  84.         LES   DI,[DrawBuf]
  85.         MOV   SI,[LinePtr]
  86.         MOV   AL,[DS:BX+TEditorTabSize]
  87.         MOV   [TabSize],AL
  88.         XOR   DX,DX
  89.         CLD
  90.         MOV   AH,[BYTE PTR Colors]
  91.         MOV   CX,[DS:BX+TEditorSelStart]
  92.         CALL  @@10
  93.         MOV   AH,[BYTE PTR Colors+1]
  94.         MOV   CX,[DS:BX+TEditorCurPtr]
  95.         CALL  @@10
  96.         ADD   SI,[DS:BX+TEditorGapLen]
  97.         MOV   CX,[DS:BX+TEditorSelEnd]
  98.         ADD   CX,[DS:BX+TEditorGapLen]
  99.         CALL  @@10
  100.         MOV   AH,[BYTE PTR Colors]
  101.         MOV   CX,[DS:BX+TEditorBufSize]
  102.         CALL  @@10
  103.         JMP   @@31
  104. @@10:   SUB   CX,SI
  105.         JA    @@11
  106.         RETN
  107. @@11:   LDS   BX,[DS:BX+TEditorBuffer]
  108.         ADD   SI,BX
  109.         MOV   BX,[Wide]
  110. @@12:   LODSB
  111.         CMP   AL,' '
  112.         JB    @@20
  113. @@13:   STOSW
  114.         INC   DX
  115. @@14:   CMP   DX,BX
  116.         JAE   @@30
  117.         LOOP  @@12
  118.         LDS   BX,[thisPtr]
  119.         SUB   SI,[WORD PTR DS:BX+TEditorBuffer]
  120.         RETN
  121. @@20:   CMP   AL,0Dh
  122.         JE    @@29        ;@@30
  123.         CMP   AL,09h
  124.         JNE   @@13
  125.         PUSH  AX
  126.         MOV   AX,DX
  127.         DIV   [TabSize]         ;AH=remainder, AL=quotient
  128.         MOV   AL,[TabSize]
  129.         SUB   AL,AH             ;compute spaces to next tab stop
  130.         MOV   [Count],AL
  131.         POP   AX
  132.         MOV   AL,' '            ;put spaces in output buffer
  133. @@21:   STOSW
  134.         INC   DX
  135.         CMP   DX,BX
  136.         JAE   @@30
  137.         DEC   [Count]
  138.         JNZ   @@21
  139.         JMP   @@14
  140. @@29:   JCXZ  @@30              ;
  141.         LODSB                   ;
  142.         CMP   AL,0Ah            ;have CR, check for hard-return (CR+LF)
  143.         JNE   @@30              ;
  144.         MOV   AL,250            ;
  145.         STOSW                   ;
  146.         INC   DX                ;
  147. @@30:   POP   CX
  148. @@31:   MOV   AL,' '
  149.         MOV   CX,[Wide]
  150.         SUB   CX,DX
  151.         JBE   @@32
  152.         REP   STOSW
  153. @@32:   RET
  154. ENDP
  155.  
  156.  
  157. ;function TEditor.lineEnd(P: Word): Word; assembler;
  158. PROC    @TEditor@lineEnd$qus
  159.  
  160.         ARG   thisPtr:FAR PTR, P:WORD
  161.         USES  DS,SI,DI
  162.  
  163.         LDS   SI,[thisPtr]
  164.         LES   BX,[DS:SI+TEditorBuffer]
  165.         MOV   DI,[P]
  166.         MOV   AL,0Dh
  167.         CLD
  168.         MOV   CX,[DS:SI+TEditorCurPtr]
  169.         SUB   CX,DI
  170.         JBE   @@1
  171.         ADD   DI,BX
  172.         REPNE SCASB
  173.         JE    @@2
  174.         MOV   DI,[DS:SI+TEditorCurPtr]
  175. @@1:    MOV   CX,[DS:SI+TEditorBufLen]
  176.         SUB   CX,DI
  177.         JCXZ  @@4
  178.         ADD   BX,[DS:SI+TEditorGapLen]
  179.         ADD   DI,BX
  180.         REPNE SCASB
  181.         JNE   @@3
  182. @@2:    DEC   DI
  183. @@3:    SUB   DI,BX
  184. @@4:    MOV   AX,DI
  185.         RET
  186. ENDP
  187.  
  188.  
  189. ;function TEditor.lineStart(P: Word): Word; assembler;
  190. PROC    @TEditor@lineStart$qus
  191.  
  192.         ARG   thisPtr:FAR PTR, P:WORD
  193.         USES  DS,SI,DI
  194.  
  195.         LDS   SI,[thisPtr]
  196.         LES   BX,[DS:SI+TEditorBuffer]
  197.         MOV   DI,[P]
  198.         MOV   AL,0Dh
  199.         STD
  200.         MOV   CX,DI
  201.         SUB   CX,[DS:SI+TEditorCurPtr]
  202.         JBE   @@1
  203.         ADD   BX,[DS:SI+TEditorGapLen]
  204.         ADD   DI,BX
  205.         DEC   DI
  206.         REPNE SCASB
  207.         JE    @@2
  208.         SUB   BX,[DS:SI+TEditorGapLen]
  209.         MOV   DI,[DS:SI+TEditorCurPtr]
  210. @@1:    MOV   CX,DI
  211.         JCXZ  @@4
  212.         ADD   DI,BX
  213.         DEC   DI
  214.         REPNE SCASB
  215.         JNE   @@3
  216. @@2:    INC   DI
  217.         INC   DI
  218.         SUB   DI,BX
  219.         CMP   DI,[DS:SI+TEditorCurPtr]
  220.         JE    @@4
  221.         CMP   DI,[DS:SI+TEditorBufLen]
  222.         JE    @@4
  223.         CMP   [BYTE PTR ES:BX+DI],0Ah
  224.         JNE   @@4
  225.         INC   DI
  226.         JMP   @@4
  227. @@3:    XOR   DI,DI
  228. @@4:    MOV   AX,DI
  229.         CLD
  230.         RET
  231. ENDP
  232.  
  233.  
  234. ;function TEditor.nextChar(P: Word): Word; assembler;
  235. PROC    @TEditor@nextChar$qus
  236.  
  237.         ARG   thisPtr:FAR PTR, P:WORD
  238.         USES  DS,SI,DI
  239.  
  240.         LDS   SI,[thisPtr]
  241.         MOV   DI,[P]
  242.         CMP   DI,[DS:SI+TEditorBufLen]
  243.         JE    @@Done
  244.         INC   DI
  245.         CMP   DI,[DS:SI+TEditorBufLen]
  246.         JE    @@Done
  247.         LES   BX,[DS:SI+TEditorBuffer]
  248.         CMP   DI,[DS:SI+TEditorCurPtr]
  249.         JB    @@1
  250.         ADD   BX,[DS:SI+TEditorGapLen]
  251. @@1:    MOV   AX,[ES:BX+DI-1]
  252.         CMP   AX,0A0Dh
  253.         JE    @@Skip
  254.         CMP   AH,0Dh                    ;check for soft-return
  255.         JNE   @@Done
  256.         CMP   [BYTE PTR ES:BX+DI+1],0Ah
  257.         JE    @@Done
  258. @@Skip: INC   DI
  259. @@Done: MOV   AX,DI
  260.         RET
  261. ENDP
  262.  
  263.  
  264. ;function TEditor.prevChar(P: Word): Word; assembler;
  265. PROC    @TEditor@prevChar$qus
  266.  
  267.         ARG   thisPtr:FAR PTR, P:WORD
  268.         USES  DS,SI,DI
  269.  
  270.         LDS   SI,[thisPtr]
  271.         MOV   DI,[P]
  272.         OR    DI,DI
  273.         JE    @@Done
  274.         DEC   DI
  275.         JE    @@Done
  276.         LES   BX,[DS:SI+TEditorBuffer]
  277.         CMP   DI,[DS:SI+TEditorCurPtr]
  278.         JB    @@1
  279.         ADD   BX,[DS:SI+TEditorGapLen]
  280. @@1:    MOV   AX,[ES:BX+DI-1]
  281.         CMP   AX,0A0Dh
  282.         JE    @@Skip
  283.         CMP   AH,0Dh                    ;check for soft-return
  284.         JNE   @@Done
  285. @@Skip: DEC   DI
  286. @@Done: MOV   AX,DI
  287.         RET
  288. ENDP
  289.  
  290. END
  291.  
  292.