From e00df04511c8a5de2ddeeb30ed9dbfca1341d2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=2E=20R=C3=B8dseth?= Date: Wed, 7 Aug 2024 19:34:10 +0200 Subject: [PATCH] Show the col limit when in git mode or if ctrl-g has been pressed 3x --- v2/editor.go | 101 ++++++++++++++++++++++++------------------------ v2/highlight.go | 4 +- v2/keyloop.go | 1 + 3 files changed, 54 insertions(+), 52 deletions(-) diff --git a/v2/editor.go b/v2/editor.go index a06e185e..a539651b 100644 --- a/v2/editor.go +++ b/v2/editor.go @@ -23,56 +23,57 @@ import ( // Editor represents the contents and editor settings, but not settings related to the viewport or scrolling type Editor struct { - detectedTabs *bool // were tab or space indentations detected when loading the data? - breakpoint *Position // for the breakpoint/jump functionality in debug mode - gdb *gdb.Gdb // connection to gdb, if debugMode is enabled - sameFilePortal *Portal // a portal that points to the same file - lines map[int][]rune // the contents of the current document - macro *Macro // the contents of the current macro (will be cleared when esc is pressed) - filename string // the current filename - searchTerm string // the current search term, used when searching - stickySearchTerm string // used when going to the next match with ctrl-n, unless esc has been pressed - Theme // editor theme, embedded struct - pos Position // the current cursor and scroll position - indentation mode.TabsSpaces // spaces or tabs, and how many spaces per tab character - wrapWidth int // set to ie. 80 or 100 to trigger word wrap when typing to that column - mode mode.Mode // a filetype mode, like for git, markdown or various programming languages - debugShowRegisters int // show no register box, show changed registers, show all changed registers - previousY int // previous cursor position - previousX int // previous cursor position - lineBeforeSearch LineIndex // save the current line number before jumping between search results - playBackMacroCount int // number of times the macro should be played back, right now - rainbowParenthesis bool // rainbow parenthesis - redraw bool // if the contents should be redrawn in the next loop - sshMode bool // is o used over ssh, tmux or screen, in a way that usually requires extra redrawing? - debugMode bool // in a mode where ctrl-b toggles breakpoints, ctrl-n steps to the next line and ctrl-space runs the application - statusMode bool // display a status line at all times at the bottom of the screen - expandTags bool // can be used for XML and HTML - syntaxHighlight bool // syntax highlighting - stopParentOnQuit bool // send SIGQUIT to the parent PID when quitting - clearOnQuit bool // clear the terminal when quitting the editor, or not - quit bool // for indicating if the user wants to end the editor session - changed bool // has the contents changed, since last save? - readOnly bool // is the file read-only when initializing o? - debugHideOutput bool // hide the GDB stdout pane when in debug mode? - binaryFile bool // is this a binary file, or a text file? - wrapWhenTyping bool // wrap text at a certain limit when typing - addSpace bool // add a space to the editor, once - debugStepInto bool // when stepping to the next instruction, step into instead of over - slowLoad bool // was the initial file slow to load? (might be an indication of a slow disk or USB stick) - building bool // currently buildig code or exporting to a file? - runAfterBuild bool // run the application after building? - generatingTokens bool // is code or text being generated right now? - redrawCursor bool // if the cursor should be moved to the location it is supposed to be - fixAsYouType bool // fix each line as you type it in, using AI? - monitorAndReadOnly bool // monitor the file for changes and open it as read-only - primaryClipboard bool // use the primary or the secondary clipboard on UNIX? - jumpToLetterMode bool // jump directly to a highlighted letter - nanoMode bool // emulate GNU Nano - spellCheckMode bool // spell check mode? - createDirectoriesIfMissing bool // when saving a file, should directories be created if they are missing? - displayQuickHelp bool // display the quick help box? - drawProgress bool // used for drawing the progress character on the right side + detectedTabs *bool // were tab or space indentations detected when loading the data? + breakpoint *Position // for the breakpoint/jump functionality in debug mode + gdb *gdb.Gdb // connection to gdb, if debugMode is enabled + sameFilePortal *Portal // a portal that points to the same file + lines map[int][]rune // the contents of the current document + macro *Macro // the contents of the current macro (will be cleared when esc is pressed) + filename string // the current filename + searchTerm string // the current search term, used when searching + stickySearchTerm string // used when going to the next match with ctrl-n, unless esc has been pressed + Theme // editor theme, embedded struct + pos Position // the current cursor and scroll position + indentation mode.TabsSpaces // spaces or tabs, and how many spaces per tab character + wrapWidth int // set to ie. 80 or 100 to trigger word wrap when typing to that column + mode mode.Mode // a filetype mode, like for git, markdown or various programming languages + debugShowRegisters int // show no register box, show changed registers, show all changed registers + previousY int // previous cursor position + previousX int // previous cursor position + lineBeforeSearch LineIndex // save the current line number before jumping between search results + playBackMacroCount int // number of times the macro should be played back, right now + rainbowParenthesis bool // rainbow parenthesis + redraw bool // if the contents should be redrawn in the next loop + sshMode bool // is o used over ssh, tmux or screen, in a way that usually requires extra redrawing? + debugMode bool // in a mode where ctrl-b toggles breakpoints, ctrl-n steps to the next line and ctrl-space runs the application + statusMode bool // display a status line at all times at the bottom of the screen + showColumnLimitToggleCounter int // show the line where the column limit is (at 79 by default) + expandTags bool // can be used for XML and HTML + syntaxHighlight bool // syntax highlighting + stopParentOnQuit bool // send SIGQUIT to the parent PID when quitting + clearOnQuit bool // clear the terminal when quitting the editor, or not + quit bool // for indicating if the user wants to end the editor session + changed bool // has the contents changed, since last save? + readOnly bool // is the file read-only when initializing o? + debugHideOutput bool // hide the GDB stdout pane when in debug mode? + binaryFile bool // is this a binary file, or a text file? + wrapWhenTyping bool // wrap text at a certain limit when typing + addSpace bool // add a space to the editor, once + debugStepInto bool // when stepping to the next instruction, step into instead of over + slowLoad bool // was the initial file slow to load? (might be an indication of a slow disk or USB stick) + building bool // currently buildig code or exporting to a file? + runAfterBuild bool // run the application after building? + generatingTokens bool // is code or text being generated right now? + redrawCursor bool // if the cursor should be moved to the location it is supposed to be + fixAsYouType bool // fix each line as you type it in, using AI? + monitorAndReadOnly bool // monitor the file for changes and open it as read-only + primaryClipboard bool // use the primary or the secondary clipboard on UNIX? + jumpToLetterMode bool // jump directly to a highlighted letter + nanoMode bool // emulate GNU Nano + spellCheckMode bool // spell check mode? + createDirectoriesIfMissing bool // when saving a file, should directories be created if they are missing? + displayQuickHelp bool // display the quick help box? + drawProgress bool // used for drawing the progress character on the right side } // CopyLines will create a new map[int][]rune struct that is the copy of all the lines in the editor diff --git a/v2/highlight.go b/v2/highlight.go index 2ff0ee35..5f7a3ee7 100644 --- a/v2/highlight.go +++ b/v2/highlight.go @@ -587,8 +587,8 @@ func (e *Editor) WriteLines(c *vt100.Canvas, fromline, toline LineIndex, cx, cy xp := cx + lineRuneCount c.WriteRunesB(xp, yp, e.Foreground, bg, ' ', cw-lineRuneCount) - // Draw a gray line to remind the user of where the N-column limit is - if e.statusMode && lineRuneCount < uint(e.wrapWidth) { + // Draw a red line to remind the user of where the N-column limit is + if ((e.showColumnLimitToggleCounter+1)%4 == 0 || e.mode == mode.Git) && lineRuneCount <= uint(e.wrapWidth) { c.WriteRune(uint(e.wrapWidth), yp, e.Theme.StatusErrorForeground, bg, '|') } diff --git a/v2/keyloop.go b/v2/keyloop.go index a9c4c1c1..8e19dff4 100644 --- a/v2/keyloop.go +++ b/v2/keyloop.go @@ -1627,6 +1627,7 @@ func Loop(tty *vt100.TTY, fnord FilenameOrData, lineNumber LineNumber, colNumber if !jumpedToDefinition { status.ClearAll(c) e.statusMode = !e.statusMode + e.showColumnLimitToggleCounter++ if e.statusMode { status.ShowLineColWordCount(c, e, e.filename) }