ox icon indicating copy to clipboard operation
ox copied to clipboard

Outputing editors state for discord rpc

Open d3r1n opened this issue 4 years ago • 2 comments

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?

d3r1n avatar Oct 24 '21 11:10 d3r1n

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 :)

curlpipe avatar Oct 24 '21 12:10 curlpipe

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...

d3r1n avatar Oct 25 '21 06:10 d3r1n