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

add libvterm support #1212

Closed
wants to merge 15 commits into from
Closed

add libvterm support #1212

wants to merge 15 commits into from

Conversation

brotzeit
Copy link
Member

@brotzeit brotzeit commented Jan 5, 2019

I have a TODO list of the review from the old PR, but I would like to get this merged as I still hope I get some help with this =)

However I still have problems with configure.ac. I can't get this to work.
.rustified_enum("VTermProp") doesn't work since #1185. It worked before...

Apart from that, it seems to be usable. But resizing needs to get fixed.

@brotzeit brotzeit mentioned this pull request Jan 5, 2019
3 tasks
@brotzeit brotzeit requested a review from shaleh January 5, 2019 12:41
@shaleh
Copy link
Collaborator

shaleh commented Jan 6, 2019

Perhaps the right thing to do is leave this in a feature branch while the kinks are worked through.

@brotzeit
Copy link
Member Author

brotzeit commented Jan 6, 2019

@shaleh ok I will work some more on this. Can you please take a look at configure.ac. I don't know why HAVE_LIBVTERM doesn't work.

@shaleh
Copy link
Collaborator

shaleh commented Jan 6, 2019

@brotzeit I pushed a fix to the configure script and used it to make vterm.c become empty if libvterm is not found. That may need some tweaking, but the detection is now solid.

EMACS_CHECK_MODULES is all you needed. It uses pkgconfig to detect the library in question. An extra gotcha is the library defines itself as vterm in its .pc file, not libvterm.

When EMACS_CHECK_MODULES finds a library it sets HAVE_$LIBRARY=yes for you. Otherwise it is set to no. The extra bit which looks weird is you then have to call AC_DEFINE which exports the HAVE_FOO so it is in config.h and usable in C land.

@shaleh
Copy link
Collaborator

shaleh commented Jan 7, 2019

Ok, I just pushed some changes that should enable you to allocate the vterminal as a pseudovector. vterm_new is not defined so I could not easily test it. Details are in the commit message.

@brotzeit
Copy link
Member Author

brotzeit commented Jan 8, 2019

@shaleh Thanks. Your changes regarding the pseudovector were the same as mine, but it didn't work when I tried this because we didn't tag.

With LispObject::tag_ptr(v, Lisp_Type::Lisp_Vectorlike) it seems to work fine.

@shaleh
Copy link
Collaborator

shaleh commented Jan 8, 2019

@brotzeit you also missed adding the header to the top of struct vterminal.

@brotzeit
Copy link
Member Author

brotzeit commented Jan 8, 2019

No, I had that one. First post after your last post in #1130 ;)

I guess without that it wouldn't have run in the first place. It was just the segfault after a few insertions when vterm was already running.

Tagging solved the problem. I wonder if

    pub fn from_ptr(ptr: *mut c_void) -> Option<Self> {
        unsafe { ptr.as_ref().map(|p| mem::transmute(p)) }
    }

is also a source of potential problems ?

@shaleh
Copy link
Collaborator

shaleh commented Jan 8, 2019

Yeah, can be potentially dangerous if the wrong type is used. However, it is taking a pointer after it has been untagged. And the object returned should be retagged. If that is true it is safe.

fn ignore(path: &str) -> bool {
path == "" || path.starts_with('.') || path == "lib.rs" || path == "functions.rs"
}

#[cfg(not(feature = "libvterm"))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of repeating the base ignore maybe you should make a base_ignore which is all that the vterm version uses and the non-vterm version is it plus vterm.rs.

@@ -53,9 +53,9 @@ impl LispVterminalRef {
(height, width)
}

pub fn set_size(self, rows: EmacsInt, cols: EmacsInt) {
pub fn set_size(self, rows: c_int, cols: c_int) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to continue using c_int or should we transition to i32?

@brotzeit
Copy link
Member Author

I have another problem that confuses me. When I use describe-variable with the buffer local variable vterm--term in vterm-mode, I get a segfault.

@brotzeit
Copy link
Member Author

And resizing horizontally after window size change also doesn't work correctly.

@brotzeit
Copy link
Member Author

vterm_set_size only sets the height and not the width. @leonerd any idea what I'm doing wrong here ? It seems to work for neovim...

@leonerd
Copy link

leonerd commented Jan 14, 2019

Hrm.. werird. That should set both height and width at the same time. Do you have a link to the relevant code? I can't see a call to vterm_set_size in the changes in this PR


pub fn set_size(self, rows: i32, cols: i32) {
unsafe {
vterm_set_size((*self).vt, rows, cols);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leonerd Here. When I resize the window while htop is running it only updates the height. But when I exit htop and run it again it also gets the correct width. Maybe the reason is how emacs handles resizing...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is caused by the COLUMNS and LINES environment variable. Unset these before invoking htop and resizing will work.

@brotzeit brotzeit force-pushed the vterm_new branch 2 times, most recently from 0b08cb7 to 35a228a Compare January 17, 2019 20:52
@brotzeit
Copy link
Member Author

brotzeit commented Feb 5, 2019

I wonder if it wouldn't be better to vendor libvterm. neovim and emacs-libvterm both do it this way and it seems this is the reason why libvterm isn't up to date in the package repos. The arch linux package is orphaned. I could take care of the arch linux package, but what's with the other distros.

What do you think ?

@leonerd
Copy link

leonerd commented Feb 5, 2019

I don't know quite what "vendoring" means, but generally at the moment you want to be taking yourself a static snapshot of whatever version you've written code against, and only update that when you're updating code at the same time. Until I get around to actually stablising any last bits of API I know I'm going to be changing in future, I am not making version-numbered releases of libvterm. Best is to keep that static snapshot so you know APIs aren't going to change underneath you.

@brotzeit
Copy link
Member Author

brotzeit commented Feb 5, 2019

@leonerd I have read the term in neovim and emacs-libvterm so I thought this describes what we both mean ;)

But that's what I thought. Thanks.

@shaleh
Copy link
Collaborator

shaleh commented Feb 5, 2019

@brotzeit once @Wilfred sets up the remacs project you could bring libvterm there instead of adding more code to this quite large repo.

@brotzeit
Copy link
Member Author

brotzeit commented Feb 6, 2019

@shaleh Can you give me some source on how to add this to the build process. I was hoping I can take this from emacs-libvterm but I guess I can't use this cmake stuff ?

@shaleh
Copy link
Collaborator

shaleh commented Feb 14, 2019

My expectation is the user first builds the vterm library and puts it somewhere linkable. For instance in /usr/local/lib. Then they build remacs and the remacs configure script will find and set up the linking for vterm. Does this match your expectation @brotzeit?

This is how I am accustomed to handling C/C++ libraries in other open source projects. Look at the configure script for remacs. It fails and says "go figure libjpeg out and come back". Welcome to the days before bundling. The user was expected to either use a tool like apt/yum/whatever or to download and compile the package. Once done you go back and try again. Repeat until all dependencies are installed or you give up and use something already packaged.

@brotzeit
Copy link
Member Author

The only problem I see is that users get the wrong version for our remacs implementation. That's the reason why you told me to add libvterm to the remacs organization right ?

@shaleh
Copy link
Collaborator

shaleh commented Feb 17, 2019

Having the crate in the remacs org makes keeping the versions in sync easier. The user installs the vterm lib and then builds remacs.

@brotzeit
Copy link
Member Author

brotzeit commented Mar 10, 2019

I gave up with libvterm as a submodule. It seemed to me like a nice idea, but I don't get how this works.

I think with @akermu 's fixes it works pretty well. It would be great if we could start the final review.

@brotzeit brotzeit force-pushed the vterm_new branch 2 times, most recently from 7ba4871 to f72b63e Compare March 10, 2019 17:13
@brotzeit brotzeit force-pushed the vterm_new branch 2 times, most recently from c622d83 to 852a27a Compare March 10, 2019 18:51
@brotzeit
Copy link
Member Author

Scrollback still needs fixing, but since we make this optional this should be ok. We just mention in the readme libvterm support is not stable. Maybe some users get motivated to help with it when they see it works.

@brotzeit brotzeit closed this Aug 28, 2019
@brotzeit brotzeit deleted the vterm_new branch August 28, 2019 10:19
@leonerd
Copy link

leonerd commented Aug 28, 2019

It might be of interest to you folks that I've now made a v0.1 tarball release. Though bits of API are still verymuch subject to change, so expect that v0.2 will probably have some incompatible bits in it.

http://www.leonerd.org.uk/code/libvterm/

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

Successfully merging this pull request may close these issues.

None yet

4 participants