Thread: newbie question about storing large blocks of text.

  1. #1
    Registered User
    Join Date
    Nov 2005

    newbie question about storing large blocks of text.


    ok, i would like to make a simple text editor in which the user can enter large blocks of text, save and load, how would i go about starting this sort of thing?

    any help would be appreicated


  2. #2
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Republika Srpska - Balkan
    maybe char[1000][5000]???
    If your using windows just create a child control ( is that possible )...
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  3. #3
    Registered User
    Join Date
    Aug 2005
    That question is not very easy to answer. It depends a lot on what kind of features your editor should have.
    For a simple solution you could just read in the text line by line and save the lines in an array ( navigation in the text would be very fast insertion and deletion of text would involve lot of copying ).
    If you would use a linked list you would be doing a lot of iterating the list to find the current line of text.
    For both of this solutions ( array or list ) you would have to write a lot of similar code twice. One set of operations for insertion-mode and one for overwrite-mode.

    One interesting solution I have seen involves just a char buffer. This buffer is split into two areas. All the text before the current working point is kept at the beginning of the buffer. The text after the current working point is at kept at the end of the buffer. You have to have a variable to keep track of the gapsize ( that is the buffersize - textsize ).
    In this solution there is only a small difference in code depending on insert or overwrite-mode. Either you decrease the gapsize if a character is typed ( insert-mode ) or you don't ( overwrite-mode ).
    If you change the current working-point you have to update the two bufferareas but that is just one simple memmove operation. The disadvantage of this approach is that changing the workingpoint involves counting linebreaks.
    Last edited by ZuK; 11-27-2005 at 05:46 AM.

  4. #4
    Registered User
    Join Date
    Nov 2005
    hi again,

    well...the eventual idea is that on save every character will be switched with something else (preset in code) i.e.

    a = 10
    b = 110
    c = 1110
    d = 11110

    and so on...

    and the idea is that on open it'll do the opposite, basically it'll count the number of 1's untill the 0 (0 being the termination) and lookup what that character is supposed to be and replace it accordingly so that the person can read the message when they're writing it and when they've opened it using the application only.

    i just thought it might be a good idea to ask how to do the basic part of it first

    Last edited by DimensionX; 11-27-2005 at 09:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  3. Question About Blank Lines in Text Files
    By Zildjian in forum C++ Programming
    Replies: 11
    Last Post: 10-16-2004, 04:31 PM
  4. GLenum = editbox text? (Win32/OGL question)
    By psychopath in forum Windows Programming
    Replies: 4
    Last Post: 08-27-2004, 09:23 AM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM