Menu

#1591 Add API `SCI_FINDCOLUMN(line line, position column, int tabWidth) → position`

Won't_Implement
open
Scintilla (415)
5
1 day ago
1 day ago
YX Hao
No

Add API SCI_FINDCOLUMNEX(line line, position column, int tabWidth) → position

Hi,

Could we add a new API SCI_FINDCOLUMNEX(line line, position column, int tabWidth) → position?

Extend FindColumn() to something like:

Sci::Position Document::FindColumnEx(Sci::Line line, Sci::Position column, int tabWidth) const noexcept {

If tabWidth > 0, use it instead of tabInChars.

                columnCurrent = NextTab(columnCurrent, tabInChars);

This request/idea originated from https://github.com/zufuliu/notepad4/pull/1305#issuecomment-5713847205. We are planning to improve the /g CLI option for 3 types of "column" results of searching tool: character, bytes and column.
Due to the searching tools (ugrep) and editor (notepad4) will adopt different Tab width to calculate columns, it is very useful to get the target position of the searching tool.

Thanks in advance!

Discussion

  • Zufu Liu

    Zufu Liu - 1 day ago
    • labels: --> Scintilla
     
  • Zufu Liu

    Zufu Liu - 1 day ago

    I think this may not suitable for upstream Scintilla as SCI message can't support three parameters.

    As GetRelativePosition() is 3x slow than FindColumn() and doesn't stop at EOL, I'm planing to add new function (maybe just FindColumnEx(flag, CharacterRangeFull)) in Notepad4 that does the three types position finding:

    1. column, expand tab \t.
    2. character and byte treat tab as single column.
     
  • YX Hao

    YX Hao - 1 day ago

    Combining column and tabWidth into a struct is an option with minimal changes. Maybe

    struct ColumnCounter {
        position column;
        int tabWidth;
    };
    
     
  • Neil Hodgson

    Neil Hodgson - 1 day ago
    • Group: Initial --> Won't_Implement
     
  • Neil Hodgson

    Neil Hodgson - 1 day ago

    The messaging API can only take 2 parameters. Structs are avoided to ensure binary compatibility (there have been many issues with existing use of structs) and ease calling from scripting languages.

    Applications can implement their own features based on currently available APIs.

     

Log in to post a comment.