Skip to content

Commit

Permalink
RLogin-2.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kmiya-culti committed Apr 4, 2021
1 parent 8e6efed commit 21fad48
Show file tree
Hide file tree
Showing 32 changed files with 1,072 additions and 798 deletions.
114 changes: 94 additions & 20 deletions RLogin/AnyPastDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ CAnyPastDlg::CAnyPastDlg(CWnd* pParent /*=NULL*/)
m_bDelayPast = FALSE;
m_bUpdateEnable = FALSE;
m_CtrlCode[0] = m_CtrlCode[1] = m_CtrlCode[2] = 0;
m_pView = NULL;
m_pMain = NULL;
m_bCtrlView = FALSE;
m_DocSeqNumber = 0;
m_bDiffViewEnable = FALSE;
}

CAnyPastDlg::~CAnyPastDlg()
Expand All @@ -48,6 +50,7 @@ BEGIN_MESSAGE_MAP(CAnyPastDlg, CDialogExt)
ON_BN_CLICKED(IDC_SHELLESC, &CAnyPastDlg::OnShellesc)
ON_BN_CLICKED(IDC_ONELINE, &CAnyPastDlg::OnOneLine)
ON_BN_CLICKED(IDC_CHECK4, &CAnyPastDlg::OnCtrlView)
ON_WM_CLOSE()
END_MESSAGE_MAP()

static const INITDLGTAB ItemTab[] = {
Expand Down Expand Up @@ -198,6 +201,10 @@ BOOL CAnyPastDlg::OnInitDialog()

m_IconBox.SetIcon(LoadIcon(NULL, IDI_QUESTION));
m_bUpdateEnable = FALSE;
m_bDelayPast = AfxGetApp()->GetProfileInt(_T("AnyPastDlg"), _T("DelayPast"), FALSE);
m_bCtrlView = AfxGetApp()->GetProfileInt(_T("AnyPastDlg"), _T("CtrlView"), FALSE);
m_NoCheck = m_pMain->m_PastNoCheck;

UpdateData(FALSE);

if ( m_bCtrlView ) {
Expand All @@ -210,6 +217,7 @@ BOOL CAnyPastDlg::OnInitDialog()
CtrlCount();

CRect rect;
int sx = 0, sy = 0;
int cx, cy;

GetWindowRect(rect);
Expand All @@ -221,38 +229,115 @@ BOOL CAnyPastDlg::OnInitDialog()
if ( cy < rect.Height() )
cy = rect.Height();

MoveWindow(rect.left, rect.top, cx, cy, FALSE);
AfxGetMainWnd()->GetWindowRect(rect);
sx = rect.left + (rect.Width() - cx) / 2;
sy = rect.top + (rect.Height() - cy) / 2;

MoveWindow(sx, sy, cx, cy, FALSE);

AddShortCutKey(0, VK_RETURN, MASK_CTRL, 0, IDOK);

return TRUE;
}

void CAnyPastDlg::SaveWindowRect()
BOOL CAnyPastDlg::SendBracketedPaste(LPCTSTR str)
{
CRLoginDoc *pDoc;
CRLoginView *pView;

if ( (pDoc = m_pMain->GetMDIActiveDocument()) == NULL )
return FALSE;

if ( (pView = (CRLoginView *)pDoc->GetAciveView()) == NULL )
return FALSE;

if ( !m_bDiffViewEnable && (m_DocSeqNumber == 0 || m_DocSeqNumber != pDoc->m_DocSeqNumber) ) {
if ( AfxMessageBox(IDS_ANYPASTVIEWMSG, MB_ICONWARNING | MB_YESNO) != IDYES )
return FALSE;
m_bDiffViewEnable = TRUE;
}

if ( pView->m_HisOfs != 0 ) {
pView->m_HisOfs = 0;
pDoc->UpdateAllViews(NULL, UPDATE_INVALIDATE, NULL);
}

pView->SendBracketedPaste(TstrToUni(str), m_bDelayPast);

return TRUE;
}

BOOL CAnyPastDlg::UpdateTextData(BOOL bOk)
{
ASSERT(m_pMain != NULL);

if ( !IsIconic() ) {
CRect rect;
GetWindowRect(rect);
AfxGetApp()->WriteProfileInt(_T("AnyPastDlg"), _T("cx"), MulDiv(rect.Width(), m_InitDpi.cx, m_NowDpi.cx));
AfxGetApp()->WriteProfileInt(_T("AnyPastDlg"), _T("cy"), MulDiv(rect.Height(), m_InitDpi.cy, m_NowDpi.cy));
}

AfxGetApp()->WriteProfileInt(_T("AnyPastDlg"), _T("DelayPast"), m_bDelayPast);
AfxGetApp()->WriteProfileInt(_T("AnyPastDlg"), _T("CtrlView"), m_bCtrlView);
m_pMain->m_PastNoCheck = m_NoCheck;

if ( !bOk )
return FALSE;

if ( m_bUpdateText )
m_pMain->SetClipboardText(m_EditText);

return SendBracketedPaste(m_EditText);
}
void CAnyPastDlg::SetEditText(LPCTSTR str, int DocSeqNumber)
{
if ( m_bCtrlView )
str = CtrlStr(str, TRUE);
m_EditWnd.SetSel(0, -1, FALSE);
m_EditWnd.ReplaceSel(str, TRUE);
m_DocSeqNumber = DocSeqNumber;
}
void CAnyPastDlg::OnOK()
{
UpdateData(TRUE);

m_EditWnd.GetWindowText(m_EditText);
if ( m_bCtrlView )
m_EditText = CtrlStr(m_EditText, FALSE);
SaveWindowRect();
CDialogExt::OnOK();

//CDialogExt::OnOK();

if ( UpdateTextData(TRUE) )
DestroyWindow();
}
void CAnyPastDlg::OnCancel()
{
UpdateData(TRUE);
SaveWindowRect();
CDialogExt::OnCancel();

//CDialogExt::OnCancel();

UpdateTextData(FALSE);
DestroyWindow();
}
void CAnyPastDlg::OnClose()
{
UpdateData(TRUE);

CDialogExt::OnClose();

UpdateTextData(FALSE);
DestroyWindow();
}
void CAnyPastDlg::PostNcDestroy()
{
CDialogExt::PostNcDestroy();

if ( m_pMain != NULL )
m_pMain->m_pAnyPastDlg = NULL;

delete this;
}
void CAnyPastDlg::OnUpdateEdit()
{
m_bUpdateEnable = TRUE;
Expand Down Expand Up @@ -340,7 +425,6 @@ void CAnyPastDlg::OnOneLine()
{
int st, ed, mx;
LPCTSTR p;
CBuffer tmp;
CString str;

UpdateData(TRUE);
Expand Down Expand Up @@ -368,23 +452,13 @@ void CAnyPastDlg::OnOneLine()

} else {
// 範囲指定を送信
if ( st < ed && m_pView != NULL ) {
if ( st < ed ) {
str = m_EditText.Mid(st, ed - st);

if ( m_bCtrlView )
str = CtrlStr(str, FALSE);

for ( LPCTSTR s = str ; *s != _T('\0') ; ) {
if ( s[0] == L'\r' && s[1] == L'\n' ) {
// 改行は\rだけにする
tmp.PutWord(*s);
s += 2;
} else
tmp.PutWord(*(s++));
}

if ( tmp.GetSize() > 0 )
m_pView->SendBuffer(tmp, FALSE, m_bDelayPast);
SendBracketedPaste(str);
}

// 次行を範囲指定
Expand Down
10 changes: 8 additions & 2 deletions RLogin/AnyPastDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,24 @@ class CAnyPastDlg : public CDialogExt

CString m_EditText;
BOOL m_bUpdateEnable;
class CRLoginView *m_pView;
class CMainFrame *m_pMain;
int m_DocSeqNumber;
BOOL m_bDiffViewEnable;

public:
void CtrlCount();
void SaveWindowRect();
LPCTSTR CtrlStr(LPCTSTR str, BOOL bCtrl);
BOOL SendBracketedPaste(LPCTSTR str);
BOOL UpdateTextData(BOOL bOk);
void SetEditText(LPCTSTR str, int DocSeqNumber);

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV サポート
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual void OnCancel();
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void PostNcDestroy();

protected:
DECLARE_MESSAGE_MAP()
Expand All @@ -49,4 +54,5 @@ class CAnyPastDlg : public CDialogExt
afx_msg void OnShellesc();
afx_msg void OnOneLine();
afx_msg void OnCtrlView();
afx_msg void OnClose();
};
2 changes: 1 addition & 1 deletion RLogin/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5760,7 +5760,7 @@ static const struct _CmdsKeyTab {
{ IDM_SEARCH_NEXT, L"$SEARCH_NEXT" },
{ IDM_SEARCH_REG, L"$SEARCH_REG" },
{ IDM_SECPORICY, L"$SECURITYCOLICY" },
{ IDM_SPEEKALL, L"$SPEEK_ALL" },
{ IDM_SPEAKALL, L"$SPEAK_ALL" },
{ ID_SPLIT_HEIGHT, L"$SPLIT_HEIGHT" },
{ IDM_SPLIT_HEIGHT_NEW, L"$SPLIT_HEIGHTNEW" },
{ ID_SPLIT_OVER, L"$SPLIT_OVER" },
Expand Down
14 changes: 14 additions & 0 deletions RLogin/DialogExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ BOOL CDialogExt::IsDialogExt(CWnd *pWnd)

return FALSE;
}
void CDialogExt::GetDlgFontBase(CDC *pDC, CFont *pFont, CSize &size)
{
CSize TextSize;
TEXTMETRIC TextMetric;
CFont *pOld;

pOld = pDC->SelectObject(pFont);
pDC->GetTextMetrics(&TextMetric);
::GetTextExtentPoint32(pDC->GetSafeHdc(), _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52, &TextSize);
size.cx = (TextSize.cx + 26) / 52;
size.cy = (TextMetric.tmHeight + TextMetric.tmExternalLeading);
pDC->SelectObject(pOld);
}

void CDialogExt::CheckMoveWindow(CRect &rect, BOOL bRepaint)
{
HMONITOR hMonitor;
Expand Down
1 change: 1 addition & 0 deletions RLogin/DialogExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CDialogExt : public CDialog

static void GetActiveDpi(CSize &dpi, CWnd *pWnd, CWnd *pParent);
static BOOL IsDialogExt(CWnd *pWnd);
static void GetDlgFontBase(CDC *pDC, CFont *pFont, CSize &size);

// オーバーライド
public:
Expand Down
56 changes: 55 additions & 1 deletion RLogin/ExtFileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,58 @@ BEGIN_MESSAGE_MAP(CExtFileDialog, CFileDialog)
ON_WM_DESTROY()
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CExtFileDialog::OnTcnSelchangeTab1)
END_MESSAGE_MAP()

void CExtFileDialog::FontSizeCheck()
{
CDC *pDc = GetDC();
CFont *pFont;
CSize ZoomMul, ZoomDiv, AddSize;
int AddTop;
CRect rect;
WINDOWPLACEMENT place;
CString FontName = ::AfxGetApp()->GetProfileString(_T("Dialog"), _T("FontName"), _T(""));
int FontSize = MulDiv(::AfxGetApp()->GetProfileInt(_T("Dialog"), _T("FontSize"), 9), SCREEN_DPI_Y, SYSTEM_DPI_Y);

if ( FontName.IsEmpty() && FontSize == 9 )
return;

if ( m_NewFont.GetSafeHandle() != NULL ) {
CDialogExt::GetDlgFontBase(pDc, &m_NewFont, ZoomDiv);
m_NewFont.DeleteObject();
} else if ( (pFont = GetFont()) != NULL ) {
CDialogExt::GetDlgFontBase(pDc, pFont, ZoomDiv);
} else
return;

if ( !m_NewFont.CreatePointFont(FontSize * 10, FontName) )
return;

CDialogExt::GetDlgFontBase(pDc, &m_NewFont, ZoomMul);
ReleaseDC(pDc);

m_TabCtrl.GetWindowPlacement(&place);
AddTop = place.rcNormalPosition.bottom;
place.rcNormalPosition.right = place.rcNormalPosition.left + (place.rcNormalPosition.right - place.rcNormalPosition.left) * ZoomMul.cx / ZoomDiv.cx;
place.rcNormalPosition.bottom = place.rcNormalPosition.top + (place.rcNormalPosition.bottom - place.rcNormalPosition.top) * ZoomMul.cy / ZoomDiv.cy;
AddTop = place.rcNormalPosition.bottom - AddTop;
m_TabCtrl.SetWindowPlacement(&place);
m_TabCtrl.SetFont(&m_NewFont, TRUE);

m_Frame.GetWindowPlacement(&place);
AddSize.cx = place.rcNormalPosition.right - place.rcNormalPosition.left;
AddSize.cy = place.rcNormalPosition.bottom - place.rcNormalPosition.top;
place.rcNormalPosition.right = place.rcNormalPosition.left + (place.rcNormalPosition.right - place.rcNormalPosition.left) * ZoomMul.cx / ZoomDiv.cx;
place.rcNormalPosition.bottom = place.rcNormalPosition.top + (place.rcNormalPosition.bottom - place.rcNormalPosition.top) * ZoomMul.cy / ZoomDiv.cy;
place.rcNormalPosition.top += AddTop;
place.rcNormalPosition.bottom += AddTop;
AddSize.cx = (place.rcNormalPosition.right - place.rcNormalPosition.left) - AddSize.cx;
AddSize.cy = (place.rcNormalPosition.bottom - place.rcNormalPosition.top) - AddSize.cy;
m_Frame.SetWindowPlacement(&place);
m_Frame.SetFont(&m_NewFont, TRUE);

GetWindowRect(rect);
SetWindowPos(NULL, 0, 0, rect.Width() + AddSize.cx, rect.Height() + AddSize.cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_SHOWWINDOW);
}

BOOL CExtFileDialog::OnInitDialog()
{
Expand All @@ -397,8 +449,10 @@ BOOL CExtFileDialog::OnInitDialog()
// WM_GETDLGCODE loop ... HELP!!!
// https://groups.google.com/forum/#!topic/comp.os.ms-windows.programmer.controls/y0tPgUrDpGk

if ( m_DialogMode != 0 )
if ( m_DialogMode != 0 ) {
ModifyStyleEx(0, WS_EX_CONTROLPARENT);
FontSizeCheck();
}

switch(m_DialogMode) {
case EXTFILEDLG_DOWNLOAD:
Expand Down
4 changes: 4 additions & 0 deletions RLogin/ExtFileDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ class CExtFileDialog : public CFileDialog
CFileUpSendPage *m_pUpSend;
CFileDownPage *m_pDownPage;

CFont m_NewFont;

void FontSizeCheck();

public:
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV サポート
Expand Down
Loading

0 comments on commit 21fad48

Please sign in to comment.