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

[Request - idea] Column numbers, relative numbers and color the current column #406

Closed
josegl opened this issue Oct 28, 2016 · 4 comments
Closed

Comments

@josegl
Copy link

josegl commented Oct 28, 2016

Just like the line numbers and relative line numbers, but for columns. Along with color current line (available now) and maybe a future color column you would have a big cross pointing at the current character, and with the line and column numbers, it would be ultra fast to move around the document instead to count whites, or whatever other way you use to move around the text file.

I think it would be very handy.
Thank you for reading 😄

@martanne
Copy link
Owner

Thanks for the idea. If I understand you correctly you would like to display relative column numbers for example at the top of the window?

The difference to lines number is of course that there is no horizontal space available to display digits taking more than one cell. Hence you would either have to stack the column numbers vertically (probably not a good idea) or only display every 5th value or so.

In any case this is probably not a feature suitable for the editor core. In the (distant) future it might be possible to do this in Lua. We would need to somehow expose the 2D cell grid to Lua.

@josegl
Copy link
Author

josegl commented Mar 5, 2018

I've been rethinking in this recently and I was wondering if it would be possible to have only the cross I mentioned in 2016, not the relative column numbers in the headline. I don't know if it would be very difficult or not, but I guess that if already it is possible to highlight a fixed column, and the current line, It maybe be not that complicated to highlight the current column as well.

@ghost
Copy link

ghost commented Mar 5, 2018

@josegl

diff --git a/vis.c b/vis.c
index 431c779..1b1912b 100644
--- a/vis.c
+++ b/vis.c
@@ -316,14 +316,16 @@ static void window_draw_cursorline(Win *win) {
        CellStyle style = win->ui->style_get(win->ui, UI_STYLE_CURSOR_LINE);
        Selection *sel = view_selections_primary_get(view);
        size_t lineno = view_cursors_line_get(sel)->lineno;
+       size_t colno = view_cursors_col(sel) - 1;
        for (Line *l = view_lines_first(view); l; l = l->next) {
                if (l->lineno == lineno) {
                        for (int x = 0; x < width; x++) {
                                l->cells[x].style.attr |= style.attr;
                                l->cells[x].style.bg = style.bg;
                        }
-               } else if (l->lineno > lineno) {
-                       break;
+               } else {
+                       l->cells[colno].style.attr |= style.attr;
+                       l->cells[colno].style.bg = style.bg;
                }
        }
 }

@josegl
Copy link
Author

josegl commented Mar 6, 2018

@TWO-FINGER
Thank you very much for pointing me in the correct direction.

Maybe I will try to update the code to allow this as an option that could be set from the visrc.lua file.

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