Skip to content

Commit

Permalink
Fix cursor misalignment occurs, we need disable resizeQuirk #39
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Jun 6, 2024
1 parent 6776db8 commit 7238615
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ en-US:
- Fix the crash problem caused by modifying the configuration of the currently running session
- Fix the problem of incorrect pop-up position of the context menu in the case of multiple screens
- Modify to switch to the tab when right-clicking on a non-current tab
- Fix the cursor alignment error in the local shell on the windows msvc version, need to disable resizeQuirk [#39](https://github.com/QQxiaoming/quardCRT/issues/39)

zh-CN:

Expand All @@ -19,6 +20,7 @@ zh-CN:
- 修复修改当前正在运行中的会话配置导致的崩溃问题
- 修复多屏幕的情况下,上下文菜单弹出位置错误问题
- 修改右击非当前标签页时,切换到该标签页
- 修复在windows msvc版本local shell光标对齐错误问题,需要禁用resizeQuirk [#39](https://github.com/QQxiaoming/quardCRT/issues/39)

## [[V0.4.6](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.4.6)] - 2024-05-26

Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fix the crash problem caused by modifying the configuration of the currently running session
- Fix the problem of incorrect pop-up position of the context menu in the case of multiple screens
- Modify to switch to the tab when right-clicking on a non-current tab
- Fix the cursor alignment error in the local shell on the windows msvc version, need to disable resizeQuirk [#39](https://github.com/QQxiaoming/quardCRT/issues/39)

## [[V0.4.6](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.4.6)] - 2024-05-26

Expand Down
6 changes: 5 additions & 1 deletion lib/ptyqt/conptyprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ HRESULT _CreatePseudoConsole(const HANDLE hToken,
// This is plenty of space to hold the formatted string
wchar_t cmd[MAX_PATH]{};
const BOOL bInheritCursor = (dwFlags & PSEUDOCONSOLE_INHERIT_CURSOR) == PSEUDOCONSOLE_INHERIT_CURSOR;
const BOOL bResizeQuirk = (dwFlags & PSEUDOCONSOLE_RESIZE_QUIRK) == PSEUDOCONSOLE_RESIZE_QUIRK;
// FIXME: QuardCRT is not support resizeQuirk
const BOOL bResizeQuirk = false; //(dwFlags & PSEUDOCONSOLE_RESIZE_QUIRK) == PSEUDOCONSOLE_RESIZE_QUIRK;
const BOOL bWin32InputMode = (dwFlags & PSEUDOCONSOLE_WIN32_INPUT_MODE) == PSEUDOCONSOLE_WIN32_INPUT_MODE;
swprintf_s(cmd,
MAX_PATH,
Expand Down Expand Up @@ -763,6 +764,7 @@ class WindowsContext
HPCON* phPC); // ConPty Reference

typedef HRESULT (*ResizePseudoConsolePtr)(HPCON hPC, COORD size);
typedef HRESULT (*ClearPseudoConsolePtr)(HPCON hPC);

typedef VOID (*ClosePseudoConsolePtr)(HPCON hPC);

Expand All @@ -777,6 +779,7 @@ class WindowsContext
createPseudoConsole = (CreatePseudoConsolePtr)ConptyCreatePseudoConsole;
resizePseudoConsole = (ResizePseudoConsolePtr)ConptyResizePseudoConsole;
closePseudoConsole = (ClosePseudoConsolePtr)ConptyClosePseudoConsole;
clearPseudoConsole = (ClearPseudoConsolePtr)ConptyClearPseudoConsole;

return true;
}
Expand All @@ -791,6 +794,7 @@ class WindowsContext
CreatePseudoConsolePtr createPseudoConsole{nullptr};
ResizePseudoConsolePtr resizePseudoConsole{nullptr};
ClosePseudoConsolePtr closePseudoConsole{nullptr};
ClearPseudoConsolePtr clearPseudoConsole{nullptr};

private:
QString m_lastError;
Expand Down
4 changes: 2 additions & 2 deletions lib/qtermwidget/History.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ class CompactHistoryBlock
#endif
}

virtual unsigned int remaining(){ return blockStart+blockLength-tail;}
virtual unsigned length() { return blockLength; }
virtual unsigned int remaining(){ return (unsigned int)(blockStart+blockLength-tail);}
virtual unsigned int length() { return (unsigned int)(blockLength); }
virtual void* allocate(size_t length);
virtual bool contains(void *addr) {return addr>=blockStart && addr<(blockStart+blockLength);}
virtual void deallocate();
Expand Down
8 changes: 8 additions & 0 deletions lib/qtermwidget/ScreenWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ int ScreenWindow::getCursorY() const {
return _screen->getCursorY();
}

void ScreenWindow::setCursorX(int x) {
_screen->setCursorX(x);
}

void ScreenWindow::setCursorY(int y) {
_screen->setCursorY(y);
}

QString ScreenWindow::getScreenText(int row1, int col1, int row2, int col2, int mode) {
return _screen->getScreenText( row1, col1, row2, col2, mode );
}
Expand Down
4 changes: 3 additions & 1 deletion lib/qtermwidget/ScreenWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ Q_OBJECT

int getCursorX() const;
int getCursorY() const;

void setCursorX(int x);
void setCursorY(int y);

/**
* Convenience method. Returns true if the window is currently at the bottom
* of the screen.
Expand Down
10 changes: 10 additions & 0 deletions lib/qtermwidget/TerminalDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3635,6 +3635,16 @@ int TerminalDisplay::getCursorY() const {
return _screenWindow.isNull() ? 0 : _screenWindow->getCursorY();
}

void TerminalDisplay::setCursorX(int x) {
if(!_screenWindow.isNull())
_screenWindow->setCursorX(x);
}

void TerminalDisplay::setCursorY(int y) {
if(!_screenWindow.isNull())
_screenWindow->setCursorY(y);
}

QString TerminalDisplay::screenGet(int row1, int col1, int row2, int col2, int mode) {
return _screenWindow.isNull() ? QString() : _screenWindow->getScreenText(row1, col1, row2, col2, mode);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/qtermwidget/TerminalDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ public slots:
/** Returns the line which the cursor is positioned on. */
int getCursorY() const;

void setCursorX(int x);
void setCursorY(int y);

QString screenGet(int row1, int col1, int row2, int col2, int mode);

void setLocked(bool enabled) { _isLocked = enabled; }
Expand Down
8 changes: 8 additions & 0 deletions lib/qtermwidget/qtermwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,14 @@ int QTermWidget::getCursorY() {
return m_impl->m_terminalDisplay->getCursorY();
}

void QTermWidget::setCursorX(int x) {
m_impl->m_terminalDisplay->setCursorX(x);
}

void QTermWidget::setCursorY(int y) {
m_impl->m_terminalDisplay->setCursorY(y);
}

QString QTermWidget::screenGet(int row1, int col1, int row2, int col2, int mode) {
return m_impl->m_terminalDisplay->screenGet(row1, col1, row2, col2, mode);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/qtermwidget/qtermwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ class QTermWidget : public QWidget {
int columns();
int getCursorX();
int getCursorY();
void setCursorX(int x);
void setCursorY(int y);

QString screenGet(int row1, int col1, int row2, int col2, int mode);

Expand Down

0 comments on commit 7238615

Please sign in to comment.