Skip to content

Commit

Permalink
Merge pull request #406 from TeraTermProject/402-add_history
Browse files Browse the repository at this point in the history
ヒストリ(履歴)を扱うファイルを追加 #402
  • Loading branch information
zmatsuo authored Dec 21, 2024
2 parents 25e61a4 + 077e9b9 commit 272a336
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 203 deletions.
2 changes: 2 additions & 0 deletions teraterm/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ add_library(
fileread.h
getcontent.cpp
getcontent.h
history_store.cpp
history_store.h
i18n.c
i18n.h
i18n_static.c
Expand Down
36 changes: 0 additions & 36 deletions teraterm/common/dlglib_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,42 +486,6 @@ void SetDlgItemIcon(HWND dlg, int nID, const wchar_t *name, int cx, int cy)
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)data);
}

/**
* 接続したホスト履歴をコンボボックスまたはリストボックスにセットする
*/
void SetComboBoxHostHistory(HWND dlg, int dlg_item, int maxhostlist, const wchar_t *SetupFNW)
{
char class_name[32];
UINT message;
int r = GetClassNameA(GetDlgItem(dlg, dlg_item), class_name, _countof(class_name));
if (r == 0) {
return;
}
if (strcmp(class_name, "ComboBox") == 0) {
message = CB_ADDSTRING;
}
else if (strcmp(class_name, "ListBox") == 0) {
message = LB_ADDSTRING;
}
else {
assert(FALSE);
return;
}

int i = 1;
do {
wchar_t EntNameW[128];
wchar_t *TempHostW;
_snwprintf_s(EntNameW, _countof(EntNameW), _TRUNCATE, L"host%d", i);
hGetPrivateProfileStringW(L"Hosts", EntNameW, L"", SetupFNW, &TempHostW);
if (TempHostW[0] != 0) {
SendDlgItemMessageW(dlg, dlg_item, message, 0, (LPARAM)TempHostW);
}
free(TempHostW);
i++;
} while (i <= maxhostlist);
}

/**
* ウィンドウにアイコンをセットする
*
Expand Down
29 changes: 6 additions & 23 deletions teraterm/common/edithistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "helpid.h"
#include "win32helper.h"
#include "resize_helper.h"
#include "history_store.h"

#include "edithistory_res.h"
#include "edithistory.h"
Expand Down Expand Up @@ -87,28 +88,10 @@ static void ModifyListboxHScrollWidth(HWND dlg, int dlg_item)
*/
static void WriteListBoxHostHistory(HWND dlg, int dlg_item, int maxhostlist, const wchar_t *SetupFNW)
{
LRESULT item_count;
LRESULT i;

item_count = SendDlgItemMessageW(dlg, dlg_item, LB_GETCOUNT, 0, 0);
if (item_count == LB_ERR) {
return;
}

// [Hosts] をすべて削除
WritePrivateProfileStringW(L"Hosts", NULL, NULL, SetupFNW);

if (item_count > maxhostlist) {
item_count = maxhostlist;
}
for (i = 0; i < item_count; i++) {
wchar_t EntNameW[10];
wchar_t *strW;
GetDlgItemIndexTextW(dlg, dlg_item, (WPARAM)i, &strW);
_snwprintf_s(EntNameW, _countof(EntNameW), _TRUNCATE, L"Host%i", (int)i + 1);
WritePrivateProfileStringW(L"Hosts", EntNameW, strW, SetupFNW);
free(strW);
}
HistoryStore *hs = HistoryStoreCreate(maxhostlist);
HistoryStoreGetControl(hs, dlg, dlg_item);
HistoryStoreSaveIni(hs, SetupFNW, L"Hosts", L"host");
HistoryStoreDestroy(hs);
}

/**
Expand Down Expand Up @@ -142,7 +125,7 @@ static void TCPIPDlgButtons(HWND Dialog)

typedef struct {
ReiseDlgHelper_t *resize_helper;
EditHistoryDlgData *parent_data;
const EditHistoryDlgData *parent_data;
} DlgData;

static INT_PTR CALLBACK TCPIPDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
Expand Down
Loading

0 comments on commit 272a336

Please sign in to comment.