<commit_before>#define _CRT_SECURE_NO_WARNINGS 1
#include "BoardView.h"

#include <algorithm>
#include <math.h>
#include <memory>
#include <stdio.h>

#include "BRDBoard.h"
#include "BRDFile.h"
#include "imgui.h"

#include "NetList.h"
#include "PartList.h"

#include "platform.h"

using namespace std;
using namespace std::placeholders;

#if _MSC_VER
#define stricmp _stricmp
#endif

BoardView::~BoardView() {
	delete m_file;
	delete m_board;
	free(m_lastFileOpenName);
}

void BoardView::ShowError(char *msg) {
	m_lastErrorMsg = msg;
	m_showError = true;
}

#pragma region Update Logic
void BoardView::Update() {
	float menu_height = 0;
	const ImGuiIO &io = ImGui::GetIO();

	if (ImGui::BeginMainMenuBar()) {
		menu_height = ImGui::GetWindowHeight();
		if (ImGui::BeginMenu("File")) {
			if (ImGui::MenuItem("Open", "Ctrl+O")) {
				m_open_file = true;
			}
			if (ImGui::MenuItem("Quit", "Ctrl+Q")) {
				m_wantsQuit = true;
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("View")) {
			if (ImGui::MenuItem("Flip board", "<Space>")) {
				FlipBoard();
			}
			if (ImGui::MenuItem("Rotate CW", ".")) {
				Rotate(1);
			}
			if (ImGui::MenuItem("Rotate CCW", ",")) {
				Rotate(-1);
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("Search")) {
			if (ImGui::MenuItem("Net", "N")) {
				m_showSearchNetfilter = true;
			}
			if (ImGui::MenuItem("Component", "C")) {
				m_showSearchComponent = true;
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("Windows")) {
			if (ImGui::MenuItem("Net List", "L")) {
				m_showWindowsNetList = m_showWindowsNetList ? false : true;
			}
			if (ImGui::MenuItem("Part List", "K")) {
				m_showWindowsPartList = m_showWindowsPartList ? false : true;
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("Help")) {
			if (ImGui::MenuItem("Controls")) {
				m_showHelpControls = true;
			}
			if (ImGui::MenuItem("About")) {
				m_showHelpAbout = true;
			}
			ImGui::EndMenu();
		}
		ImGui::EndMainMenuBar();
	}

	if (m_open_file) {
		m_open_file = false;
		char *filename = show_file_picker();
		ImGuiIO &io = ImGui::GetIO();
		io.MouseDown[0] = false;
		io.MouseClicked[0] = false;
		io.MouseClickedPos[0] = ImVec2(0, 0);
		if (filename) {<commit_msg>Revert "Absorb stray clicks and normalise mouse status after file_picker()"<commit_after>#define _CRT_SECURE_NO_WARNINGS 1
#include "BoardView.h"

#include <algorithm>
#include <math.h>
#include <memory>
#include <stdio.h>

#include "BRDBoard.h"
#include "BRDFile.h"
#include "imgui.h"

#include "NetList.h"
#include "PartList.h"

#include "platform.h"

using namespace std;
using namespace std::placeholders;

#if _MSC_VER
#define stricmp _stricmp
#endif

BoardView::~BoardView() {
	delete m_file;
	delete m_board;
	free(m_lastFileOpenName);
}

void BoardView::ShowError(char *msg) {
	m_lastErrorMsg = msg;
	m_showError = true;
}

#pragma region Update Logic
void BoardView::Update() {
	float menu_height = 0;
	const ImGuiIO &io = ImGui::GetIO();

	if (ImGui::BeginMainMenuBar()) {
		menu_height = ImGui::GetWindowHeight();
		if (ImGui::BeginMenu("File")) {
			if (ImGui::MenuItem("Open", "Ctrl+O")) {
				m_open_file = true;
			}
			if (ImGui::MenuItem("Quit", "Ctrl+Q")) {
				m_wantsQuit = true;
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("View")) {
			if (ImGui::MenuItem("Flip board", "<Space>")) {
				FlipBoard();
			}
			if (ImGui::MenuItem("Rotate CW", ".")) {
				Rotate(1);
			}
			if (ImGui::MenuItem("Rotate CCW", ",")) {
				Rotate(-1);
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("Search")) {
			if (ImGui::MenuItem("Net", "N")) {
				m_showSearchNetfilter = true;
			}
			if (ImGui::MenuItem("Component", "C")) {
				m_showSearchComponent = true;
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("Windows")) {
			if (ImGui::MenuItem("Net List", "L")) {
				m_showWindowsNetList = m_showWindowsNetList ? false : true;
			}
			if (ImGui::MenuItem("Part List", "K")) {
				m_showWindowsPartList = m_showWindowsPartList ? false : true;
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("Help")) {
			if (ImGui::MenuItem("Controls")) {
				m_showHelpControls = true;
			}
			if (ImGui::MenuItem("About")) {
				m_showHelpAbout = true;
			}
			ImGui::EndMenu();
		}
		ImGui::EndMainMenuBar();
	}

	if (m_open_file) {
		m_open_file = false;
		char *filename = show_file_picker();
		if (filename) {
{'fraction_non_alphanumeric': 0.17793676436648972, 'fraction_numerical': 0.0032310177705977385, 'mean_word_length': 4.227985524728589, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5786108', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1652, 'n_words': 317}