Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/teraterm/teraterm/addsetting.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 10443 by zmatsuo, Thu Dec 29 16:43:20 2022 UTC revision 10444 by zmatsuo, Fri Dec 30 15:46:12 2022 UTC
# Line 57  Line 57 
57  #include "themedlg.h"  #include "themedlg.h"
58  #include "theme.h"  #include "theme.h"
59  #include "ttcmn_notify2.h"  #include "ttcmn_notify2.h"
60  #include "filesys_log.h"        // for ConvertLognameW()  #include "filesys_log.h"        // for FLogGetLogFilenameBase()
61    
62  const mouse_cursor_t MouseCursor[] = {  const mouse_cursor_t MouseCursor[] = {
63          {"ARROW", IDC_ARROW},          {"ARROW", IDC_ARROW},
# Line 169  void CGeneralPropPageDlg::OnInitDialog() Line 169  void CGeneralPropPageDlg::OnInitDialog()
169    
170  void CGeneralPropPageDlg::OnOK()  void CGeneralPropPageDlg::OnOK()
171  {  {
         char buf[64];  
172          int val;          int val;
173    
174          // (1)          // (1)
# Line 182  void CGeneralPropPageDlg::OnOK() Line 181  void CGeneralPropPageDlg::OnOK()
181          ts.AcceptBroadcast = GetCheck(IDC_ACCEPT_BROADCAST);          ts.AcceptBroadcast = GetCheck(IDC_ACCEPT_BROADCAST);
182    
183          // (4)IDC_MOUSEWHEEL_SCROLL_LINE          // (4)IDC_MOUSEWHEEL_SCROLL_LINE
184          GetDlgItemText(IDC_SCROLL_LINE, buf, _countof(buf));          val = GetDlgItemInt(IDC_SCROLL_LINE);
         val = atoi(buf);  
185          if (val > 0)          if (val > 0)
186                  ts.MouseWheelScrollLine = val;                  ts.MouseWheelScrollLine = val;
187    
# Line 1366  private: Line 1364  private:
1364          enum { IDD = IDD_TABSHEET_LOG };          enum { IDD = IDD_TABSHEET_LOG };
1365          BOOL OnCommand(WPARAM wParam, LPARAM lParam);          BOOL OnCommand(WPARAM wParam, LPARAM lParam);
1366          void OnHelp();          void OnHelp();
1367          wchar_t *CreateLogFilename(const wchar_t *format);          wchar_t *MakePreviewStr(const wchar_t *format, const wchar_t *UILanguageFile);
1368          CTipWin *m_TipWin;          CTipWin *m_TipWin;
1369  };  };
1370    
# Line 1534  void CLogPropPageDlg::OnInitDialog() Line 1532  void CLogPropPageDlg::OnInitDialog()
1532          ::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_VIEWLOG_EDITOR));          ::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_VIEWLOG_EDITOR));
1533  }  }
1534    
1535  wchar_t *CLogPropPageDlg::CreateLogFilename(const wchar_t *format)  wchar_t *CLogPropPageDlg::MakePreviewStr(const wchar_t *format, const wchar_t *UILanguageFile)
1536  {  {
1537          time_t time_local;          wchar_t *str = FLogGetLogFilenameBase(format);
         struct tm tm_local;  
         time(&time_local);  
         localtime_s(&tm_local, &time_local);  
         wchar_t *str;  
1538    
1539            wchar_t *message = NULL;
1540          if (isInvalidStrftimeCharW(format)) {          if (isInvalidStrftimeCharW(format)) {
1541                  str = _wcsdup(L"Invalid character is included in log file name.");                  wchar_t *msg;
1542          }                  GetI18nStrWW("Tera Term", "MSG_LOGFILE_INVALID_CHAR_ERROR",
1543          else {                                           L"Invalid character is included in log file name.",
1544                  size_t len = 128;                                           UILanguageFile, &msg);
1545                  str = (wchar_t*)malloc(sizeof(wchar_t) * len);                  awcscats(&message, L"\r\n", msg, L"(strftime)", NULL);
1546                  wcsftime(str, len, format, &tm_local);                  free(msg);
1547                  wchar_t *replace = replaceInvalidFileNameCharW(str, L'_');          }
1548                  free(str);  
1549                  str = replace;          if (isInvalidFileNameCharW(format)) {
1550                    wchar_t *msg;
1551                  if (isInvalidFileNameCharW(str)) {                  GetI18nStrWW("Tera Term", "MSG_LOGFILE_INVALID_CHAR_ERROR",
1552                          free(str);                                           L"Invalid character is included in log file name.",
1553                          str = _wcsdup(L"Invalid character is included in log file name.");                                           UILanguageFile, &msg);
1554                  }                  awcscats(&message, L"\r\n", msg, L"(char)", NULL);
1555                  else {                  free(msg);
1556                          wchar_t *str2 = ConvertLognameW(&cv, str);          }
1557                          free(str);  
1558                          str = str2;          if (message != NULL) {
1559                  }                  awcscat(&str, message);
1560                    free(message);
1561          }          }
1562    
1563          return str;          return str;
1564  }  }
1565    
# Line 1674  BOOL CLogPropPageDlg::OnCommand(WPARAM w Line 1671  BOOL CLogPropPageDlg::OnCommand(WPARAM w
1671                          if (format == NULL) {                          if (format == NULL) {
1672                                  hGetDlgItemTextW(m_hWnd, IDC_DEFAULTNAME_EDITOR, &format);                                  hGetDlgItemTextW(m_hWnd, IDC_DEFAULTNAME_EDITOR, &format);
1673                          }                          }
1674                          wchar_t *str = CreateLogFilename(format);                          wchar_t *preview = MakePreviewStr(format, ts.UILanguageFileW);
1675                          if (wcslen(str) > 0) {                          if (preview[0] != 0 && wcscmp(format, preview) != 0) {
1676                                  RECT rc;                                  RECT rc;
1677                                  ::GetWindowRect(::GetDlgItem(m_hWnd, IDC_DEFAULTNAME_EDITOR), &rc);                                  ::GetWindowRect(::GetDlgItem(m_hWnd, IDC_DEFAULTNAME_EDITOR), &rc);
1678                                  m_TipWin->SetText(str);                                  m_TipWin->SetText(preview);
1679                                  m_TipWin->SetPos(rc.left, rc.bottom);                                  m_TipWin->SetPos(rc.left, rc.bottom);
1680                                  m_TipWin->SetHideTimer(5 * 1000);  // 表示時間                                  m_TipWin->SetHideTimer(5 * 1000);  // 表示時間
1681                                  if (!m_TipWin->IsVisible()) {                                  if (!m_TipWin->IsVisible()) {
# Line 1688  BOOL CLogPropPageDlg::OnCommand(WPARAM w Line 1685  BOOL CLogPropPageDlg::OnCommand(WPARAM w
1685                          else {                          else {
1686                                  m_TipWin->SetVisible(FALSE);                                  m_TipWin->SetVisible(FALSE);
1687                          }                          }
1688                          free(str);                          free(preview);
1689                          free(format);                          free(format);
1690                          return TRUE;                          return TRUE;
1691                  }                  }

Legend:
Removed from v.10443  
changed lines
  Added in v.10444

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26