Thread: Re: displaying the line number

  1. #1
    Registered User
    Join Date
    Nov 2003

    Re: displaying the line number

    It may be a simple problem but...

    I was wondering how to diplay what line number the cursor is on and then display this in the staus bar in Borland C++, so the user of the editor i have creted can see what line they need to goto, to correct any errors.

    any help would be gratefully recieved


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    You want the line in the file, not the line on the display.
    This is also much easier to figure out since you have an array of lines when you read the file in to be edited.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2002
    This seems like it would be pretty platform dependent, although I suspect you are probably using a platform with a window of some sort. In general I suspect you would need some mechanism for defining what a line is and some mechanism for keeping track of the number of lines and where they are. A line may be defined by dividing the height of a line into the height of the screen or viewing/active area or by a semicolon outside of a set of () or by a newline char, etc. The editor will need to able to determine the start and the end of a line, whichever definition you choose. Then I suspect you will need some container to store all lines identified by the editor. If that container is an array/vector then the index of each element seems like a logical choice for line number. If the container is a list or a tree then each link may well be declared to include a given line and the lines number, which would be assigned to it by the editor as it is identified. In either case, once the line is identified you could have a protocol for displaying x number of lines before and after the given line on the screen with the cursor at the start of the given line. Alternatively, a map container with an int for a key and a string for the data could be used too. Lot's of possible choices to explore.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    No one understands your question.
    You will have to be alot more specific as to what you are trying to accomplish.


  5. #5
    Registered User
    Join Date
    Nov 2003

    Re:displaying line numbers

    Sorry if i was not clear before,

    I have created a text editor to assemble asm files. I want the user to know what line of code they need to make their corrections on, when the list file i create gives any error message at line (say 120).

    I want my editor to display (in the status bar i created) the different line numbers the user is on to be able to quickly go to the error. Just like normal assembler programs

    I hope that is more clear..

    again any help and i would be very gratefull

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying Numbers divisible by user's desired number
    By DaniiChris in forum C Programming
    Replies: 9
    Last Post: 07-07-2008, 02:06 PM
  2. Need help with this compiler error
    By Evangeline in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 09:27 AM
  3. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  4. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM
  5. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM