1. Text Editing

I want to write a GUI System for use as a DOS shell. What i want to know is
how to write a multi-line text edit control,much like the one that David
Cuny wrote for his GUI lib,but i want to able to resize it.

thanks for any help.

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » topic index » view message » categorize

2. Re: Text Editing

Ian Smith wrote:

> how to write a multi-line text edit control,
> much like the one that David Cuny wrote for
his GUI lib,but i want to able to resize it.

Are you writing a DOS application?

It's not that hard to rewrite the IDE_EDIT code to support resizing. When
you get an onResize event in the window, calculate a new editCX, editCY.
Then resize the Pixmap in Buffer with setSize(). Don't forget to call
updatePage() to repaint the display. That's about it.

Hope this helps!

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

3. Re: Text Editing

I'm sorry but i don't think you understood my message. I am writing my own
GUI system in a text-mode. I can write all the other types of controls on my
own(Single-Line text edit, Radio/Check boxes, frames)
i'm not sure wether or not i'll support re-sizing of windows but i still
want to support different sizes.

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

4. Re: Text Editing

Ian Smith wrote:

> I am writing my own GUI system in a text-mode.

OK, now I understand. What *specifically* were you wondering about?

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

5. Re: Text Editing

David,

I am wondering how to write a window that can scroll through a text buffer(a
sequence holding all the text read in a file) and to be able to scroll
through it with all the correct character breaks and no word-wrapping.


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

6. Re: Text Editing

Ian Smith wrote:

> I am wondering how to write a window that
> can scroll through a text buffer(a sequence
> holding all the text read in a file) and to be
> able to scroll through it with all the correct
> character breaks and no word-wrapping.

Typically I'll store each line of text as a seperate string. This makes
things a lot easier. The user can move anywhere in the display area,
independant of whether there is really text there or not.

I keep track of the topLine, which is the line number of the top line, and
the leftMargin, which is the position of the left margin. The screen display
code looks something like this:

   line = 1    -- position of the top line in the window
   row = 10  -- position of the left margin in the window

   -- display a screen of text
   for i = topLine to topLine + numberOfLines - 1 do

      -- is the line past the end of file?
      if i > length( text ) then
         -- blank line
         showText = repeat( ' ', pageWidth )

      else
         -- get a line of text
         theText = text[i]

         -- text left of margin?
         if length( theText ) < leftMargin then
            showText = repeat( ' ', pageWidth )

         else
            -- make the slice safe
            theText &= repeat( ' ', pageWidth )

            -- slice to fit screen
            showText = theText[leftMargin..leftMargin+pageWidth-1]

      end if

      -- display the text
      position( line, row )
      puts( 1, showText )

   end for

When the user presses a key, my editor first checks to see if there is
actual text where the cursor is positioned. For example, if the cursor were
located at the '_':

   this is an example        _

and the string wasn't that long, the first thing the editor would do would
add padding to that line so that the cursor is above a real character (the .
represents a space):

   this is an example.........

Then I can simply insert a character into that position, or whatever.
Actually, there's a test it performs before that: it makes sure that the
line acually exists. For example:

   this is the end of the file.


       _

Here, the cursor is four lines past the end of the file. So I first extend
the file, and then pad to the cursor position:


   this is the end of the file.
   .
   .
   .
   ....

And insert/delete/whatever.

Did that answer the question?

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

7. Re: Text Editing

Exactly what i needed to know, thanks alot!
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu