Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
Uploading the core project, with out the Scintilla and Boost Library.
I'll uploads those libraries, once I can figure out what's the minimum required files for use with this project.
  • Loading branch information
David-Maisonave committed Aug 21, 2021
1 parent c5f7462 commit d734024
Show file tree
Hide file tree
Showing 41 changed files with 7,272 additions and 0 deletions.
50 changes: 50 additions & 0 deletions RegexAssistant.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1585
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegexAssistant", "RegexAssistant\RegexAssistant.vcxproj", "{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}"
ProjectSection(ProjectDependencies) = postProject
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76} = {C4E80941-26F9-4AE0-867B-58AB5B5A9E76}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SciLexer", "scintilla\vcbuild\SciLexer.vcxproj", "{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|ARM64.ActiveCfg = Debug|Win32
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x64.ActiveCfg = Debug|x64
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x64.Build.0 = Debug|x64
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x86.ActiveCfg = Debug|Win32
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x86.Build.0 = Debug|Win32
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|ARM64.ActiveCfg = Release|Win32
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x64.ActiveCfg = Release|x64
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x64.Build.0 = Release|x64
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x86.ActiveCfg = Release|Win32
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x86.Build.0 = Release|Win32
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|ARM64.ActiveCfg = Debug|Win32
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x64.ActiveCfg = Debug|x64
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x64.Build.0 = Debug|x64
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x86.ActiveCfg = Debug|Win32
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x86.Build.0 = Debug|Win32
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|ARM64.ActiveCfg = Release|Win32
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x64.ActiveCfg = Release|x64
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x64.Build.0 = Release|x64
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x86.ActiveCfg = Release|Win32
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D2337E3C-ACD5-476E-8CA0-A5B2C72A909E}
EndGlobalSection
EndGlobal
17 changes: 17 additions & 0 deletions RegexAssistant/CAboutDlg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "pch.h"
#include "framework.h"
#include "RegexAssistant.h"
#include "CAboutDlg.h"

CAboutDlg::CAboutDlg() : CDialogEx( IDD_ABOUTBOX )
{
}

void CAboutDlg::DoDataExchange( CDataExchange* pDX )
{
CDialogEx::DoDataExchange( pDX );
}

BEGIN_MESSAGE_MAP( CAboutDlg, CDialogEx )
END_MESSAGE_MAP()

22 changes: 22 additions & 0 deletions RegexAssistant/CAboutDlg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "RegexAssistantDlg.h"

// CAboutDlg dialog used for App About
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();

// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif

protected:
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support

// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
147 changes: 147 additions & 0 deletions RegexAssistant/ClipboardXX.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#pragma once

#include <string>
#include <exception>
#include <string.h>

#if defined(_WIN32) || defined(WIN32)
#define WINDOWS 1
#else
#define LINUX 1
#endif


class CExceptionXX : public std::exception{
private:
const char* m_pReason;

public:
CExceptionXX(const char* pReason) : m_pReason(pReason){};

const char* what(){
return m_pReason;
}
};

class IClipboardOS{
protected:
// not accessable from other files :)
IClipboardOS(){};

public:
virtual void CopyText(const char* , size_t ){};
virtual void PasteText(std::string &){};
};
class CClipboardXX;



#ifdef WINDOWS


#include <Windows.h>

class CClipboardWindows: public IClipboardOS{
private:
CClipboardWindows(){
if(!OpenClipboard(0)){
throw CExceptionXX("Cannot open clipboard!");
}
}

public:
~CClipboardWindows(){
CloseClipboard();
}

void CopyText(const char* pText, size_t Length){
if(!EmptyClipboard())
throw CExceptionXX("Cannot empty clipboard!");

HGLOBAL pGlobal = GlobalAlloc(GMEM_FIXED, (Length + 1)* sizeof(char));

#ifdef _MSC_VER
strcpy_s((char *)pGlobal, (Length + 1)*sizeof(char), pText);
#else
strncpy((char *)pGlobal, pText, Length);
#endif

SetClipboardData(CF_TEXT, pGlobal);

GlobalFree(pGlobal);
}

void PasteText(std::string &sString){
char* pResult = (char*) GetClipboardData(CF_TEXT);

if(pResult != NULL){
sString = pResult;
GlobalFree(pResult);
}
}

friend class CClipboardXX;
};

#elif LINUX

#include <QGuiApplication>
#include <QClipboard>

// for some reason have to declare Qt App in global (idk why)
static int gs_FakeArgc = 1;
static QGuiApplication gs_GuiApp(gs_FakeArgc, nullptr);

class CClipboardLinux: public IClipboardOS{
private:
QClipboard* m_pClipboard;

CClipboardLinux(){
m_pClipboard = gs_GuiApp.clipboard();
}

public:
~CClipboardLinux(){
gs_GuiApp.quit();
}

void CopyText(const char* pText, size_t Length){
m_pClipboard->setText(pText, QClipboard::Mode::Clipboard);
}

void PasteText(std::string &sString){
sString = m_pClipboard->text().toStdString();
}

friend class CClipboardXX;
};

#endif

class CClipboardXX{
private:
IClipboardOS* m_pClipboard = new

#ifdef WINDOWS
CClipboardWindows();
#elif LINUX
CClipboardLinux();
#endif


public:
~CClipboardXX(){
delete m_pClipboard;
}
void operator<<(const char* pText){
m_pClipboard->CopyText(pText, strlen(pText));
}

void operator<<(std::string &sText){
m_pClipboard->CopyText(sText.c_str(), sText.size());
}

void operator>>(std::string &sResult){
m_pClipboard->PasteText(sResult);
}
};
28 changes: 28 additions & 0 deletions RegexAssistant/CommonFunction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "pch.h"
#include "CommonFunctions.h"
#include <string>
#include <codecvt>
#include <locale>
#include <boost/algorithm/string/replace.hpp>

namespace FXString
{
std::wstring ToWString(std::string src) {
return std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(src);
}

std::string ToString(std::wstring src ) {
return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(src);
}

void ReplaceAll(std::string &str, const std::string &searchStr, const std::string &ReplacementStr) {
boost::replace_all(str, searchStr, ReplacementStr);
}

std::string CopyAndReplaceAll(std::string str, const std::string &searchStr, const std::string &ReplacementStr)
{
ReplaceAll(str, searchStr, ReplacementStr);
return str;
}
}

50 changes: 50 additions & 0 deletions RegexAssistant/CommonFunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include <string>
#include <cstring>
#include <mutex>

enum { QISUCCESS = 0};
#define LOGEXT "log"

class auto_lock
{
std::mutex mtx;
public:
auto_lock() { mtx.lock(); }
~auto_lock() { mtx.unlock(); }
};

namespace FXString
{
std::wstring ToWString(std::string src);
inline std::wstring ToWString( const std::wstring &src ) { return src; }
inline std::wstring ToWString( const CString &src) { return src.operator LPCWSTR(); }

inline CString ToTString(const char * src) { return ToWString(src).c_str(); }
inline CString ToTString(const wchar_t * src) { return src; }

std::string ToString( std::wstring src);
inline std::string ToString( const std::string &src ) { return src; }
//inline std::string ToString( const CString &src ) { return ToString( std::wstring(src.operator LPCWSTR()) ); }

std::string CopyAndReplaceAll(std::string src, const std::string &searchStr, const std::string &ReplacementStr);
void ReplaceAll(std::string &src, const std::string &searchStr, const std::string &ReplacementStr);

template <class strType1, class strType2> bool MatchesNoCase(strType1 str1, strType2 str2)
{
std::wstring wstr1 = ToWString(str1);
std::wstring wstr2 = ToWString(str2);
return (0 == _wcsicmp(wstr1.c_str(), wstr2.c_str()));
}

inline size_t StrLen(const char * str) { return strlen(str); }
inline size_t StrLen(const wchar_t * str) { return wcslen(str); }
inline size_t StrLen(const CString &str) { return static_cast <size_t>(str.GetLength()); }

inline DWORD StrDwLen( const char * str ) { return static_cast<DWORD>(strlen( str )); }
inline DWORD StrDwLen( const wchar_t * str ) { return static_cast<DWORD>(wcslen( str )); }
inline DWORD StrDwLen( const CString &str ) { return static_cast<DWORD>(str.GetLength()); }
}


Loading

0 comments on commit d734024

Please sign in to comment.