Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff -ur config.c config.c
--- config.c 2009-03-05 23:45:39.120000000 +0900
+++ config.c 2009-03-05 23:46:14.995000000 +0900
@@ -11,6 +11,7 @@
#include "storage.h"
#define PRINTER_DISABLED_STRING "None (printing disabled)"
+#define PRINT_TO_CLIPBOARD_STRING "Windows clipboard"
#define HOST_BOX_TITLE "Host Name (or IP address)"
#define PORT_BOX_TITLE "Port"
@@ -292,30 +293,14 @@
{
Config *cfg = (Config *)data;
if (event == EVENT_REFRESH) {
- int nprinters, i;
- printer_enum *pe;
-
- dlg_update_start(ctrl, dlg);
- /*
- * Some backends may wish to disable the drop-down list on
- * this edit box. Be prepared for this.
- */
- if (ctrl->editbox.has_list) {
- dlg_listbox_clear(ctrl, dlg);
- dlg_listbox_add(ctrl, dlg, PRINTER_DISABLED_STRING);
- pe = printer_start_enum(&nprinters);
- for (i = 0; i < nprinters; i++)
- dlg_listbox_add(ctrl, dlg, printer_get_name(pe, i));
- printer_finish_enum(pe);
- }
- dlg_editbox_set(ctrl, dlg,
- (*cfg->printer ? cfg->printer :
- PRINTER_DISABLED_STRING));
- dlg_update_done(ctrl, dlg);
+ dlg_update_start(ctrl, dlg);
+ dlg_listbox_add(ctrl,dlg,PRINT_TO_CLIPBOARD_STRING);
+ dlg_editbox_set(ctrl,dlg,PRINT_TO_CLIPBOARD_STRING);
+ dlg_update_done(ctrl,dlg);
} else if (event == EVENT_VALCHANGE) {
- dlg_editbox_get(ctrl, dlg, cfg->printer, sizeof(cfg->printer));
- if (!strcmp(cfg->printer, PRINTER_DISABLED_STRING))
- *cfg->printer = '\0';
+ dlg_editbox_get(ctrl, dlg, cfg->printer, sizeof(cfg->printer));
+ *cfg->printer = '\0';
+ cfg->printclip = 1;
}
}
@@ -616,7 +601,7 @@
static const char *const colours[] = {
"Default Foreground", "Default Bold Foreground",
"Default Background", "Default Bold Background",
- "Cursor Text", "Cursor Colour",
+ "Cursor Text", "Cursor Colour", "IME Cursor colour",
"ANSI Black", "ANSI Black Bold",
"ANSI Red", "ANSI Red Bold",
"ANSI Green", "ANSI Green Bold",
diff -ur logging.c logging.c
--- logging.c 2009-03-05 23:45:39.510625000 +0900
+++ logging.c 2009-03-05 14:15:33.375000000 +0900
@@ -21,7 +21,7 @@
Config cfg;
};
-static void xlatlognam(Filename *d, Filename s, char *hostname, struct tm *tm);
+static void xlatlognam(Filename *d, Filename s, char *hostname, int *port, struct tm *tm);
/*
* Internal wrapper function which must be called for _all_ output
@@ -147,7 +147,7 @@
tm = ltime();
/* substitute special codes in file name */
- xlatlognam(&ctx->currlogfilename, ctx->cfg.logfilename,ctx->cfg.host, &tm);
+ xlatlognam(&ctx->currlogfilename, ctx->cfg.logfilename,ctx->cfg.host,ctx->cfg.port, &tm);
ctx->lgfp = f_open(ctx->currlogfilename, "r", FALSE); /* file already present? */
if (ctx->lgfp) {
@@ -358,7 +358,7 @@
* "&Y":YYYY "&m":MM "&d":DD "&T":hhmmss "&h":<hostname> "&&":&
*/
static void xlatlognam(Filename *dest, Filename src,
- char *hostname, struct tm *tm) {
+ char *hostname, int *port, struct tm *tm) {
char buf[10], *bufp;
int size;
char buffer[FILENAME_MAX];
@@ -393,6 +393,10 @@
bufp = hostname;
size = strlen(bufp);
break;
+ case 'p':
+ sprintf(bufp,"%d",port);
+ size = strlen(bufp);
+ break;
default:
buf[0] = '&';
size = 1;
diff -ur putty.h putty.h
--- putty.h 2009-03-05 23:45:39.885625000 +0900
+++ putty.h 2009-02-26 18:43:24.312500000 +0900
@@ -607,6 +607,7 @@
int window_border;
char answerback[256];
char printer[128];
+ int printclip;
int arabicshaping;
int bidi;
/* Colour options */
@@ -615,7 +616,7 @@
int system_colour;
int try_palette;
int bold_colour;
- unsigned char colours[22][3];
+ unsigned char colours[23][3];
/* Selection options */
int mouse_is_xterm;
int rect_select;
diff -ur settings.c settings.c
--- settings.c 2009-03-05 23:45:39.916875000 +0900
+++ settings.c 2009-02-26 18:51:52.000000000 +0900
@@ -383,7 +383,7 @@
write_setting_i(sesskey, "Xterm256Colour", cfg->xterm_256_colour);
write_setting_i(sesskey, "BoldAsColour", cfg->bold_colour);
- for (i = 0; i < 22; i++) {
+ for (i = 0; i < 23; i++) {
char buf[20], buf2[30];
sprintf(buf, "Colour%d", i);
sprintf(buf2, "%d,%d,%d", cfg->colours[i][0],
@@ -409,7 +409,7 @@
write_setting_s(sesskey, "LineCodePage", cfg->line_codepage);
write_setting_i(sesskey, "CJKAmbigWide", cfg->cjk_ambig_wide);
write_setting_i(sesskey, "UTF8Override", cfg->utf8_override);
- write_setting_s(sesskey, "Printer", cfg->printer);
+ write_setting_i(sesskey, "Printer", cfg->printclip);
write_setting_i(sesskey, "CapsLockCyr", cfg->xlat_capslockcyr);
write_setting_i(sesskey, "Use5Casis", cfg->use_5casis);
write_setting_i(sesskey, "ScrollBar", cfg->scrollbar);
@@ -687,10 +687,10 @@
gppi(sesskey, "Xterm256Colour", 1, &cfg->xterm_256_colour);
gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour);
- for (i = 0; i < 22; i++) {
+ for (i = 0; i < 23; i++) {
static const char *const defaults[] = {
"187,187,187", "255,255,255", "0,0,0", "85,85,85", "0,0,0",
- "0,255,0", "0,0,0", "85,85,85", "187,0,0", "255,85,85",
+ "0,255,0", "0,0,255", "0,0,0", "85,85,85", "187,0,0", "255,85,85",
"0,187,0", "85,255,85", "187,187,0", "255,255,85", "0,0,187",
"85,85,255", "187,0,187", "255,85,255", "0,187,187",
"85,255,255", "187,187,187", "255,255,255"
@@ -760,9 +760,9 @@
}
gppi(sesskey, "CJKAmbigWide", 0, &cfg->cjk_ambig_wide);
gppi(sesskey, "UTF8Override", 1, &cfg->utf8_override);
- gpps(sesskey, "Printer", "", cfg->printer, sizeof(cfg->printer));
- gppi (sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr);
- gppi (sesskey, "Use5Casis", 0, &cfg->use_5casis);
+ gppi(sesskey, "Printer", "Windows clipboard", &cfg->printclip);
+ gppi(sesskey, "CapsLockCyr", 0, &cfg->xlat_capslockcyr);
+ gppi(sesskey, "Use5Casis", 0, &cfg->use_5casis);
gppi(sesskey, "ScrollBar", 1, &cfg->scrollbar);
gppi(sesskey, "ScrollBarFullScreen", 0, &cfg->scrollbar_in_fullscreen);
gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key);
diff -ur terminal.c terminal.c
--- terminal.c 2009-03-05 23:45:40.041875000 +0900
+++ terminal.c 2009-03-05 23:46:15.041875000 +0900
@@ -1397,7 +1397,7 @@
term->sco_acs = term->alt_sco_acs = 0;
term->utf = 0;
}
- if (!*term->cfg.printer) {
+ if (!*term->cfg.printer || term->cfg.printclip) {
term_print_finish(term);
}
term_schedule_tblink(term);
@@ -2445,12 +2445,68 @@
}
/*
+ * Windows clipboard support
+ * Diomidis Spinellis, June 2003
+ */
+static char *clip_b, *clip_bp; /* Buffer, pointer to buffer insertion point */
+static size_t clip_bsiz, clip_remsiz; /* Buffer, size, remaining size */
+static size_t clip_total; /* Total read */
+
+#define CLIP_CHUNK 4096
+
+static void clipboard_init(void)
+{
+ if (clip_b)
+ sfree(clip_b);
+ clip_bp = clip_b = smalloc(clip_remsiz = clip_bsiz = CLIP_CHUNK);
+ clip_total = 0;
+}
+
+static void clipboard_data(void *buff, int len)
+{
+ memcpy(clip_bp, buff, len);
+ clip_remsiz -= len;
+ clip_total += len;
+ clip_bp += len;
+ if (clip_remsiz < CLIP_CHUNK) {
+ clip_b = srealloc(clip_b, clip_bsiz *= 2);
+ clip_remsiz = clip_bsiz - clip_total;
+ clip_bp = clip_b + clip_total;
+ }
+}
+
+static void clipboard_copy(void)
+{
+ HANDLE hglb;
+
+ if (!OpenClipboard(NULL))
+ return; // error("Unable to open the clipboard");
+ if (!EmptyClipboard()) {
+ CloseClipboard();
+ return; // error("Unable to empty the clipboard");
+ }
+
+ hglb = GlobalAlloc(GMEM_DDESHARE, clip_total + 1);
+ if (hglb == NULL) {
+ CloseClipboard();
+ return; // error("Unable to allocate clipboard memory");
+ }
+ memcpy(hglb, clip_b, clip_total);
+ ((char *)hglb)[clip_total] = '\0';
+ SetClipboardData(CF_TEXT, hglb);
+ CloseClipboard();
+}
+
+/*
* ANSI printing routines.
*/
static void term_print_setup(Terminal *term)
{
bufchain_clear(&term->printer_buf);
- term->print_job = printer_start_job(term->cfg.printer);
+ if (term->cfg.printclip)
+ clipboard_init();
+ else
+ term->print_job = printer_start_job(term->cfg.printer);
}
static void term_print_flush(Terminal *term)
{
@@ -2461,8 +2517,11 @@
bufchain_prefix(&term->printer_buf, &data, &len);
if (len > size-5)
len = size-5;
- printer_job_data(term->print_job, data, len);
- bufchain_consume(&term->printer_buf, len);
+ if (term->cfg.printclip)
+ clipboard_data(data, len);
+ else
+ printer_job_data(term->print_job, data, len);
+ bufchain_consume(&term->printer_buf, len);
}
}
static void term_print_finish(Terminal *term)
@@ -2482,11 +2541,18 @@
bufchain_consume(&term->printer_buf, size);
break;
} else {
- printer_job_data(term->print_job, &c, 1);
+ //printer_job_data(term->print_job, &c, 1);
+ if (term->cfg.printclip)
+ clipboard_data(&c, 1);
+ else
+ printer_job_data(term->print_job, &c, 1);
bufchain_consume(&term->printer_buf, 1);
}
}
- printer_finish_job(term->print_job);
+ if (term->cfg.printclip)
+ clipboard_copy();
+ else
+ printer_finish_job(term->print_job);
term->print_job = NULL;
term->printing = term->only_printing = FALSE;
}
@@ -3470,7 +3536,7 @@
compatibility(VT100);
{
if (term->esc_nargs != 1) break;
- if (term->esc_args[0] == 5 && *term->cfg.printer) {
+ if (term->esc_args[0] == 5 && (*term->cfg.printer || term->cfg.printclip)) {
term->printing = TRUE;
term->only_printing = !term->esc_query;
term->print_state = 0;
diff -ur windows/putty.lng windows/putty.lng
--- windows/putty.lng 2009-03-05 23:45:40.604375000 +0900
+++ windows/putty.lng 2009-03-05 23:50:38.151250000 +0900
@@ -192,7 +192,8 @@
Default Background=標準の背景
Default Bold Background=標準の強調背景
Cursor Text=カーソル上の文字
-Cursor Colour=カーソルの色
+Cursor Colour=IME_OFF時カーソルの色
+IME Cursor Colour=IME_ON時カーソルの色
ANSI Black=ANSI 黒
ANSI Black Bold=ANSI 黒 太字
ANSI Red=ANSI 赤
@@ -482,7 +483,7 @@
Port=ポート
Serial line=シリアルポート
Speed=スピード
-(Log file name can contain &Y, &M, &D for date, &T for time, and &H for host name)=(ログファイル名は, 日付を表す &Y, &M, &D, 時刻を表す &T, ホスト名を表す &H を含むことができます)
+(Log file name can contain &Y, &M, &D for date, &T for time, and &H for host name)=(ログファイル名は, 日付を表す &Y, &M, &D, 時刻を表す &T, ホスト名を表す &H, ポート番号を表す &P を含むことができます)
(Codepages supported by Windows but not listed here, such as CP866 on many systems, can be entered manually)=(CP866 のように, Windows が対応していて 一覧にない コードページも, 入力できます)
Telnet command, or local proxy command=Telnetコマンドまたはローカルプロキシコマンド
Proxy=プロキシ
diff -ur windows/puttytel.lng windows/puttytel.lng
--- windows/puttytel.lng 2009-03-05 23:45:40.635625000 +0900
+++ windows/puttytel.lng 2009-03-05 23:51:59.276250000 +0900
@@ -45,7 +45,7 @@
Log &SSH packet data=SSH パケットデータのログをとる(&S)
Log &file name:=ログファイル名(&F)
Bro&wse...=参照(&W)...
-(Log file name can contain &&Y, &&M, &&D for date, &&T for time,%0Aand &&H for host name)=(ログファイル名は、日付を表す &&Y、&&M、&&D、時刻を表す &&T、%0Aホスト名を表す &&H を含むことができます)
+(Log file name can contain &&Y, &&M, &&D for date, &&T for time,%0Aand &&H for host name)=(ログファイル名は、日付を表す &&Y、&&M、&&D、時刻を表す &&T、%0Aホスト名を表す &&H、%0Aポート番号を表す &&P を含むことができます)
(Log file name can contain &&Y, &&M, &&D for date, &&T for%0Atime, and &&H for host name)=(ログファイル名は、日付を表す &&Y、&&M、&&D、時刻を表す &&T、%0Aホスト名を表す &&H を含むことができます)
What to do if th&e log file already exists:=ログファイルがすでに存在する場合何をすべきか(&E):
Always overwrite it=常にそれを上書き
diff -ur windows/windlg.c windows/windlg.c
--- windows/windlg.c 2009-03-05 23:45:40.698125000 +0900
+++ windows/windlg.c 2009-03-05 23:46:15.120000000 +0900
@@ -46,8 +46,6 @@
extern Config cfg; /* defined in window.c */
-#define PRINTER_DISABLED_STRING "None (printing disabled)"
-
void force_normal(HWND hwnd)
{
static int recurse = 0;
diff -ur windows/window.c windows/window.c
--- windows/window.c 2009-03-05 23:45:40.713750000 +0900
+++ windows/window.c 2009-03-05 23:46:15.198125000 +0900
@@ -1409,12 +1409,12 @@
{
int i;
static const int ww[] = {
- 256, 257, 258, 259, 260, 261,
+ 256, 257, 258, 259, 260, 261, 262,
0, 8, 1, 9, 2, 10, 3, 11,
4, 12, 5, 13, 6, 14, 7, 15
};
- for (i = 0; i < 22; i++) {
+ for (i = 0; i < 23; i++) {
int w = ww[i];
defpal[w].rgbtRed = cfg.colours[i][0];
defpal[w].rgbtGreen = cfg.colours[i][1];
@@ -1454,6 +1454,7 @@
{ COLOR_WINDOW, 258, 259 }, /* Default Background */
{ COLOR_HIGHLIGHTTEXT, 260, 260 }, /* Cursor Text */
{ COLOR_HIGHLIGHT, 261, 261 }, /* Cursor Colour */
+ { COLOR_HIGHLIGHT, 262, 262 }, /* IME Cursor Colour */
};
for (i = 0; i < (sizeof(or)/sizeof(or[0])); i++) {
@@ -2387,12 +2388,48 @@
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
+ HIMC hImc = NULL ;
+ BOOL bIMEOpen = FALSE ;
static int ignore_clip = FALSE;
static int need_backend_resize = FALSE;
static int fullscr_on_max = FALSE;
static UINT last_mousemove = 0;
+ static BYTE defCursorPal[3] ;
switch (message) {
+ case WM_IME_NOTIFY : /* IME_Notify_Message */
+ if(wParam == IMN_SETOPENSTATUS){
+ hImc = ImmGetContext(hwnd);
+ if(hImc){
+ BOOL bIMEOpen = ImmGetOpenStatus(hImc);
+ if(bIMEOpen){
+ /* default cursor color setting */
+ defCursorPal[0] = defpal[261].rgbtRed ;
+ defCursorPal[1] = defpal[261].rgbtGreen ;
+ defCursorPal[2] = defpal[261].rgbtBlue ;
+
+ /* IME_ON cursor color setting */
+ defpal[261].rgbtRed = defpal[262].rgbtRed;
+ defpal[261].rgbtGreen = defpal[262].rgbtGreen;
+ defpal[261].rgbtBlue = defpal[262].rgbtBlue;
+
+ init_palette();
+ InvalidateRect(hwnd,NULL,FALSE);
+ UpdateWindow(hwnd);
+ }
+ else {
+ /* IME_OFF cursor color setting */
+ defpal[261].rgbtRed = defCursorPal[0] ;
+ defpal[261].rgbtGreen = defCursorPal[1] ;
+ defpal[261].rgbtBlue = defCursorPal[2] ;
+
+ init_palette();
+ InvalidateRect(hwnd,NULL,FALSE);
+ UpdateWindow(hwnd);
+ }
+ }
+ }
+ break ;
case WM_TIMER:
if ((UINT_PTR)wParam == TIMING_TIMER_ID) {
long next;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.