Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lines starting from 0 #113

Open
markusmoenig opened this issue Oct 29, 2024 · 5 comments
Open

Lines starting from 0 #113

markusmoenig opened this issue Oct 29, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@markusmoenig
Copy link

Hi,

would it be possible to add an option to start lines from 0 instead of 1 ?

I am working on a chip emulator in assembly which has offsets into tags starting from 0.

Thanks :)

@mchakravarty
Copy link
Owner

@markusmoenig Sorry, but I'm not sure I understand the feature that you need. Do you need the first line to have a line number, which is labeled "0", or do you need the internal line count (in the line map) to start at 0?

Changing the line number that is printed to the left of each line would instead require a change, but a very simple one.

Internally, the line map already starts from 0 and the API allows to use both 0-based or 1-based line numbers when creating a position value.

@markusmoenig
Copy link
Author

markusmoenig commented Oct 29, 2024

I would need the line numbers to count up from 0. Is that already in the API ? Did not see it.

Thanks

@markusmoenig
Copy link
Author

markusmoenig commented Oct 30, 2024

@mchakravarty While I have your attention, how do I get the current CURSOR position when it changes ? I seem to only be able to access selections and scroll positions ?

I would need to get the current line position to show help information about the assembly instruction on that line.

Thanks

@mchakravarty
Copy link
Owner

I would need the line numbers to count up from 0. Is that already in the API ? Did not see it.

No, that's not yet supported, but easy to add. I'll try to have a look at it this or next week. (Or feel free to have a go yourself and send a PR.)

@mchakravarty
Copy link
Owner

mchakravarty commented Nov 4, 2024

While I have your attention, how do I get the current CURSOR position when it changes ? I seem to only be able to access selections and scroll positions ?

You can do this with the setInfo argument, which I added recently — see

/// - setInfo: Callback that lets the code editor update the context about informational aspects of the current

(The reason that this is not included in the position information is because you can use position also to set the selection and scroll position. Having the selection —with the insertion point as a special case— and line/column position in here would allow a lot of inconsistent values. In contrast, setInfo is unidirectional, you can observe it, but you can't set it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Development

No branches or pull requests

2 participants