Mercurial > octave-nkf
comparison libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp @ 16628:a66c285729a6
use swapped points when getting selection text in Windows terminal
* QWinTerminalImpl.cpp (QConsolePrivagte::getSelection): Extract text
using swapped points, not original points.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 07 May 2013 15:52:13 -0400 |
parents | 818eef7b2618 |
children | cbaf19edc4ee |
comparison
equal
deleted
inserted
replaced
16627:de91b1621260 | 16628:a66c285729a6 |
---|---|
410 QPoint begin = m_beginSelection; | 410 QPoint begin = m_beginSelection; |
411 QPoint end = m_endSelection; | 411 QPoint end = m_endSelection; |
412 | 412 |
413 maybeSwapPoints (begin, end); | 413 maybeSwapPoints (begin, end); |
414 | 414 |
415 if (m_beginSelection != m_endSelection) | 415 if (begin != end) |
416 { | 416 { |
417 CHAR_INFO* buf; | 417 CHAR_INFO* buf; |
418 COORD bufSize, bufCoord; | 418 COORD bufSize, bufCoord; |
419 SMALL_RECT bufRect; | 419 SMALL_RECT bufRect; |
420 int nr; | 420 int nr; |
421 | 421 |
422 nr = m_endSelection.y () - m_beginSelection.y () + 1; | 422 nr = end.y () - begin.y () + 1; |
423 buf = new CHAR_INFO[m_bufferSize.width () * nr]; | 423 buf = new CHAR_INFO[m_bufferSize.width () * nr]; |
424 bufSize.X = m_bufferSize.width (); | 424 bufSize.X = m_bufferSize.width (); |
425 bufSize.Y = nr; | 425 bufSize.Y = nr; |
426 bufCoord.X = 0; | 426 bufCoord.X = 0; |
427 bufCoord.Y = 0; | 427 bufCoord.Y = 0; |
428 | 428 |
429 bufRect.Left = 0; | 429 bufRect.Left = 0; |
430 bufRect.Right = m_bufferSize.width (); | 430 bufRect.Right = m_bufferSize.width (); |
431 bufRect.Top = m_beginSelection.y (); | 431 bufRect.Top = begin.y (); |
432 bufRect.Bottom = m_endSelection.y (); | 432 bufRect.Bottom = end.y (); |
433 | 433 |
434 if (ReadConsoleOutput (m_stdOut, buf, bufSize, bufCoord, &bufRect)) | 434 if (ReadConsoleOutput (m_stdOut, buf, bufSize, bufCoord, &bufRect)) |
435 { | 435 { |
436 int start = m_beginSelection.x (); | 436 int start_pos = begin.x (); |
437 int end = (nr - 1) * m_bufferSize.width () + m_endSelection.x (); | 437 int end_pos = (nr - 1) * m_bufferSize.width () + end.x (); |
438 int lastNonSpace = -1; | 438 int lastNonSpace = -1; |
439 | 439 |
440 for (int i = start; i <= end; i++) | 440 for (int i = start_pos; i <= end_pos; i++) |
441 { | 441 { |
442 if (i && (i % m_bufferSize.width ()) == 0) | 442 if (i && (i % m_bufferSize.width ()) == 0) |
443 { | 443 { |
444 if (lastNonSpace >= 0) | 444 if (lastNonSpace >= 0) |
445 selection.truncate (lastNonSpace); | 445 selection.truncate (lastNonSpace); |