[.Net] C# Syntax Highlighting ์๋ํฐ๋ฅผ ์ํ ScintillaNET ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ
์ํ ์ฝ๋๋ ๋ณธ๋ฌธ ํ๋จ์ ์ฒจ๋ถ๋์ด ์์ต๋๋ค.
๊ตฌ๋ฌธ ๊ฐ์กฐ(Syntax Highlighting)๋?
ScintillaNET
๋ฅผ ์๊ฐํ๊ธฐ์ ์์, Syntax Highlighting
์ ๋ํด ๋จผ์ ์ค๋ช
ํ๊ฒ ์ต๋๋ค. ํ๋ก๊ทธ๋๋ฐ์ ์ํ ์ปดํ์ผ๋ฌ ํ
์คํธ ํธ์ง๊ธฐ ๋๋ ์ผ๋ฐ ํ
์คํธ ์๋ํฐ(notepad++)๋ฅผ ๋ณด๋ฉด, ๊ตฌ๋ฌธ ๊ฐ์กฐ ๋ฐ ๊ฐ๋
์ฑ์ ์ํ ํ์ด๋ผ์ดํ
๊ธฐ๋ฅ์ด ํ์ฌ๋์ด ์์ต๋๋ค.
์ด ๊ตฌ๋ฌธ ๊ฐ์กฐ ๊ธฐ๋ฅ์ ๋ฐ๋ก ์๋ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ต๋๋ค.
๋จ์ด๋ง ๋ด์๋ ๋ญ๊น ์ถ๊ฒ ์ง๋ง, ๊ทธ๋ฆผ์ ๋ณด๋ฉด ๋๊ตฌ๋ ๋ค ์๋ ๊ฒ์ผ ๊ฒ๋๋ค. ํ๋ก๊ทธ๋๋ฐ ์ธ์ด์ ์๊ด์์ด ๊ฑฐ์ ๋ชจ๋ ์๋ํฐ๋ Syntax Highlighting
๊ธฐ๋ฅ์ ์ง์ํ๊ณ ์์ต๋๋ค.
ScintillaNET ์ด๋?
๋ธ๋ก๊ทธ์ฒ๋ผ ์น ํ์ด์ง์์ ์ฌ์ฉํ ์ ์๋ Syntax Highlighting
์ปดํฌ๋ํธ๋ ์ฌ๋ฌ ๊ฐ์ง๊ฐ ์๋๋ฐ์. ๊ทธ์ค์์๋ highlight.js
๊ฐ ์ ๋ช
ํ์ฃ .
์ธํฐ๋ท์ ์ค์น ๋ฐฉ๋ฒ์ด๋ ์ฌ์ฉ ๋ฐฉ๋ฒ์ด ๋ง์ด ๋์ ์์ด, ์ ์ฉ ๋ฐ ์ฌ์ฉ ๋ฐฉ๋ฒ์ด ์ฌ์ด ํธ์
๋๋ค. ๊ทธ๋ฐ๋ฐ, ์๋์ฐ ์์ฉ ํ๋ก๊ทธ๋จ์ ํด๋น ๊ธฐ๋ฅ์ ์ถ๊ฐํ๋ ๊ฒ์ ์ ๋ง ๊น๋ค๋ก์ด ์ผ์
๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก MFC
๋ C#
๋ชจ๋ ์ด๋ฐ ์๋ํฐ ์ปจํธ๋กค์ ์ ๊ณตํ์ง ์๊ธฐ ๋๋ฌธ์ด์ฃ (๋ฌผ๋ก ์ด๋ฐ ๊ธฐ๋ฅ์ด ํ์ํ ์ผ๋ ๊ฑฐ์ ์์ง๋ง์).
ํ์ง๋ง ์๋์ฐ ์์ฉ ํ๋ก๊ทธ๋จ์ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ๋ฐ๋ก ์์ต๋๋ค. ๋ฐ๋ก, Scintilla
์ธ๋ฐ์. Scintilla
๋ ๋ฌด๋ฃ ์์ค ์ฝ๋ ์๋ํฐ ์ปดํฌ๋ํธ๋ก, ๊ฐ์ธ์ด๋ ์์ฉ ๋ชฉ์ ์ผ๋ก ์ฌ์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ .Net
์์ ์ฌ์ฉํ ์ ์๊ฒ Wrapping ๋ ๊ฒ์ด ScintillaNET
์ด์ฃ .
Scintilla ํํ์ด์ง: https://www.scintilla.org/index.html
Scintilla and SciTE
Scintilla is a free source code editing component. It comes with complete source code and a license that permits use in any free project or commercial product. As well as features found in standard text editing components, Scintilla includes features espec
www.scintilla.org
ScintillaNET GitHub: https://github.com/jacobslusser/ScintillaNET
GitHub - jacobslusser/ScintillaNET: A Windows Forms control, wrapper, and bindings for the Scintilla text editor.
A Windows Forms control, wrapper, and bindings for the Scintilla text editor. - GitHub - jacobslusser/ScintillaNET: A Windows Forms control, wrapper, and bindings for the Scintilla text editor.
github.com
ScintillaNET ์ ์ฉ ๋ชจ์ต
๊ทธ๋ผ ScintillaNET
์ ์ ์ฉํ๋ฉด ์ด๋ค ๋ชจ์ต์ธ์ง ๋จผ์ ๋ณด๊ฒ ์ต๋๋ค. ์๋ ์ด๋ฏธ์ง์ ์ ๋๋ฉ์ด์
์ ํฐ์คํ ๋ฆฌ ์๋ํฐ์ ์์์ ๋ง์ถ ๋ชจ์ต์
๋๋ค.
C# Windows Forms ํ๋ก์ ํธ์์ ScintillaNET ์ค๋นํ๊ธฐ
Windows Forms ์ฑ
์ ํ ํ ExamScintillaNET
์ด๋ฆ์ ํ๋ก์ ํธ๋ฅผ ์์ฑํฉ๋๋ค.
ํ๋ก์ ํธ ์์ฑ ํ NuGet ํจํค์ง ๊ด๋ฆฌ ๋ฉ๋ด๋ฅผ ์ ํํฉ๋๋ค.
NuGet ํจํค์ง ํ๋ฉด์์ ScintillaNET
์ ๊ฒ์ํ๊ณ , ์ต์ ๋ฒ์ ์ ์ค์นํฉ๋๋ค.
Form ๋์์ธ ํ๋ฉด์์ ๋๊ตฌ ์์์ ๋ชฉ๋ก์ ๋ณด๋ฉด Scintilla ์ปดํฌ๋ํธ๊ฐ ์ถ๊ฐ๋์ด ์์ต๋๋ค.
๋ง์ฝ, ๋ชฉ๋ก์ Scintilla ์ปดํฌ๋ํธ๊ฐ ์๋ค๋ฉด ํญ๋ชฉ ์ ํ ๋ฉ๋ด์์ ์๋์ ๊ฐ์ด ์๋์ผ๋ก ์ถ๊ฐํ ์ ์์ต๋๋ค. Scintilla dll์ ํ๋ก์ ํธ ํด๋์ packages ํด๋ ์์ dll์ด ์์ต๋๋ค.
์ฌ๊ธฐ๊น์ง C# Windows Forms ์ฑ
์ ScintillaNET
์ ์ค๋นํ๋ ๊ณผ์ ์ด์์ต๋๋ค.
ScintillaNET CPP ์คํ์ผ๋ก ์์ ์ค์ ํ๊ธฐ
๊ทธ๋ผ, ์ด์ ๊ตฌ๋ฌธ์ ๋ฐ๋ฅธ ์์์ ์ ์ฉํด ๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ScintillaNET;
namespace ExamScintillaNET
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
scintilla1.Margins[0].Type = MarginType.Number;
scintilla1.Margins[0].Width = 35;
scintilla1.StyleResetDefault();
scintilla1.Styles[Style.Default].Font = "Consolas";
scintilla1.Styles[Style.Default].Size = 14;
scintilla1.StyleClearAll();
// CPP Lexer Style ์ค์
scintilla1.Styles[Style.Cpp.Default].ForeColor = Color.Silver;
scintilla1.Styles[Style.Cpp.Comment].ForeColor = Color.FromArgb(0, 128, 0);
scintilla1.Styles[Style.Cpp.CommentLine].ForeColor = Color.FromArgb(0, 128, 0);
scintilla1.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128);
scintilla1.Styles[Style.Cpp.Number].ForeColor = Color.Olive;
scintilla1.Styles[Style.Cpp.Word].ForeColor = Color.Blue;
scintilla1.Styles[Style.Cpp.Word2].ForeColor = Color.Blue;
scintilla1.Styles[Style.Cpp.String].ForeColor = Color.FromArgb(163, 21, 21);
scintilla1.Styles[Style.Cpp.Character].ForeColor = Color.FromArgb(163, 21, 21);
scintilla1.Styles[Style.Cpp.Verbatim].ForeColor = Color.FromArgb(163, 21, 21);
scintilla1.Styles[Style.Cpp.StringEol].BackColor = Color.Pink;
scintilla1.Styles[Style.Cpp.Operator].ForeColor = Color.Purple;
scintilla1.Styles[Style.Cpp.Preprocessor].ForeColor = Color.Maroon;
scintilla1.Lexer = Lexer.Cpp;
// keywords ์ค์
scintilla1.SetKeywords(0, "abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using virtual while");
scintilla1.SetKeywords(1, "bool byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void");
}
}
}
์ ์ฝ๋๋ ์๋์ ๊ฐ์ด ๋์ํฉ๋๋ค.
์ํ๋ ์คํ์ผ์ด ์๋ค๋ฉด ์ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํ์ฌ ์์์ ๋ณ๊ฒฝํ๋ฉด ๋๊ฒ ์ต๋๋ค. ๋๋ ์ธํฐ๋ท์ ๊ฒ์ํ๋ฉด ํน์ ์ธ์ด์ ๋ํ ํ ํ๋ฆฟ ์์์ ๊ตฌํํด ๋์ ๊ณณ๋ ์์ด, ํด๋น ์ํ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํ๋ฉด ๋์์ด ๋ฉ๋๋ค.
์์ธํ ๋ด์ฉ์ ์๋ ์ฒจ๋ถ๋ ์ํ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํ์ธ์ :)
'Programming > .Net' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋๊ธ
์ด ๊ธ ๊ณต์ ํ๊ธฐ
-
๊ตฌ๋
ํ๊ธฐ
๊ตฌ๋ ํ๊ธฐ
-
์นด์นด์คํก
์นด์นด์คํก
-
๋ผ์ธ
๋ผ์ธ
-
ํธ์ํฐ
ํธ์ํฐ
-
Facebook
Facebook
-
์นด์นด์ค์คํ ๋ฆฌ
์นด์นด์ค์คํ ๋ฆฌ
-
๋ฐด๋
๋ฐด๋
-
๋ค์ด๋ฒ ๋ธ๋ก๊ทธ
๋ค์ด๋ฒ ๋ธ๋ก๊ทธ
-
Pocket
Pocket
-
Evernote
Evernote
๋ค๋ฅธ ๊ธ
-
[.Net] C#์์ CefSharp์ผ๋ก ํฌ๋กฌ ๋ธ๋ผ์ฐ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ (์์ ํฌํจ)
[.Net] C#์์ CefSharp์ผ๋ก ํฌ๋กฌ ๋ธ๋ผ์ฐ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ (์์ ํฌํจ)
2021.09.11 -
[.Net] C#์์ JPEG, PNG๋ฅผ WebP๋ก ๋ณํํ๋ ๋ฐฉ๋ฒ (์์ ํฌํจ)
[.Net] C#์์ JPEG, PNG๋ฅผ WebP๋ก ๋ณํํ๋ ๋ฐฉ๋ฒ (์์ ํฌํจ)
2021.08.30 -
[.Net] C#์์ ์์ (Excel) ํ์ผ ๋ค๋ฃจ๋ ๋ฐฉ๋ฒ (์์ ํฌํจ)
[.Net] C#์์ ์์ (Excel) ํ์ผ ๋ค๋ฃจ๋ ๋ฐฉ๋ฒ (์์ ํฌํจ)
2021.05.01 -
[.Net] C#์ผ๋ก ๋์ ์ฆ๊ถ ์ฃผ์ ์๋ ๋งค๋งค ํ๋ก๊ทธ๋จ ๋ง๋ค๊ธฐ - ํฌ๋ ์จ ํ๋ฌ์ค ์ค๋น ๋จ๊ณ
[.Net] C#์ผ๋ก ๋์ ์ฆ๊ถ ์ฃผ์ ์๋ ๋งค๋งค ํ๋ก๊ทธ๋จ ๋ง๋ค๊ธฐ - ํฌ๋ ์จ ํ๋ฌ์ค ์ค๋น ๋จ๊ณ
2021.04.12