浏览代码

Fixed build error from last pr - brought back drawing of colors for the formats 36F301 and 255, 0, 0

Scott Brogden 5 月之前
父节点
当前提交
41fbd8e2e4
共有 2 个文件被更改,包括 35 次插入1 次删除
  1. 34 0
      src/QListCtrl.cpp
  2. 1 1
      src/SendKeys.h

+ 34 - 0
src/QListCtrl.cpp

@@ -775,6 +775,18 @@ void CQListCtrl::DrawCopiedColorCode(CString& csText, CRect& rcText, CDC* pDC)
 		}
 	}
 
+	//draw hex color copied like #FF0000, FF0000, FF0000 other text with a space before other text
+	if (parseText.GetLength() == 6 ||
+		parseText.Find(' ') == 6)
+	{
+		int r, g, b;
+		int scanRet = swscanf(parseText, _T("%02x%02x%02x"), &r, &g, &b);
+		if (scanRet == 3)
+		{
+			DrawColorBox(RGB(r, g, b)); // Draw using RGB part
+			return; // Valid RGB/RGBA format found and drawn
+		}
+	}
 
 	// 5. --- HSL Color Parsing ---
 	// Formats: hsl(H, S%, L%), hsla(H, S%, L%, A), hsl(H S% L%), hsl(H S% L% / A)
@@ -897,6 +909,28 @@ void CQListCtrl::DrawCopiedColorCode(CString& csText, CRect& rcText, CDC* pDC)
 		}
 	}
 
+	// draw rgb color copied like 255,0,0
+	int firstCommaPos = parseText.Find(',');
+	if (firstCommaPos >= 0)
+	{
+		int secondCommaPos = parseText.Find(',', firstCommaPos + 1);
+		if (secondCommaPos)
+		{
+			int noThirdCommaPos = parseText.Find(',', secondCommaPos + 1);
+
+			if (noThirdCommaPos < 0)
+			{
+				int r, g, b;
+				int scanRet = swscanf(parseText, _T("%d,%d,%d"), &r, &g, &b);
+				if (scanRet == 3)
+				{
+					DrawColorBox(RGB(r, g, b)); // Draw using RGB part
+					return; // Valid RGB/RGBA format found and drawn
+				}
+			}
+		}
+	}
+
 	// If we reach here, no valid format was detected or parsed correctly.
 	// The original csText remains unchanged, and no color box is drawn.
 }

+ 1 - 1
src/SendKeys.h

@@ -30,7 +30,7 @@ private:
 
   enum
   {
-    MaxSendKeysRecs  = 79,
+    MaxSendKeysRecs  = 98,
     MaxExtendedVKeys = 12
   };