Thread: Adding a scroll bar in a text mode program

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    30

    Adding a scroll bar in a text mode program

    I'd like to add a scroll bar to scroll up and down through output, sort of like EDIT.COM. Assume no access to system calls, interrupts or otherwise, forget ncurses, and assume direct access to keyboard I/O ports and video memory.

  2. #2
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    Quote Originally Posted by Wolf` View Post
    I'd like to add a scroll bar to scroll up and down through output, sort of like EDIT.COM. Assume no access to system calls, interrupts or otherwise, forget ncurses, and assume direct access to keyboard I/O ports and video memory.
    Maybe it's better if you say what OS you are using. :-)

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    30
    Let's assume none. I have basically most of the stdlib, and direct access to everything.

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    182
    Quote Originally Posted by Wolf` View Post
    Let's assume none. I have basically most of the stdlib, and direct access to everything.
    To have direct access to everything you need to know what OS
    is in your machine, and IF it permits direct access to I/O ports
    or you have to use APIs.
    There is no general machine around, as far as I know. :-)

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    30
    Listen, I have direct access, because I wrote the kernel. This is my point.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So what exactly are you having problems with? Write a ^ on the top right corner. Write a v on the bottom right corner. Write a | everywhere else along the right wall, with a # or something showing how far down the page you are.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    Jun 2009
    Posts
    30
    How can I scroll up and down with the arrow keys is my point, like EDIT.COM?

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You wrote a kernel, but you can't figure out how to read keys? Grab the keystroke from the arrow keys, and repaint the visible portion of the screen.


    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Jun 2009
    Posts
    30
    I can grab the keystroke, my point is how to repaint the screen? How do I store what was previous, etc.

  10. #10
    Registered User
    Join Date
    Jul 2010
    Posts
    55
    you wrote a kernel? woah...

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You buffer everything you expect to be on the screen, decide how much of it is shown at once, and output whatever is shown. When you ^ or v you simply adjust your frame of reference and output that. Look:

    abc
    def
    ghi
    jkl

    The screen is two lines. Paint ABC DEF. I hit down. Paint DEF GHI. I hit down. Paint GHI JKL. I hit down. Nothing changes. I hit up. Paint DEF GHI.


    Quzah.
    Hope is the first step on the road to disappointment.

  12. #12
    Registered User
    Join Date
    Jun 2009
    Posts
    30

    Smile

    Yeah, it's a small one, but anyway, I wanted to create a scrolling type ability for the command line. MS should open source edit.com by now.

  13. #13
    Registered User
    Join Date
    Jun 2009
    Posts
    30
    Quote Originally Posted by quzah View Post
    You buffer everything you expect to be on the screen, decide how much of it is shown at once, and output whatever is shown. When you ^ or v you simply adjust your frame of reference and output that. Look:

    abc
    def
    ghi
    jkl

    The screen is two lines. Paint ABC DEF. I hit down. Paint DEF GHI. I hit down. Paint GHI JKL. I hit down. Nothing changes. I hit up. Paint DEF GHI.


    Quzah.
    Kind of hard when it's a hexdump output that you create on the fly...

  14. #14
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    No one can help you then. If you're not clever enough to output to something other than the screen first, then no one can help you. Oh, and no one will actually believe you wrote the kernel either, if the concept of a buffer makes your head explode.


    Quzah.
    Hope is the first step on the road to disappointment.

  15. #15
    Registered User
    Join Date
    Jun 2009
    Posts
    30
    I understand the concept of a buffer, thank you. Never mind, I'll go elsewhere.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 19
    Last Post: 05-30-2007, 05:47 PM
  2. Scroll bar help
    By rEtard in forum Windows Programming
    Replies: 8
    Last Post: 05-17-2005, 02:50 PM
  3. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  4. accessing text from another program
    By Bozyo in forum Windows Programming
    Replies: 1
    Last Post: 08-05-2004, 12:17 PM
  5. can someone check this out and let me know ?
    By javaz in forum C Programming
    Replies: 5
    Last Post: 01-21-2002, 02:13 PM