<commit_before>/*
*	Copyright 2009 <NAME>
*
*	Licensed under the Apache License, Version 2.0 (the "License");
*	you may not use this file except in compliance with the License.
*	You may obtain a copy of the License at
*
*		http://www.apache.org/licenses/LICENSE-2.0
*
*	Unless required by applicable law or agreed to in writing, software
*	distributed under the License is distributed on an "AS IS" BASIS,
*	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*	See the License for the specific language governing permissions and
*	limitations under the License. 
*/

#pragma once

class CEditCmdFilter;

class MetalBar
{
public:
	MetalBar(HWND vertBar, HWND editor, HWND horizBar, WNDPROC oldProc, IVsTextView* view);
	~MetalBar();

	IVsTextView*					GetView() const { return m_view; }
	HWND							GetHwnd() const { return m_hwnd; }
	LRESULT							WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);

	static void						ResetSettings();
	static void						ReadSettings();
	static void						SaveSettings();

	static void						RemoveAllBars();

	// User-controllable parameters.
	static unsigned int				s_barWidth;
	static unsigned int				s_whitespaceColor;
	static unsigned int				s_upperCaseColor;
	static unsigned int				s_characterColor;
	static unsigned int				s_commentColor;
	static unsigned int				s_cursorColor;
	static unsigned int				s_matchColor;
	static unsigned int				s_modifiedLineColor;
	static unsigned int				s_unsavedLineColor;
	static unsigned int				s_breakpointColor;
	static unsigned int				s_bookmarkColor;

private:
	enum LineMarker
	{
		LineMarker_Hidden			= 0x01,
		LineMarker_ChangedUnsaved	= 0x02,
		LineMarker_ChangedSaved		= 0x04,
		LineMarker_Breakpoint		= 0x08,
		LineMarker_Bookmark			= 0x10,
		LineMarker_Match			= 0x20
	};

	struct Highlight
	{
		unsigned int				start;
		unsigned int				end;
		Highlight*					next;
	};

	struct LineInfo
	{
		unsigned int				flags;
		Highlight*					highlights;
	};

	typedef std::vector<LineInfo>	LineList;
	typedef std::vector<Highlight>	HighlightList;

	struct MarkerOperator
	{
		virtual void NotifyCount(int /*numMarkers*/) const {}
		virtual void Process(IVsTextLineMarker* marker, int idx) const = 0;
	};

	static std::set<MetalBar*>		s_bars;
	static bool						ReadRegInt(unsigned int* to, HKEY key, const char* name);
	static void						WriteRegInt(HKEY key, const char* name, unsigned int val);

	// Handles and other window-related stuff.
	WNDPROC							m_oldProc;
	HWND							m_hwnd;
	HWND							m_editorWnd;
	HWND							m_horizBar;
	HWND							m_tooltipWnd;

	// Text.
	IVsTextView*					m_view;
	long							m_numLines;
	CEditCmdFilter*					m_editCmdFilter;

	// Painting.
	bool							m_codeImgDirty;
	HBITMAP							m_codeImg;
	HDC								m_imgDC;
	HBITMAP							m_backBufferImg;
	HDC								m_backBufferDC;
	unsigned int*					m_backBufferBits;
	unsigned int					m_backBufferWidth;
	unsigned int					m_backBufferHeight;

	// Scrollbar stuff.
	int								m_pageSize;
	int								m_scrollPos;
	int								m_scrollMin;
	int								m_scrollMax;
	bool							m_dragging;
	bool							m_tooltipShown;

	void							InitTooltip();
	bool							GetBufferAndText(IVsTextLines** buffer, BSTR* text, long* numLines);
	bool							GetFileName(CComBSTR& name, IVsTextLines* buffer);
	void							ProcessLineMarkers(IVsTextLines* buffer, int type, const MarkerOperator& op);

	void							OnDrag(bool initial);
	void							OnTrackTooltip();
	void							OnPaint(HDC ctrlDC);
	void							OnGetTooltipInfo(NMTTDISPINFOA* tooltipInfo);
	void							AdjustSize(unsigned int requiredWidth);
	void							RemoveWndProcHook();

	void							HighlightMatchingWords();
	void							RemoveWordHighlight(IVsTextLines* buffer);
<commit_msg>Removed old method from MetalBar.h.<commit_after>/*
*	Copyright 2009 <NAME>
*
*	Licensed under the Apache License, Version 2.0 (the "License");
*	you may not use this file except in compliance with the License.
*	You may obtain a copy of the License at
*
*		http://www.apache.org/licenses/LICENSE-2.0
*
*	Unless required by applicable law or agreed to in writing, software
*	distributed under the License is distributed on an "AS IS" BASIS,
*	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*	See the License for the specific language governing permissions and
*	limitations under the License. 
*/

#pragma once

class CEditCmdFilter;

class MetalBar
{
public:
	MetalBar(HWND vertBar, HWND editor, HWND horizBar, WNDPROC oldProc, IVsTextView* view);
	~MetalBar();

	IVsTextView*					GetView() const { return m_view; }
	HWND							GetHwnd() const { return m_hwnd; }
	LRESULT							WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);

	static void						ResetSettings();
	static void						ReadSettings();
	static void						SaveSettings();

	static void						RemoveAllBars();

	// User-controllable parameters.
	static unsigned int				s_barWidth;
	static unsigned int				s_whitespaceColor;
	static unsigned int				s_upperCaseColor;
	static unsigned int				s_characterColor;
	static unsigned int				s_commentColor;
	static unsigned int				s_cursorColor;
	static unsigned int				s_matchColor;
	static unsigned int				s_modifiedLineColor;
	static unsigned int				s_unsavedLineColor;
	static unsigned int				s_breakpointColor;
	static unsigned int				s_bookmarkColor;

private:
	enum LineMarker
	{
		LineMarker_Hidden			= 0x01,
		LineMarker_ChangedUnsaved	= 0x02,
		LineMarker_ChangedSaved		= 0x04,
		LineMarker_Breakpoint		= 0x08,
		LineMarker_Bookmark			= 0x10,
		LineMarker_Match			= 0x20
	};

	struct Highlight
	{
		unsigned int				start;
		unsigned int				end;
		Highlight*					next;
	};

	struct LineInfo
	{
		unsigned int				flags;
		Highlight*					highlights;
	};

	typedef std::vector<LineInfo>	LineList;
	typedef std::vector<Highlight>	HighlightList;

	struct MarkerOperator
	{
		virtual void NotifyCount(int /*numMarkers*/) const {}
		virtual void Process(IVsTextLineMarker* marker, int idx) const = 0;
	};

	static std::set<MetalBar*>		s_bars;
	static bool						ReadRegInt(unsigned int* to, HKEY key, const char* name);
	static void						WriteRegInt(HKEY key, const char* name, unsigned int val);

	// Handles and other window-related stuff.
	WNDPROC							m_oldProc;
	HWND							m_hwnd;
	HWND							m_editorWnd;
	HWND							m_horizBar;
	HWND							m_tooltipWnd;

	// Text.
	IVsTextView*					m_view;
	long							m_numLines;
	CEditCmdFilter*					m_editCmdFilter;

	// Painting.
	bool							m_codeImgDirty;
	HBITMAP							m_codeImg;
	HDC								m_imgDC;
	HBITMAP							m_backBufferImg;
	HDC								m_backBufferDC;
	unsigned int*					m_backBufferBits;
	unsigned int					m_backBufferWidth;
	unsigned int					m_backBufferHeight;

	// Scrollbar stuff.
	int								m_pageSize;
	int								m_scrollPos;
	int								m_scrollMin;
	int								m_scrollMax;
	bool							m_dragging;
	bool							m_tooltipShown;

	void							InitTooltip();
	bool							GetBufferAndText(IVsTextLines** buffer, BSTR* text, long* numLines);
	bool							GetFileName(CComBSTR& name, IVsTextLines* buffer);
	void							ProcessLineMarkers(IVsTextLines* buffer, int type, const MarkerOperator& op);

	void							OnDrag(bool initial);
	void							OnTrackTooltip();
	void							OnPaint(HDC ctrlDC);
	void							AdjustSize(unsigned int requiredWidth);
	void							RemoveWndProcHook();

	void							HighlightMatchingWords();
	void							RemoveWordHighlight(IVsTextLines* buffer);

{'fraction_non_alphanumeric': 0.07253044654939107, 'fraction_numerical': 0.007307171853856563, 'mean_word_length': 3.329818394844757, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2421222', 'n_tokens_mistral': 3104, 'n_tokens_neox': 2516, 'n_words': 707}