Thread: Text editor?

  1. #16
    Registered User
    Join Date
    Nov 2008
    Location
    My computer
    Posts
    65
    for me, or for you to explain.

  2. #17
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    How much do you really think we know about you and what your abilities are?

    If you need to find some code to get an idea of where to start, then you need to scrape the web for it instead of asking us. Try looking at the code for these
    http://code.google.com/search/#q=notepad%20replacement
    http://sourceforge.net/projects/padpaper/
    and you'll get an idea of how what you want to do is actually done. You might convince yourself to use something you found instead, too.

    In general the more effort you put in the more help we can be.

  3. #18
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Sly View Post
    for me, or for you to explain.
    I couldn't tell you much about assembly beyond the fact that you will find learning it more awkward than learning C. I could be wrong.

    I also don't know anything about the windows console API (or whatever it's called), but it should not be much more (or less) complicated than curses. Like I said earlier, ncurses() is neat once you learn how to use it, and no doubt so are the other options. Pick which ever one you want. But you won't be finishing that up this evening.

    Learning a basic Application Programming Interface is probably a good way to get experience and learn C at the same time. How much you'll have to struggle depends on how much you already know, but I really believe that you should be able to start tackling a console API not long after you get a grasp on datatypes and pointers.

    And functions. Functions.
    Last edited by MK27; 02-16-2009 at 08:22 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #19
    Registered User
    Join Date
    Nov 2008
    Location
    My computer
    Posts
    65
    No, I know x86 assembly, I am wondering if it would be easier to explain how to edit text with it.

  5. #20
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Sly View Post
    No, I know x86 assembly, I am wondering if it would be easier to explain how to edit text with it.
    Well if you want to be a real craftsperson.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #21
    Registered User
    Join Date
    Nov 2008
    Location
    My computer
    Posts
    65
    So would you be able to explain how then?

  7. #22
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Sly View Post
    So would you be able to explain how then?
    No, I couldn't give you a syntax correct piece of ASM if would win me a trip around the world. But it is unlikely to do that anyway.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #23
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You can use the Windows API to move the console cursor.

    Go to MSKnowledge Base and look up: SetConsoleCursorPosition(x,y).

    Where x and y represent the the X and Y position, you want the cursor moved to.

  9. #24
    Registered User
    Join Date
    Nov 2008
    Location
    My computer
    Posts
    65
    Mixing C with assembly?

  10. #25
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    No, it's straight C, it just uses the Windows API (Application Program Interface).

    You don't want assembly - oh! How you do *not* want assembly!!

  11. #26
    Registered User
    Join Date
    Nov 2008
    Location
    My computer
    Posts
    65
    Quote Originally Posted by Adak View Post
    You don't want assembly - oh! How you do *not* want assembly!!
    Come on, it's not that bad.

  12. #27
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Sly View Post
    Come on, it's not that bad.
    Writing LARGE portions of assembly code (and in this case, it would be several thousand lines - tamis that I worked on was about 7-8000 lines of 68K or PDP-11 assembler).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #28
    Registered User
    Join Date
    Nov 2008
    Location
    My computer
    Posts
    65
    Quote Originally Posted by matsp View Post
    7-8000 lines of 68K or PDP-11 assembler).

    --
    Mats
    Holy crap!! Still, x86 asm isn't that hard.

  14. #29
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Sly View Post
    Holy crap!! Still, x86 asm isn't that hard.
    No, but considering that both 68K and PDP-11 has generic "memory to memory" moves [and most other operations], and x86 hasn't, that would further extend the number of lines of code by some amount. For example, where in 68K you could do a memcpy() using this:
    Code:
    // assume A0 and A1 points to the memory to be copied, and D0 is the 
    memcpy:
         move.b   (a1)+,  (a0)+
         dbra       d0, memcpy
         ret
    Yes, you can do that with rep movs if the registers are in the right place, but it is just ONE possible memory to memory operation - a common one, but there are plenty of places where copying stuff from a data structure to another data structure, for example, would require double the number of x86 instructions compared to the 68K instructions.

    So a rough estimate would be that 7000 lines of 68K assembler turns into some 8500 lines of x86 assembler. Not bad, but a good bit of code to write if you are not used to write LARGE programs in assembler.

    It is still MUCH easier to write this sort of thing in a language that has ready-made functions to do many string operations, output numbers in almost any format you like, etc, etc.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #30
    Registered User
    Join Date
    Nov 2008
    Location
    My computer
    Posts
    65
    So what if you mix C and assembly so you could do it in the least possible time?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. text editor
    By akki in forum C Programming
    Replies: 5
    Last Post: 07-11-2009, 02:05 PM
  3. C++ For Text Editor?
    By bmroyer in forum C++ Programming
    Replies: 12
    Last Post: 04-05-2005, 02:17 AM
  4. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  5. help about text editor
    By nag in forum C++ Programming
    Replies: 2
    Last Post: 04-24-2003, 11:45 AM