Quantcast
Channel: All Open Tickets - Tera Term on OSDN
Viewing all articles
Browse latest Browse all 2128

Feature to add hotkey for font resizing - Tera Term Ticket #37155 on OSDN

$
0
0

Feature to add hotkey for font resizing

Eröffnet am: 2017-05-04 18:06

Letztes Update: 2017-05-04 18:06

Auswertung:pryanksterVerantwortlicher:(Keine)
Priorität:5 - MittelMeilenstein:(Keine)
Typ:FunktionsanfragenSchweregrad:5 - Mittel
Komponente:Tera TermStatus:Offen
LösungKeine

Einzelheiten

I switch back and forth between a high-res, high-dpi monitor and my laptop, having the ability to hotkey the font size up and down would come in very handy, so I added it to teraterm.

Here's the diff. The change does "eat up" two user keys, but I didn't know about the ramifications of changing the NumOfUserKey macro.

ありがとうございます!

Index: teraterm/common/tttypes.h
===================================================================
--- teraterm/common/tttypes.h	(revision 6700)
+++ teraterm/common/tttypes.h	(working copy)
@@ -853,7 +853,9 @@
 #define IdCmdPrevSWin     87
 #define IdCmdLocalEcho    88
 #define IdCmdScrollLock   89
-#define IdUser1           90
+#define IdCmdFontSizeUp   90
+#define IdCmdFontSizeDown 91
+#define IdUser1           92
 #define NumOfUDK          IdUDK20-IdUDK6+1
 #define NumOfUserKey      99
 #define IdKeyMax          IdUser1+NumOfUserKey-1
Index: teraterm/teraterm/vtdisp.c
===================================================================
--- teraterm/teraterm/vtdisp.c	(revision 6700)
+++ teraterm/teraterm/vtdisp.c	(working copy)
@@ -3359,6 +3359,37 @@
   ChangeCaret();
 }

+static int fontSizes[] = { 4, 6, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 };
+#define NUM_FONT_SIZES (sizeof(fontSizes) / sizeof(fontSizes[0]))
+
+void DispBumpFontSize(int dir)
+{
+	// get logpx scale
+	HDC TmpDC = GetDC(NULL);
+	int logpxy = GetDeviceCaps(TmpDC, LOGPIXELSY);
+	ReleaseDC(NULL, TmpDC);
+
+	// clip direction to -1 or 1.
+	dir = dir > 0 ? 1 : -1;
+
+	for (int i = 0; i < NUM_FONT_SIZES; ++i) {
+		int logpx = -MulDiv(fontSizes[i], logpxy, 72);
+		// logpx gets more negative as font sizes grow, so find largest number not less than current size.
+		if (logpx <= ts.VTFontSize.y) {
+			// now go 1 up or 1 down
+			int newSize = i + dir;
+			// still in range?
+			if (newSize < 0 || newSize == NUM_FONT_SIZES)
+				break;
+			ts.VTFontSize.y = -MulDiv(fontSizes[newSize], logpxy, 72);
+			ChangeFont();
+			DispChangeWinSize(WinWidth, WinHeight);
+			ChangeCaret();
+			return;
+		}
+	}
+}
+
 void DispRestoreWinSize()
 //  Restore window size by double clik on caption bar
 {
Index: teraterm/teraterm/vtdisp.h
===================================================================
--- teraterm/teraterm/vtdisp.h	(revision 6700)
+++ teraterm/teraterm/vtdisp.h	(working copy)
@@ -71,6 +71,7 @@
 void DispHScroll(int Func, int Pos);
 void DispVScroll(int Func, int Pos);
 void DispSetupFontDlg();
+void DispBumpFontSize(int dir);
 void DispRestoreWinSize();
 void DispSetWinPos();
 void DispSetActive(BOOL ActiveFlag);
Index: teraterm/teraterm/vtwin.cpp
===================================================================
--- teraterm/teraterm/vtwin.cpp	(revision 6700)
+++ teraterm/teraterm/vtwin.cpp	(working copy)
@@ -3492,6 +3492,12 @@
 		case IdCmdScrollLock:
 			ScrollLock = ! ScrollLock;
 			break;
+		case IdCmdFontSizeUp:
+			DispBumpFontSize(1);
+			break;
+		case IdCmdFontSizeDown:
+			DispBumpFontSize(-1);
+			break;
 	}
 	return 0;
 }
Index: teraterm/ttpcmn/ttcmn.c
===================================================================
--- teraterm/ttpcmn/ttcmn.c	(revision 6700)
+++ teraterm/ttpcmn/ttcmn.c	(working copy)
@@ -796,6 +796,8 @@
 		case IdCmdPrevSWin:
 		case IdCmdLocalEcho:
 		case IdCmdScrollLock:
+		case IdCmdFontSizeUp:
+		case IdCmdFontSizeDown:
 			PostMessage(HWin,WM_USER_ACCELCOMMAND,KeyCode,0);
 			break;
 		default:
Index: teraterm/ttpset/ttset.c
===================================================================
--- teraterm/ttpset/ttset.c	(revision 6700)
+++ teraterm/ttpset/ttset.c	(working copy)
@@ -3422,6 +3422,10 @@

 	GetInt(KeyMap, IdCmdScrollLock, ShortCut, "ScrollLock", FName);

+	GetInt(KeyMap, IdCmdFontSizeUp, ShortCut, "FontSizeUp", FName);
+
+	GetInt(KeyMap, IdCmdFontSizeDown, ShortCut, "FontSizeDown", FName);
+
 	/* user keys */

 	Ptr = 0;

Letzte Aktualisierung für dieses Ticket

2017-05-04 18:06 Aktualisiert von: pryankster

  • New Ticket "Feature to add hotkey for font resizing" created

Viewing all articles
Browse latest Browse all 2128

Trending Articles


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


UPDATE SC IDOL: TWO BECOME ONE


Pokemon para colorear


Sapos para colorear


Love Quotes Tagalog


Two timer Sad tagalog Love quotes


Top 7 Lies of Boys


“Mali man na ikaw ay ibigin ko, akoy iibig padin sayo”


RE: Mutton Pies (frankie241)


EASY COME, EASY GO


FORECLOSURE OF REAL ESTATE MORTGAGE


HOY PANGIT, MAGBAYAD KA!


Girasoles para colorear


Presence Quotes – Positive Quotes


Long Distance Relationship Tagalog Love Quotes


Tropa Quotes


“BAHAY KUBO HUGOT”


Re:Mutton Pies (lleechef)


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.