Results 1 to 13 of 13

Thread: Editor in turboc

  1. #1
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Editor in turboc

    Hi fellows,
    We , in our college are supposed to code a text editor similar to the edit in dos using turbo c(i know its age old ) without using any graphics (i.e no graphics.h utilities)
    Since we are supposed to stick on to using C (no c++ ) I decided to use this opportunity to learn c in depth. So far i am able to display typed text and move cursor but i have these to problems

    *) Which is the best data structure to store the text being displayed ? Currently i am using char array for testing purpose. Linked lists might fit in well but i want to know whether there are other efficient data structure or modified forms of data structure for this purpose ?

    *) Secondly i don't have a clue on how to implement scrolling ? In one of the dos book there was an interrupt to do scrolling but i didn't understand how this works We are using framebuffer to display the text directly.

    Can you people please help me out ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Editor in turboc

    You can emulate a data structure that is called a rope.

    http://en.wikipedia.org/wiki/Rope_(computer_science)

    See the links at the bottom.

    As for scrolling... well.. did you try the obvious approach?

  3. The following user says thank you to wysota for this useful post:

    Gopala Krishna (13th September 2007)

  4. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Editor in turboc

    Quote Originally Posted by wysota View Post
    You can emulate a data structure that is called a rope.

    http://en.wikipedia.org/wiki/Rope_(computer_science)

    See the links at the bottom.

    As for scrolling... well.. did you try the obvious approach?
    The rope seems to be pretty much what i wanted. I'll think about it. Meanwhile i am open to other ideas as well

    The only approach i know is to paint/write everything manually to get the effect of scrolling(based on current column). But there should be memove or some similar trick which can be used to emulate scrolling rather than rewriting everything. May be the interrupt works this way.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Editor in turboc

    Did you already ask your teacher the fundamental question "Why don't we use Qt instead of wasting time for implementing things nobody wants to use anymore?"?

  6. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Editor in turboc

    Quote Originally Posted by wysota View Post
    Did you already ask your teacher the fundamental question "Why don't we use Qt instead of wasting time for implementing things nobody wants to use anymore?"?
    I am the only person knowing c++ (qt too ) amongst the students. Infact we are *starting* to learn data structures (from stack) now. This project is supposed to help us master C in better way and i think they are right. I am just a bit ahead of them Also using qt at this level will be too fancy and i will be the odd one out.

    But one good outcome would be i'll understand some basics in depth, for eg the interrupts and writing directly to frame buffer are nice concepts. I'll understand how exactly scrolling is done.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Editor in turboc

    Quote Originally Posted by Gopala Krishna View Post
    I am the only person knowing c++ (qt too ) amongst the students. Infact we are *starting* to learn data structures (from stack) now. This project is supposed to help us master C in better way and i think they are right.
    By manipulating the frame buffer directly? I don't think so. It's not portable, may not work, etc. It's simply a dead end.

    But one good outcome would be i'll understand some basics in depth, for eg the interrupts and writing directly to frame buffer are nice concepts.
    What does it have to do with C or data structures?

    I'll understand how exactly scrolling is done.
    It's architecture dependent, so you'll only understand how scrolling is done in this single case. When you'll be given another architecture, you'll have to start learning from scratch. That's what I mean when I say the task is useless (unless you'll be writing your own device drivers, but I don't think that a good way to start learning C).

  8. #7
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Editor in turboc

    Your advice may be perfect for me but not my other classmates since they really don't know anything other than turboc for now. That is the only IDE familiar to them which involves nice context help built in. So doing a small functional editor(similar to edit) will sprout interest in them , atleast that is what my teacher assumes. Since my classmates know only c and some dos programming , they can achieve this for now. So they cant think about portability at this stage. One more advantage for starters will be , some understanding on how events are generated and how to handle them.
    I didn't want to be odd one out and so joined to help others too.
    My idea is to do something special in this. For example i have better idea to handle the events and catch interrupts at right place. I am trying to be perfectionist in as many areas as possible and also would like to learn advanced data structures.

    By frame buffer i meant accesing cga memory directly as in http://en.wikipedia.org/wiki/Pointer...apped_hardware
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Editor in turboc

    Quote Originally Posted by Gopala Krishna View Post
    Your advice may be perfect for me but not my other classmates since they really don't know anything other than turboc for now. That is the only IDE familiar to them which involves nice context help built in. So doing a small functional editor(similar to edit) will sprout interest in them , atleast that is what my teacher assumes.
    That's exactly what I mean. I think this assumption is wrong I don't say students shouldn't use turbo c, I'm saying they shouldn't implement such things with it, especially if they are new to the language.

    So they cant think about portability at this stage.
    It's not about thinking about portability. It's about knowing there are different architectures, not only x86/Win32. Using such concepts as programming interrupts as the basic of the C course seems very strange, based on the fact that for modern operating systems you'll never touch any interrupt handler, because they are hidden and well protected. Of course, again, this doesn't apply if you code a device driver, but that doesn't seem to be the case when using Turbo C

    One more advantage for starters will be , some understanding on how events are generated and how to handle them.
    What kind of events? I never heard of any events in TurboC.

    I didn't want to be odd one out and so joined to help others too.
    I'm not blaiming you. I'm just saying your teacher had a weird idea making his students implement a text editor as a starters project from C.

    My idea is to do something special in this. For example i have better idea to handle the events and catch interrupts at right place. I am trying to be perfectionist in as many areas as possible and also would like to learn advanced data structures.
    This is purely academical "perfection" - you'll never put that knowledge into practical use.

    By frame buffer i meant accesing cga memory directly as in http://en.wikipedia.org/wiki/Pointer...apped_hardware
    I understand that. What operating system are you using? Emulation of DOS, right? Do you have DOS on your desktop computer? Have you tried using the framebuffer directly inside WinXP or Vista for a non DOS-based application?

    That's one of the reasons I graduated CS on a technical university instead of a theoretical one

  10. #9
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Editor in turboc

    Though we are going off topic this discussion is interesting.

    Quote Originally Posted by wysota View Post
    That's exactly what I mean. I think this assumption is wrong I don't say students shouldn't use turbo c, I'm saying they shouldn't implement such things with it, especially if they are new to the language.
    They are not very new to language but ofcourse to data structures. You are right but we are just supposed to get a working editor with no fancy things and so that shouldn't be a big problem.

    It's not about thinking about portability. It's about knowing there are different architectures, not only x86/Win32. Using such concepts as programming interrupts as the basic of the C course seems very strange, based on the fact that for modern operating systems you'll never touch any interrupt handler, because they are hidden and well protected. Of course, again, this doesn't apply if you code a device driver, but that doesn't seem to be the case when using Turbo C
    True, this was ofcourse informed. Think this to be a system software

    What kind of events? I never heard of any events in TurboC.
    Can we call this over influence of Qt ? Actually i meant interrupts.


    This is purely academical "perfection" - you'll never put that knowledge into practical use.
    But since i have already been committed to this i don't bother whether this will be really useful. Playing with pointers is fun and ofcourse not everything will be waste.

    I understand that. What operating system are you using? Emulation of DOS, right? Do you have DOS on your desktop computer? Have you tried using the framebuffer directly inside WinXP or Vista for a non DOS-based application?

    That's one of the reasons I graduated CS on a technical university instead of a theoretical one
    Very true. As i said before, this is meant to be introductory and my friends have learned basic 'C'. Experimenting so much with other subjects to study will be tough to manage. Getting a simple editor working will be enough as of now.
    And also the practical part is in our hands and its our duty/curiosity to experiment
    Well actually its worth to know the theory behind too.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Editor in turboc

    Quote Originally Posted by Gopala Krishna View Post
    Playing with pointers is fun
    That's what you say. I'm not a masochist

  12. #11
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Editor in turboc

    Quote Originally Posted by wysota View Post
    That's what you say. I'm not a masochist
    I am sorry. May be you are just looking at faults rather than trying to help. Well i don't want to say anything more and thanks for answering in this thread.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  13. #12
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Editor in turboc

    Sorry wysota, i guess i lost my cool for no reason
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Editor in turboc

    No problem. By the way, I thought of something yesterday, but I forgot to write it here

    You wanted something regarding scrolling. If you can read the frame buffer, you can implement scrolling by reading the chunk of data that represent all the visible lines of the editor but one (the one that'll fall out of the screen) and writing it back again at a different offset. This way you'll have to recalculate and draw only a single line (first or last, depending on the scroll direction). I don't know if that helps, but maybe it'll give you something to start with.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.