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

Outputing editors state for discord rpc #114

Open
d3r1n opened this issue Oct 24, 2021 · 2 comments
Open

Outputing editors state for discord rpc #114

d3r1n opened this issue Oct 24, 2021 · 2 comments

Comments

@d3r1n
Copy link

d3r1n commented Oct 24, 2021

Hello!
I'm going to make a Discord RPC for ox but I can't get any information about editors state (like, filename, line number, total lines, visual - editing mode etc.). Is there any way for me to get those information from ox?

@curlpipe
Copy link
Owner

Hi there, thanks for your interest! I haven't really updated this in a long while, I've been quite busy and I feel like I burnt out a little bit. I'm not really happy with the code in this repository in it's current state, it's messy, clunky and full of bugs to the point where I don't believe it's salvageable.

However, I will help you find what you're looking for.
In editor.rs, the Editor struct contains a field doc which is a vector of documents. Each element in this vector is an open tab. You can see the currently open tab by reading the tab field in the Editor struct. By indexing the doc field with tab (self.doc[self.tab]) you'll be able to get a Document struct. In that struct you'll be able to find your filename at the field name (self.doc[self.tab].name). You'll find the line number by adding the fields cursor.y (self.doc[self.tab].cursor.y) and offset.y (self.doc[self.tab].offset.y), and as for the total lines, you can use self.doc[self.tab].rows.len(). As for visual editing mode, I'm assuming you're referring to the command line option -r for read only mode. That's in the read_only field of Document (self.doc[self.tab].read_only).

Hopefully this clears everything up for you. Let me know if you have any other questions :)

@d3r1n
Copy link
Author

d3r1n commented Oct 25, 2021

Thanks for the information!
I will add Discord RPC asap.

I'm not really happy with the code in this repository in it's current state, it's messy, clunky and full of bugs to the point where I don't believe it's salvageable

I think code base is a bit messy but that's not a problem. I'm a student with a lot of spare time so I think I can fix some bugs and make the code a bit better. ox is really a good editor for someone who is new to linux... UI is pretty and there is a lot of opportunity to make this project better with plugins, fully customizable editor, and many others...

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

No branches or pull requests

2 participants