Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MAKING A TEXT EDITOR

40 views
Skip to first unread message

Haavard Nesse,o92a

unread,
Mar 17, 1993, 7:08:07 AM3/17/93
to
Hi!

I'm currently working on a text-editor. I've defined my own screen and a window
connected to this screen. To read the keyboard events I use the VANILLAKEY
and the RAWKEY flags in the Windows structure, but I've got a couple of
practical questions:
1) Should I place the written text in a *HUGE* array?
So far I've done this, but on long texts I must change the stack size
in order to get the program to work. How is it done in commersial
software?
2) Later on I'll make a word processor, where it should be possible to
change the fonts on screen. The documents should be saved to a file,
and later loaded again with the same fonts as it was saved with.
How's the best way to do this?
Will I have to make my own codes in the document, or is there any
standards?

ex: [#f-Sapphire.font #s-21] This is a test.

Where #f tells the program, when file loaded, to change the font to
Sapphire, and #s to change the size to 21.

I really hope that someone can help me(I'm sure there is, but do they care?)

Thanks in advance!!!

Haavard Nesse - hav...@baron.edb.tih.no


Peter Simons

unread,
Mar 25, 1993, 3:33:17 PM3/25/93
to
In article <1993Mar17.1...@baron.edb.tih.no>,
hav...@edb.tih.no (Haavard Nesse,o92a) writes:

> [...] So far I've done this, but on long texts I must change the stack size


> in order to get the program to work. How is it done in commersial
> software?

If your texteditor need OS 2.04 you could simply use Exec's StackSwap(). If
it is designed to run under OS 1.3 too, you can use my AllocNewStack(),
which is public domain. Here comes the main routine:

;---------------------------------- cut here ------------------------------
_AllocNewStack:
; This routine allocates a block of memory and initialises
; this as new stack in a system-conform way.
;
; Parameter: D0=stacksize A0=StackDataBuffer (3 LWords)
; Result : D0=success (-1) or error (0)
; Comment : The routine detects OS 2.04 and uses
; StackSwap() to guarantee future compatiblity

movem.l a2/a6,-(SP)

move.l a0,a2
move.l d0,(1*4,a2)

move.l #$00010001,d1 ; MEMF_PUBLIC|MEMF_CLEAR
move.l ($4).w,a6
jsr (-$C6,a6) ; AllocMem()
move.l d0,(0*4,a2) ; new_SPLower
beq.b .ErrorExit
add.l d0,(1*4,a2) ; new_SPUpper

move.l (1*4,a2),a1
movem.l (SP)+,d0-d1/a0
movem.l d0-d1/a0,-(a1)
move.l a1,(2*4,a2) ; new_SPReg

cmp.w #37,($14,a6) ; LIB_VERSION
bpl.b .UseOS

jsr (-$78,a6) ; disable multitasking
sub.l a1,a1
jsr (-$126,a6)
move.l d0,a1

move.l ($3A,a1),d0 ; swap SPLower
move.l (0*4,a2),($3A,a1)
move.l d0,(0*4,a2)

move.l ($3E,a1),d0 ; swap SPUpper
move.l (1*4,a2),($3E,a1)
move.l d0,(1*4,a2)

move.l (2*4,a2),d0
move.l d0,($36,a1)
move.l SP,(2*4,a2)


move.l d0,SP ; swap Stack
jsr (-$7E,a6)
bra.b .Exit

.UseOS move.l a2,a0
jsr (-$2DC,a6) ; StackSwap()

.Exit moveq #-1,d0
.ErrorExit movem.l (SP)+,a2/a6
rts


_RestoreStack:
; This routine restores the systemstack after a new one
; has been allocated using AllocNewStack().
;
; Parameter: A0=StackDataBuffer
; Result : none

move.l (2*4,a0),a1
move.l (SP)+,-(a1)
movem.l a2/a6,-(a1)
move.l a1,(2*4,a0)

move.l a0,a2
move.l ($4).w,a6

cmp.w #37,($14,a6) ; LIB_VERSION
bpl.b .UseOS

jsr (-$78,a6) ; Disable()
sub.l a1,a1
jsr (-$126,a6) ; FindTask()
move.l d0,a0

move.l ($3A,a0),a1 ; SPLower
move.l (0*4,a2),($3A,a0)

move.l ($3E,a0),d0 ; SPUpper
move.l (1*4,a2),($3E,a0)

move.l (2*4,a2),($36,a0) ; SPReg
move.l (2*4,a2),SP

jsr (-$7E,a6) ; Enable()
bra.b .GoOn

.UseOS jsr (-$2DC,a6) ; StackSwap()

move.l (0*4,a2),a1
move.l (1*4,a2),d0
.GoOn sub.l a1,d0
jsr (-$D2,a6) ; FreeMem()

movem.l (SP)+,a2/a6
rts

;---------------------------------- cut here ------------------------------

If you need any help or want further info, don't hesitate to contact me.

bye, Peter


--
Peter Simons - Germany, Usenet: sim...@peti.GUN.de, Phone: 0228 / 746061


-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.1

mQBNAiuEC4sAAAECAMrOjRCPGSTGV/j/toYaURFBnY8UX0kNNDGlwkxcryHSuq3L
ov8YqylmpLakZOOuq3EGAGzikI5xs7y/yYd6pmEABRG0IVBldGVyIFNpbW9ucyA8
c2ltb25zQHBldGkuR1VOLmRlPg==
=OIbT
-----END PGP PUBLIC KEY BLOCK-----

0 new messages