1. 26 Mar, 2017 1 commit
  2. 24 Mar, 2017 4 commits
  3. 23 Mar, 2017 5 commits
  4. 22 Mar, 2017 30 commits
    • Benno Schulenberg's avatar
      tweaks: ehm... the warning is more important for the softwrap case · e46c6c96
      Benno Schulenberg authored
      But apparently none of these cases occur, because I can't trigger them.
      e46c6c96
    • Benno Schulenberg's avatar
    • Benno Schulenberg's avatar
      painting: don't try to start highlighting before column zero · 55159b7b
      Benno Schulenberg authored
      This could happen when a tab or a double-width character straddles
      the boundary between two softwrapped chunks.
      55159b7b
    • David Lawrence Ramsey's avatar
      softwrap: adjust firstcolumn when the window width changes · 0389a1d9
      David Lawrence Ramsey authored
      If the number of columns in the edit window changes (which currently
      only happens in two places: in regenerate_screen(), called when the
      window is resized; and in main(), when line numbering mode is toggled),
      the display will break if we're in softwrap mode and firstcolumn is
      nonzero.  This is because the column width of softwrapped chunks has
      changed, and firstcolumn is no longer the starting column of a chunk,
      an assumption that all code using firstcolumn relies on.
      
      To fix this problem, add a new function, ensure_firstcolumn_is_aligned(),
      to adjust firstcolumn to the starting column of the chunk it's on, and
      use it when the number of columns in the edit window changes.
      
      (Note that this function uses the simplest possible fix, and could
      probably be made more sophisticated.)
      0389a1d9
    • David Lawrence Ramsey's avatar
      softwrap: save and restore firstcolumn when replacing text · c1f70185
      David Lawrence Ramsey authored
      In do_replace(), replacing text may change firstcolumn if the next match
      is offscreen, and replacing text after that will not change it back.  In
      order to keep the viewport unchanged, we have to save and restore not
      just edittop, but firstcolumn as well.
      c1f70185
    • David Lawrence Ramsey's avatar
      softwrap: save and restore firstcolumn when internally spell-fixing text · c888edf4
      David Lawrence Ramsey authored
      In do_int_spell_fix(), spell-checking text may change firstcolumn if
      the next match is offscreen, and spell-checking text after that will
      not change it back.  In order to keep the viewport unchanged, we have
      to save and restore not just edittop, but firstcolumn as well.
      c888edf4
    • David Lawrence Ramsey's avatar
      softwrap: save firstcolumn when justifying, restore it when unjustifying · 7cd50b8c
      David Lawrence Ramsey authored
      In do_justify(), justifying text may change firstcolumn if the paragraph
      ends offscreen, and unjustifying the text again will not change it back.
      In order to keep the viewport unchanged, we have to save and restore not
      just edittop, but firstcolumn as well.
      7cd50b8c
    • David Lawrence Ramsey's avatar
      softwrap: save and restore firstcolumn when copying text · 6f0ed207
      David Lawrence Ramsey authored
      Copying text involves first cutting it and then quickly pasting it back.
      However, cutting the text may change firstcolumn if the mark is offscreen.
      To keep the viewport unchanged, copy_text() has to save and restore not
      just edittop, but firstcolumn as well.
      6f0ed207
    • David Lawrence Ramsey's avatar
      softwrap: account for softwrapped chunks when adding text · dd08b638
      David Lawrence Ramsey authored
      Now that we can add text to the bottom right corner of the screen
      without scrolling the full line onscreen, do_output() needs to refresh
      the screen in that case, since it would put the cursor offscreen
      otherwise.  Accomplish this by borrowing logic from do_right().
      dd08b638
    • David Lawrence Ramsey's avatar
      softwrap: account for firstcolumn when scrolling up a line · 93152d32
      David Lawrence Ramsey authored
      In do_up() when scroll_only is TRUE, if we're at the top of the screen
      in softwrap mode, it's not enough to check that edittop is on fileage.
      We also need to check that firstcolumn is zero.
      
      In do_up() when scroll_only is FALSE, if we're at the top of the screen
      in softwrap mode, current_y should be zero.  This is equivalent to how,
      in do_down() when scroll_only is FALSE, current_y is (editwinrows - 1)
      at the bottom of the screen in softwrap mode.  Since edittop can now
      be partially scrolled off the screen even when it takes up the entire
      screen, checking for edittop's being equal to openfile->current->next
      there no longer applies.
      93152d32
    • David Lawrence Ramsey's avatar
      softwrap: move the updating of a softwrapped line to a new function · 2f6c8987
      David Lawrence Ramsey authored
      The new function, update_softwrapped_line(), is called from inside
      update_line() when softwrap mode is on, so that existing calls remain
      unchanged.  It takes no index, instead displaying edittop from column
      firstcolumn, and all other lines from column zero.
      
      If current is on edittop, it's displayed using the edittop rules, but
      this is not a problem: if current[current_x] is above edittop at column
      firstcolumn, it's offscreen, and that should be handled before calling
      update_line() anyway.
      
      Together with the preceding bunch of changes,
      this fixes https://savannah.gnu.org/bugs/?47667.
      2f6c8987
    • David Lawrence Ramsey's avatar
      softwrap: account for firstcolumn in reset_cursor() · 98b029cf
      David Lawrence Ramsey authored
      When counting rows in softwrap mode, reset_cursor() should compensate for
      the number of softwrapped chunks that edittop takes up before firstcolumn.
      98b029cf
    • David Lawrence Ramsey's avatar
      softwrap: account for firstcolumn when checking for offscreen current · c0fa3f04
      David Lawrence Ramsey authored
      Make current_is_above_screen() check for current[current_x] being above
      edittop at column firstcolumn, and make current_is_below_screen() start
      counting down from edittop at column firstcolumn instead of edittop at
      column zero.  This means that both functions now account for softwrapped
      chunks properly.
      c0fa3f04
    • David Lawrence Ramsey's avatar
      softwrap: remove and replace workarounds for firstcolumn · e52d5b06
      David Lawrence Ramsey authored
      Actually enable scrolling edittop partially off the screen by making
      edit_scroll() and adjust_viewport() use firstcolumn properly when
      iterating through softwrapped chunks in softwrap mode, or lines in
      non-softwrap mode.
      
      In non-softwrap mode, firstcolumn should still always be zero, because
      it's initially set to that, and because passing it through the iterators
      will maintain it at that.
      
      This fixes https://savannah.gnu.org/bugs/?49100
      
      .
      Reported-by: default avatarDavid Lawrence Ramsey <pooka109@gmail.com>
      e52d5b06
    • David Lawrence Ramsey's avatar
      softwrap: prepare for a more flexible viewport · 4144f76e
      David Lawrence Ramsey authored
      We want to be able to scroll the line at edittop partially off the
      screen.  For this to be possible, the new variable firstcolumn stores
      the starting column of the viewport -- the starting column in the line
      that edittop points to.
      
      Since firstcolumn is used by go_back_chunks() and go_forward_chunks(),
      it can't be completely #ifdefed out when NANO_TINY is set, but outside
      of softwrap mode it should always be zero.
      
      Currently firstcolumn is initialized to zero, reset to zero when
      toggling softwrap mode off, and reset to zero when switching buffers
      while softwrap mode is off.  It's otherwise unused, but its uses are
      forthcoming.
      4144f76e
    • David Lawrence Ramsey's avatar
      weeding: remove ensure_line_is_visible() · 80b3a301
      David Lawrence Ramsey authored
      Since all lines can be partially scrolled off the screen now
      (except for the top line of the edit window, which is forthcoming),
      ensure_line_is_visible() is no longer needed.
      80b3a301
    • David Lawrence Ramsey's avatar
      weeding: remove maxlines and related code · 812ecaeb
      David Lawrence Ramsey authored
      Since all lines can be partially scrolled off the screen now
      (except for edittop, which is forthcoming), the maxlines global
      variable and its computation mechanism are no longer needed.
      812ecaeb
    • David Lawrence Ramsey's avatar
      softwrap: improve PageUp and PageDown's behavior with softwrapped chunks · d0c3084e
      David Lawrence Ramsey authored
      Use go_back_chunks() and go_forward_chunks() to move a screenful of
      lines or chunks up or down, instead of using special computations in
      the softwrap case.
      d0c3084e
    • David Lawrence Ramsey's avatar
      softwrap: improve Up and Down's behavior with softwrapped chunks · eb647dfb
      David Lawrence Ramsey authored
      Use go_back_chunks() and go_forward_chunks() in do_up() and do_down()
      (instead of using a special and complicated computation in do_down())
      so that they now properly move vertically to the previous/next chunk
      in softwrap mode.  This also means that do_left() and do_right() will
      now properly move vertically at actual line boundaries.
      eb647dfb
    • David Lawrence Ramsey's avatar
      softwrap: improve Left and Right's behavior with softwrapped chunks · 56402e75
      David Lawrence Ramsey authored
      Use the new "unclever" functionality of Home and End to make do_left()
      and do_right() move properly to the end of the previous chunk or to the
      start of the next chunk in softwrap mode when crossing a line boundary.
      (Furthermore, doing Up plus End, or Down plus Home, does all needed
      screen updates, which simplifies the code.)
      
      The do_left() and do_right() functions don't yet properly move vertically
      at line boundaries, but that will be fixed once do_up() and do_down() are
      updated for softwrap mode, which is forthcoming.
      
      This fixes https://savannah.gnu.org/bugs/?49384.
      56402e75
    • David Lawrence Ramsey's avatar
      tweaks: add a parameter to do_home() and do_end() · a5e106d7
      David Lawrence Ramsey authored
      Add the parameter be_clever to both functions.  When be_clever is FALSE,
      smart home and dynamic home are disabled in do_home(), and dynamic end is
      disabled in do_end(), so that these functions only move to the beginning
      or end of the current line or chunk.
      
      This simple home and end functionality is needed to improve do_left()
      and do_right()'s horizontal behavior with softwrapped chunks, which is
      forthcoming.
      a5e106d7
    • David Lawrence Ramsey's avatar
      softwrap: improve End's behavior with softwrapped chunks · e478682c
      David Lawrence Ramsey authored
      Make do_end() more useful in softwrap mode: let it move to the end of the
      current chunk instead of the end of the line; only when already at the end
      of a chunk, let it move to the end of the line.  This is "dynamic end".
      e478682c
    • David Lawrence Ramsey's avatar
      softwrap: improve Home's behavior with softwrapped lines · bd2d0863
      David Lawrence Ramsey authored
      Make do_home() more useful in softwrap mode: let it move to the beginning
      of the current chunk instead of to the beginning of the whole line; only
      when already at the beginning of a chunk, let it move to the beginning of
      the line.  This is called "dynamic home'.
      
      The above rules are ignored when --smarthome is in effect and the cursor
      is somewhere in the leading whitespace of a line -- then the cursor is
      moved to the first non-whitespace character of the line.
      bd2d0863
    • David Lawrence Ramsey's avatar
      tweaks: prepare for improvements to do_home() and do_end() · d8189703
      David Lawrence Ramsey authored
      These improvements will eventually make do_home() and do_end() take
      parameters.  Since the global function lists can hold only functions
      without parameters, preemptively add do_home_void() and do_end_void(),
      and make the global function lists use them.
      d8189703
    • David Lawrence Ramsey's avatar
      softwrap: iterate through softwrapped chunks better in do_mouse() · 52087408
      David Lawrence Ramsey authored
      Use go_back_chunks() and go_forward_chunks() to move from the row
      current_y is on to the row mouse_row is on.  Now softwrap mode and
      non-softwrap mode will behave the same way when we can scroll edittop
      partially off the screen, which is forthcoming.  Accordingly, remove
      the call to ensure_line_is_visible(), as it no longer applies.
      
      The old code did work, but it behaved differently between softwrap mode
      (which counted down from edittop) and non-softwrap mode (which counted
      up or down from current_y to take less time, and used a double loop to
      keep current from going to NULL).
      
      The new code counts up or down from current_y in both softwrap mode and
      non-softwrap mode.  In non-softwrap mode, it also avoids the double loop,
      since go_back_chunks() and go_forward_chunks() keep the filestructs they
      operate on from going to NULL.
      52087408
    • David Lawrence Ramsey's avatar
      softwrap: iterate through softwrapped chunks in adjust_viewport() · 2abf7b75
      David Lawrence Ramsey authored
      Use go_back_chunks() to adjust edittop, instead of special casing
      the computation of goal when softwrapping.  Now softwrap mode and
      non-softwrap mode will behave the same way when edittop can be
      partially scrolled off the screen, which is forthcoming.
      
      (Note that the top line of the screen can't be partially scrolled
      yet, so we have to work around that for now.)
      2abf7b75
    • David Lawrence Ramsey's avatar
      softwrap: iterate through softwrapped chunks in edit_scroll() · ba4858de
      David Lawrence Ramsey authored
      Use go_back_chunks() and go_forward_chunks() to adjust edittop and to
      move up or down to the scrolled region before updating the rows there.
      Now softwrap mode and non-softwrap mode will behave the same way when
      we can scroll the top line of the screen partially off the screen,
      which is forthcoming.
      
      (Note that the top line of the screen can't be partially scrolled yet,
      so we have to work around that for now.)
      ba4858de
    • David Lawrence Ramsey's avatar
      display: limit an optimization to non-softwrap mode · fa025f0c
      David Lawrence Ramsey authored
      Not drawing a line on a row if we're on the top row and scrolled down,
      or if we're on the bottom row and scrolled up, will only work properly
      if the line on that row takes up only that row.  The latter might not
      be the case in softwrap mode: if the line occupies multiple chunks and
      begins on that row -- in that case none of the chunks would be drawn.
      fa025f0c
    • David Lawrence Ramsey's avatar
      tweaks: rename need_horizontal_scroll() to line_needs_update() · eb369c0e
      David Lawrence Ramsey authored
      The old name made it sound as if it didn't apply in softwrap mode.  But
      it does: in softwrap mode a line needs updating  when the mark is on.
      eb369c0e
    • David Lawrence Ramsey's avatar
      softwrap: account for softwrap in get_page_start() · df2a4679
      David Lawrence Ramsey authored
      In softwrap mode, nano doesn't horizontally scroll lines at all, so in
      this case get_page_start() should always return zero.
      df2a4679