MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / EditStripLastCharacter

Function EditStripLastCharacter

src/Edit.c:3290–3323  ·  view source on GitHub ↗

============================================================================= EditStripLastCharacter()

Source from the content-addressed store, hash-verified

3288// EditStripLastCharacter()
3289//
3290void EditStripLastCharacter ( HWND hwnd )
3291{
3292 int iSelStart = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONSTART, 0, 0 );
3293 int iSelEnd = ( int ) SendMessage ( hwnd, SCI_GETSELECTIONEND, 0, 0 );
3294 if ( iSelStart == iSelEnd ) {
3295 iSelStart = 0;
3296 iSelEnd = ( int ) SendMessage ( hwnd, SCI_GETLENGTH, 0, 0 );
3297 }
3298 if ( SC_SEL_RECTANGLE != SendMessage ( hwnd, SCI_GETSELECTIONMODE, 0, 0 ) ) {
3299 int iLine;
3300 int iLineStart = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iSelStart, 0 );
3301 int iLineEnd = ( int ) SendMessage ( hwnd, SCI_LINEFROMPOSITION, ( WPARAM ) iSelEnd, 0 );
3302 if ( iSelStart >= SendMessage ( hwnd, SCI_GETLINEENDPOSITION, ( WPARAM ) iLineStart, 0 ) ) {
3303 iLineStart++;
3304 }
3305 if ( iSelEnd < SendMessage ( hwnd, SCI_GETLINEENDPOSITION, ( WPARAM ) iLineEnd, 0 ) ) {
3306 iLineEnd--;
3307 }
3308 SendMessage ( hwnd, SCI_BEGINUNDOACTION, 0, 0 );
3309 for ( iLine = iLineStart; iLine <= iLineEnd; iLine++ ) {
3310 int iStartPos = ( int ) SendMessage ( hwnd, SCI_POSITIONFROMLINE, ( WPARAM ) iLine, 0 );
3311 int iEndPos = ( int ) SendMessage ( hwnd, SCI_GETLINEENDPOSITION, ( WPARAM ) iLine, 0 );
3312 if ( iEndPos - iStartPos > 0 ) {
3313 SendMessage ( hwnd, SCI_SETTARGETSTART,
3314 ( WPARAM ) SendMessage ( hwnd, SCI_POSITIONBEFORE, ( WPARAM ) iEndPos, 0 ), 0 );
3315 SendMessage ( hwnd, SCI_SETTARGETEND, ( WPARAM ) iEndPos, 0 );
3316 SendMessage ( hwnd, SCI_REPLACETARGET, 0, ( LPARAM ) "" );
3317 }
3318 }
3319 SendMessage ( hwnd, SCI_ENDUNDOACTION, 0, 0 );
3320 } else {
3321 MsgBox ( MBINFO, IDS_SELRECT );
3322 }
3323}
3324
3325
3326//=============================================================================

Callers 1

MsgCommandFunction · 0.85

Calls 1

MsgBoxFunction · 0.85

Tested by

no test coverage detected