Git Product home page Git Product logo

Comments (8)

dbordak avatar dbordak commented on July 16, 2024

This is definitely something I want. It's a difficult problem, though, and I'm not sure how to do it efficiently. Yet.

from telephone-line.

Kethku avatar Kethku commented on July 16, 2024

Is the difficulty with implementing the code in an efficient manner or is it with writing an effective interface for the feature? I don't really have much to contribute either way, I'm just curious.

from telephone-line.

dbordak avatar dbordak commented on July 16, 2024

Figuring out how large a segment is requires rendering it. In order to figure out whether to collapse a given segment, you'd need to find out how big every other segment is. So, this would require doubling the amount of rendering going on.

...However, it's not as bad as it sounds, since empty segment detection already involves duplicated rendering. There's still logic on top of that, though...

from telephone-line.

Kethku avatar Kethku commented on July 16, 2024

I wonder if you could take a page from css and just give pixel minimums. Leave it up to the user to specify at which point each section gets removed from the mode line. I would be happy to just add an integer to each section which is minimum width in pixels or some such. I don't think it's necessary to over engineer the problem. That's just my two cents though.

from telephone-line.

dbordak avatar dbordak commented on July 16, 2024

Do you mean a maximum width?

Pixel count is actually really difficult to do. Luckily we're dealing in fixed-width fonts, though, so we can do character count. It'd be trivial to add truncation past a certain max, but that isn't really intelligent.

EDIT: Oh, do you mean a minimum amount of space you'd need to render the segment? So if there's not enough room, just skip it? This is what I was originally thinking of.

from telephone-line.

Kethku avatar Kethku commented on July 16, 2024

Haha words suck. What I was thinking is to add a number associated with each section which is the width, probably in characters sounds like, at which point for any width of the window smaller than that width, the section will not render.

Said differently, it is the minimum width of the window that a given section will display in. In many ways this might be sufficient for the majority of sections because they often have a constant width. Even more interesting would be to let the user specify a function which returns the width of the section. I would guess that usually the width could be known ahead of time without having to render the whole thing. Then taking that information it would be trivial to add a priority for what sections are more important to be included than others.

I could be completely mistaken though, as I haven't had the time to dig in to the code 😄.

from telephone-line.

dbordak avatar dbordak commented on July 16, 2024

Yeah, the rub is still that to find out how much space you have available, you need to check all the other ones... For some cases, true, you can easily figure out what it'll be. For others, it's highly variable (e.g. minor modes).

My original thought would be to attach a number for priority -- if there's not enough room to fit the whole thing, the segment with the lowest priority is booted first.

from telephone-line.

mattfidler avatar mattfidler commented on July 16, 2024

Smart mode line does something like this.

https://github.com/Malabarba/smart-mode-line

from telephone-line.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.