Browse Source

Limit the number of lines for the auto listbox tooltip to 30 and strip out empty lines

scott brogden 6 years ago
parent
commit
300235a7ef
3 changed files with 28 additions and 1 deletions
  1. 10 0
      Options.cpp
  2. 3 0
      Options.h
  3. 15 1
      QPasteWnd.cpp

+ 10 - 0
Options.cpp

@@ -2763,4 +2763,14 @@ BOOL CGetSetOptions::GetUpdateClipOrderOnCtrlC()
 void CGetSetOptions::SetUpdateClipOrderOnCtrlC(BOOL val)
 {
 	SetProfileLong("UpdateClipOrderOnCtrlC", val);
+}
+
+BOOL CGetSetOptions::GetMaxToolTipLines()
+{
+	return GetProfileLong("MaxToolTipLines", 30);
+}
+
+void CGetSetOptions::SetMaxToolTipLines(int val)
+{
+	SetProfileLong("MaxToolTipLines", val);
 }

+ 3 - 0
Options.h

@@ -613,6 +613,9 @@ public:
 
 	static BOOL GetUpdateClipOrderOnCtrlC();
 	static void SetUpdateClipOrderOnCtrlC(BOOL val);
+
+	static BOOL GetMaxToolTipLines();
+	static void SetMaxToolTipLines(int val);
 };
 
 // global for easy access and for initialization of fast access variables

+ 15 - 1
QPasteWnd.cpp

@@ -26,6 +26,7 @@
 #include "CF_UnicodeTextAggregator.h"
 #include "CF_TextAggregator.h"
 #include "htmlformataggregator.h"
+#include "shared/Tokenizer.h""
 
 #ifdef _DEBUG
     #define new DEBUG_NEW
@@ -5365,7 +5366,20 @@ void CQPasteWnd::OnGetToolTipText(NMHDR *pNMHDR, LRESULT *pResult)
         CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT lID, mText, lDate, lShortCut, clipOrder, clipGroupOrder, stickyClipOrder, stickyClipGroupOrder, lDontAutoDelete, QuickPasteText, lastPasteDate, globalShortCut, lParentID FROM Main WHERE lID = %d"), id);
         if(q.eof() == false)
         {
-            cs = q.getStringField(1);
+            CString clipText = q.getStringField(1);
+
+			int lines = 0;
+			int maxLines = CGetSetOptions::GetMaxToolTipLines();
+			CTokenizer tokenizer(clipText, "\r\n");
+			CString token;
+			while (tokenizer.Next(token))
+			{
+				cs += token + "\r\n";
+				if (lines > 30)
+					break;
+				lines++;
+			}
+
             cs += "\n\n";
             #ifdef _DEBUG
                 cs += StrF(_T("(Index = %d) (DB ID = %d) (Seq = %f) (Group Seq = %f) (Sticky Seq = %f) (Sticky Group Seq = %f)\n"),