home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 10.ddi / TVSRC.ZIP / EDITS.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-10  |  6.3 KB  |  252 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.         IDEAL
  19.         MODEL  LARGE, PROLOG
  20.  
  21.         INCLUDE "TVWRITE.INC"
  22.  
  23.         PUBLIC @TEditor@bufChar$qus
  24.         PUBLIC @TEditor@bufPtr$qus
  25.         PUBLIC @TEditor@formatLine$qnvusius
  26.         PUBLIC @TEditor@lineEnd$qus
  27.         PUBLIC @TEditor@lineStart$qus
  28.         PUBLIC @TEditor@nextChar$qus
  29.         PUBLIC @TEditor@prevChar$qus
  30.  
  31. CODESEG
  32.  
  33. ;char TEditor::bufChar( ushort P )
  34. PROC    @TEditor@bufChar$qus
  35.  
  36.         ARG     thisPtr : FAR PTR, P : WORD
  37.         USES    DI
  38.  
  39.         LES DI,[thisPtr]
  40.         MOV BX,[P]
  41.         CMP BX,[ES:DI+TEditorCurPtr]
  42.         JB  @@1
  43.         ADD BX,[ES:DI+TEditorGapLen]
  44. @@1:    LES DI,[ES:DI+TEditorBuffer]
  45.         MOV AL,[ES:DI+BX]
  46.         RET
  47. ENDP
  48.  
  49. ;function TEditor.bufPtr(P: Word): Word; assembler;
  50. PROC    @TEditor@bufPtr$qus
  51.  
  52.         ARG     thisPtr : FAR PTR, P : WORD
  53.         USES    DI
  54.  
  55.         LES DI,[thisPtr]
  56.         MOV AX,[P]
  57.         CMP AX,[ES:DI+TEditorCurPtr]
  58.         JB  @@1
  59.         ADD AX,[ES:DI+TEditorGapLen]
  60. @@1:    RET
  61. ENDP
  62.  
  63. ;void TEditor::formatLine( void *DrawBuf,
  64. ;                          ushort LinePtr,
  65. ;                          int Width,
  66. ;                          ushort Colors
  67. ;                        )
  68. PROC    @TEditor@formatLine$qnvusius
  69.  
  70.         ARG     thisPtr : FAR PTR, DrawBuf : FAR PTR, LinePtr : WORD, W : WORD, Colors : WORD
  71.         USES    DS,SI,DI
  72.  
  73.         LDS BX,[thisPtr]
  74.         LES DI,[DrawBuf]
  75.         MOV SI,[LinePtr]
  76.         XOR DX,DX
  77.         CLD
  78.         MOV AH,[BYTE PTR Colors]
  79.         MOV CX,[DS:BX+TEditorSelStart]
  80.         CALL    @@10
  81.         MOV AH,[BYTE PTR Colors+1]
  82.         MOV CX,[DS:BX+TEditorCurPtr]
  83.         CALL    @@10
  84.         ADD SI,[DS:BX+TEditorGapLen]
  85.         MOV CX,[DS:BX+TEditorSelEnd]
  86.         ADD CX,[DS:BX+TEditorGapLen]
  87.         CALL    @@10
  88.         MOV AH,[BYTE PTR Colors]
  89.         MOV CX,[DS:BX+TEditorBufSize]
  90.         CALL    @@10
  91.         JMP @@31
  92. @@10:   SUB CX,SI
  93.         JA  @@11
  94.         RETN
  95. @@11:   LDS BX,[DS:BX+TEditorBuffer]
  96.         ADD SI,BX
  97.         MOV BX,[W]
  98. @@12:   LODSB
  99.         CMP AL,' '
  100.         JB  @@20
  101. @@13:   STOSW
  102.         INC DX
  103. @@14:   CMP DX,BX
  104.         JAE @@30
  105.         LOOP    @@12
  106.         LDS BX,[thisPtr]
  107.         SUB SI,[WORD PTR DS:BX+TEditorBuffer]
  108.         RETN
  109. @@20:   CMP AL,0DH
  110.         JE  @@30
  111.         CMP AL,09H
  112.         JNE @@13
  113.         MOV AL,' '
  114. @@21:   STOSW
  115.         INC DX
  116.         TEST    DL,7
  117.         JNE @@21
  118.         JMP @@14
  119. @@30:   POP CX
  120. @@31:   MOV AL,' '
  121.         MOV CX,[W]
  122.         SUB CX,DX
  123.         JBE @@32
  124.         REP STOSW
  125. @@32:   RET
  126. ENDP
  127.  
  128. ;function TEditor.lineEnd(P: Word): Word; assembler;
  129. PROC    @TEditor@lineEnd$qus
  130.  
  131.         ARG     thisPtr : FAR PTR, P : WORD
  132.         USES    DS,SI,DI
  133.  
  134.         LDS SI,[thisPtr]
  135.         LES BX,[DS:SI+TEditorBuffer]
  136.         MOV DI,[P]
  137.         MOV AL,0DH
  138.         CLD
  139.         MOV CX,[DS:SI+TEditorCurPtr]
  140.         SUB CX,DI
  141.         JBE @@1
  142.         ADD DI,BX
  143.         REPNE   SCASB
  144.         JE  @@2
  145.         MOV DI,[DS:SI+TEditorCurPtr]
  146. @@1:    MOV CX,[DS:SI+TEditorBufLen]
  147.         SUB CX,DI
  148.         JCXZ    @@4
  149.         ADD BX,[DS:SI+TEditorGapLen]
  150.         ADD DI,BX
  151.         REPNE   SCASB
  152.         JNE @@3
  153. @@2:    DEC DI
  154. @@3:    SUB DI,BX
  155. @@4:    MOV AX,DI
  156.         RET
  157. ENDP
  158.  
  159. ;function TEditor.lineStart(P: Word): Word; assembler;
  160. PROC    @TEditor@lineStart$qus
  161.  
  162.         ARG     thisPtr : FAR PTR, P : WORD
  163.         USES    DS,SI,DI
  164.  
  165.         LDS SI,[thisPtr]
  166.         LES BX,[DS:SI+TEditorBuffer]
  167.         MOV DI,[P]
  168.         MOV AL,0DH
  169.         STD
  170.         MOV CX,DI
  171.         SUB CX,[DS:SI+TEditorCurPtr]
  172.         JBE @@1
  173.         ADD BX,[DS:SI+TEditorGapLen]
  174.         ADD DI,BX
  175.         DEC DI
  176.         REPNE   SCASB
  177.         JE  @@2
  178.         SUB BX,[DS:SI+TEditorGapLen]
  179.         MOV DI,[DS:SI+TEditorCurPtr]
  180. @@1:    MOV CX,DI
  181.         JCXZ    @@4
  182.         ADD DI,BX
  183.         DEC DI
  184.         REPNE   SCASB
  185.         JNE @@3
  186. @@2:    INC DI
  187.         INC DI
  188.         SUB DI,BX
  189.         CMP DI,[DS:SI+TEditorCurPtr]
  190.         JE  @@4
  191.         CMP DI,[DS:SI+TEditorBufLen]
  192.         JE  @@4
  193.         CMP [BYTE PTR ES:BX+DI],0AH
  194.         JNE @@4
  195.         INC DI
  196.         JMP @@4
  197. @@3:    XOR DI,DI
  198. @@4:    MOV AX,DI
  199.         CLD
  200.         RET
  201. ENDP
  202.  
  203. ;function TEditor.nextChar(P: Word): Word; assembler;
  204. PROC    @TEditor@nextChar$qus
  205.  
  206.         ARG     thisPtr : FAR PTR, P : WORD
  207.         USES    DS,SI,DI
  208.  
  209.         LDS SI,[thisPtr]
  210.         MOV DI,[P]
  211.         CMP DI,[DS:SI+TEditorBufLen]
  212.         JE  @@2
  213.         INC DI
  214.         CMP DI,[DS:SI+TEditorBufLen]
  215.         JE  @@2
  216.         LES BX,[DS:SI+TEditorBuffer]
  217.         CMP DI,[DS:SI+TEditorCurPtr]
  218.         JB  @@1
  219.         ADD BX,[DS:SI+TEditorGapLen]
  220. @@1:    CMP [WORD PTR ES:BX+DI-1],0A0DH
  221.         JNE @@2
  222.         INC DI
  223. @@2:    MOV AX,DI
  224.         RET
  225. ENDP
  226.  
  227. ;function TEditor.prevChar(P: Word): Word; assembler;
  228. PROC    @TEditor@prevChar$qus
  229.  
  230.         ARG     thisPtr : FAR PTR, P : WORD
  231.         USES    DS,SI,DI
  232.  
  233.         LDS SI,[thisPtr]
  234.         MOV DI,[P]
  235.         OR  DI,DI
  236.         JE  @@2
  237.         DEC DI
  238.         JE  @@2
  239.         LES BX,[DS:SI+TEditorBuffer]
  240.         CMP DI,[DS:SI+TEditorCurPtr]
  241.         JB  @@1
  242.         ADD BX,[DS:SI+TEditorGapLen]
  243. @@1:    CMP [WORD PTR ES:BX+DI-1],0A0DH
  244.         JNE @@2
  245.         DEC DI
  246. @@2:    MOV AX,DI
  247.         RET
  248. ENDP
  249.  
  250. END
  251.  
  252.