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

Line numbers are required #15

Open
zyavrik opened this issue Oct 2, 2013 · 16 comments
Open

Line numbers are required #15

zyavrik opened this issue Oct 2, 2013 · 16 comments

Comments

@zyavrik
Copy link

zyavrik commented Oct 2, 2013

Required support for line numbers.

@davemackintosh
Copy link

I second this, having line numbers would be hugely helpful.

@ndrewh
Copy link

ndrewh commented Nov 27, 2013

@davemackintosh
Copy link

I've actually already started trying to implement that along side.

@ndrewh
Copy link

ndrewh commented Nov 27, 2013

I would love to see it when you get something working. I've been looking for this for a while.

@davemackintosh
Copy link

Like that post says, it's working around the line break, or we scroll horizontally. Will be a challenge.

@ndrewh
Copy link

ndrewh commented Nov 27, 2013

@davemackintosh Yeah I'm messing with it now too.

@ndrewh
Copy link

ndrewh commented Nov 27, 2013

@davemackintosh Overriding the drawRect method is significantly reducing performance.

@davemackintosh
Copy link

I haven't noticed anything massive yet but stopped playing a few hours ago to get on with some other work that pays me lol. Will have another look later on/tomorrow morning but if you find anything else do let me (us all) know!

@ndrewh
Copy link

ndrewh commented Nov 27, 2013

Okay so here is what I have so far using that stack overflow post as a guide. It doesn't work perfectly yet but It will eventually. (Note that the code in the image is not mine)
Imgur

@Anviking
Copy link
Owner

An alternative to overriding -drawRect might be using NSLayoutManager.

@davemackintosh
Copy link

I think this might actually be easier than I thought, conceptually anyway. Will do an implementation tonight and see if I can come up with anything good.

@davemackintosh
Copy link

yes, it is easier than I thought with no measurable performance hit. I'm currently working on a UITableView that displays the line numbers according to the lines, this gives us line numbers that have the right amount of spacing between them without having to modify the UITextView or extend it. Will be finishing up on this today and you can review it.

@davemackintosh
Copy link

Just so people know, I am still working on this. Work is just a bit hectic at the moment and finding time to finish the implementation is hard! rest assured I will update my fork with line numbers and once it's okayed I'll submit a pull-request.

Some info on my implementation:

After seeing performance issues with using drawRect method, I've implemented programatically adding a UITableView to the left of the JLTextView which contains the line numbers in and the heights of each Cell is calculated from the font and string size so they're spaced properly.

The issue I'm having at the moment is updating the UITableView properly while editing and also setting the width of it as you get from single digits to double, to triple, so on and so forth but I'm still working on it! I'll try to get some screen shots when I get a little time to do so!

@davemackintosh
Copy link

Okay, now I have some free time I'm back on this :) just as an update. Is anyone else working on this?

@ruddfawcett
Copy link

@davemackintosh check out https://github.com/illyabusigin/CYRTextView to see a possible implementation of the line numbers... Haven't really dug around, but may be of some use.

@davemackintosh
Copy link

Oh. Ha, nice. I'll hit that up instead, having a quick look over it and it's mostly the same as what I've been doing. I'll add this today and remove what I've done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants