TextBoxã«é¢ããè¦æ¸ã®ãã¹ã¦
èªä½ã®ã½ããã§ããã¹ãã®ç·¨éãåºæ¥ãããã«ãããã£ãã®ã ããæ®éã®ããã¹ãã¨ãã£ã¿ã®ããã«undo/redoãåºæ¥ãããã«ããããç¯å²é¸æ+tabã ã¨ããèªåã¤ã³ãã³ãã¨ãè¡çªå·è¡¨ç¤ºã ã¨ããããã£ããã®ããµãã¼ããããã¨æãã¨çµæ§å¤§å¤ã ã
.NET Frameworkã®TextBoxã¯ã¨ã¦ãéåã ãundo/redoãããµãã¼ããã¦ããªãã.NETã®æ¨æºã³ã³ããã¼ã«ã¨ãã¦ããã£ã¨é«æ©è½ãªããã¹ãããã¯ã¹ããã£ã¦ãããããããªãã®ã¨æãã®ã ãã
Visual Studio 2010ã®word wrapã®é ã
ã©ããããé
ããã¨ããã¨âãããããé
ãã
Visual Studio 2010ã®word wrapã®é
ã(æ¬ã®è«)
http://cpplover.blogspot.com/2010/04/visual-studio-2010word-wrap.html
ãã®åã§ã¯Visual Studioéçºãã¼ã ã«åºæ¥ã®ããããã¹ãããã¯ã¹ãªãã¦æå¾ ããã®ã¯åå°ç¡çããç¥ããªãã
25å¹´åã®ããã¹ãã¨ãã£ã¿
ãããããã25å¹´ãããåã«ãªãããå½æã®ãã½ã³ã³ã§ãããã¹ãã¨ãã£ã¿ããã¡ãã¨ä½ãã®ã¯å¤§å¤ã ã£ãããªã¼ã«ã¢ã»ã³ãã©ã§æ¸ããªããã°ãªããªãã¨ãããã¨ã«å ãã¦ã¿ã¼ã²ãããZ80 4MHzã¨ããªã®ã§ç¡é§ãªã¡ã¢ãªã³ãã¼ãªã©ãéããªãçç¥ããªããã°ãªããªãããã¾ãã«ã¡ã¢ãªã16KBã»ã©ãã使ããªãã®ã§ã¡ã¢ãªã®ç¡é§é£ããã§ããªããå¯è±ªçããã°ã©ãã³ã°ãªãã¬ã大貧æ°çããã°ã©ãã³ã°ã ã
ããã«ã¤ãã¦å½æã©ããã£ã¦ããã®ãã«ã¤ãã¦ããå°ãçªã£è¾¼ãã 解説ããã¦ãããªããã°ãªããªãã
25å¹´åã®ããã¹ãã¨ãã£ã¿ã®è¨è¨ææ³
ããã¹ãã¨ãã£ã¿ãªã®ã§è¡ã®æ¿å
¥ã»åé¤ãªã©ãé »ç¹ã«è¡ãããããã ããè¡ã®æ¿å
¥ãåé¤ã«ãã£ã¦å¤§ããªã¡ã¢ãªãããã¯ã®ã³ãã¼ãããããã«ã¯ãããªããããã«ãåè¡ãåæ¹ålinked listã§æã£ã¦ããã¦åé¤ã»æ¿å
¥æã«ã¡ã¢ãªãããã¯ã®ã³ãã¼ã¯æ¥µåçºçããªãããã«ããã
ã¾ããlinked listã§ãªãã¦ãåè¡ã¸ã®ãã¤ã³ã¿ã ãæã£ã¦ããããªå®è£ ã§ãããã®ã ãããã®å ´åè¡åé¤ããã¨ãã«ãã®ãã¤ã³ã¿é åã®è¦ç´ ã®removeã«ä¼´ãªãã¡ã¢ãªãããã¯ã®ã³ãã¼ãçºçããã®ã§ããã¯ããã§ã¬ã¹ãã³ã¹ã®ä½ä¸ã«ã¤ãªããã®ã§ããã
次ã«ãè¡ãåé¤ããå ´åã ãããã®åé¤ããè¡ã®ãã¼ã¿ãåå¨ãã¦ããã¡ã¢ãªãããã¯ãæ°¸ä¹ ã«ä½¿ããªããããªå®è£ ã ã¨ãã£ãããªãã®ã§ãããåå©ç¨ããªããã°ãªããªããããã¯ãããã¯ã°ã©ã¦ã³ãã§å°ããã¤åæ¹ã«è©°ãã¦ããä½æ¥ãè¡ãã(次å³)
ã¡ãã£ã¨ãã®å³ã§ã¯ãããã«ããããç¥ããªããGCã¯ã1è¡ç®ããé çªã«linked listã辿ã£ã¦ãããè¡ã®çµç«¯ã¯'\0'ã§çµãã£ã¦ãããã¨ã¯ä¿è¨¼ããã¦ããã®ã§ããã®å³ã§4è¡ç®ã¾ã§ããã¨ãã«ã4è¡ç®ã®è¡é ã®1çªå°æåã®ã¡ã¢ãªã'\0'ã§ãªããã°ããã¯åé¤ãããè¡ã§ãããã¨ããããã®ã§ãã®ããã«æåã«ãã'\0'ãã¹ãã£ã³ãã¦(ããã¯2è¡ç®ã®æå¾ã®'\0'ã§è¦ã¤ãã)ã4è¡ç®ãä¸èº«ã2è¡ç®ã®æ«å°¾ã®ç´å¾ã«ç§»åãããã
ãã¾é¢¨ã®è¨èã§è¨ãã¨ãincremental GCã§ãããã¨ã¦ãç°¡ç´ ãªå®è£ ã§ã¯ãããã
25å¹´ãæã®ããã°ã©ã ã§ãããããããã®ãã¨ã¯æä½éãã£ã¦ããã®ã ã
ç¾ä»£ã®ããã¹ãããã¯ã¹ã®ããã¹ã姿ã¨ã¯ï¼
ãããã大貧æ°çããã°ã©ãã³ã°ã®è¦ç¹ã§æããã¨ã.NET Frameworkã®TextBoxã¯ãWindowsã®EditBoxã®èãwrapperã§ãã¡ã½ãããååã«ç¨æããã¦ããã(ç¾å¨ã®ãã£ã¬ããã®åå¨ããè¡çªå·ããåå¾ã§ããªã)ãããã§ã¯ååãªããã©ã¼ãã³ã¹ãåºãã¨ã¯ã¨ã¦ãè¨ãé£ãã
ãã¾ã®æ代ãã¨ã³ãã¦ã¼ã¶ã¼(.NET Frameworkã使ã£ã¦ããã°ã©ã ãæ¸ã人)ã¯åºæ¬çã«å¤§å¯è±ªçãªããã°ã©ãã³ã°ã§è¯ãã®ã ãããã®å¶ä½æã«å¿ è¦ã¨ãªãã³ã³ãã¼ãã³ãããã¬ã¼ã ã¯ã¼ã¯ãªããã¯æ¬å½ã«å¤§è²§æ°çã«ä½ããã¦ããªããã°ã¨ã³ãã¦ã¼ã¶ã¼ã大å¯è±ªçã«ãªããªãã¨æãã
ã¯ã¦ãã§ã³ã¡ã³ããã¦ããã ãããå¯è±ªã¯ããã¾ã§å¤§è²§æ°ã«æ¯ãããã¦ããã¨ããã¯æ¬å½ã«ããã ã¨æãããã·ã³ã¯ãªã½ã¼ã¹ãéããã¦ããã®ã§ããã®éããããªã½ã¼ã¹ãã²ã¨ã¤ã®ã¢ããªãæ¯ããããããã®ã³ã³ãã¼ãã³ãã奪ãåã£ã¦å ±åãã¦ãããã¦ã¼ã¶ã¼ã幸ãã«ãªãããã«ã¯ã³ã³ãã¼ãã³ãã«æ³£ãã¦ããããããªããããã¯ãç©ç©ã®çç£éãéããã¦ããç¶æ³ä¸ã§ã誰ããè ¹ãã£ã±ãé£ã¹ããã¨æãã¨ä»ã®ã¿ããªãã¾ã¨ãã«é£ã«ããã¤ããªãã®ã«ãä¼¼ã¦ããã
AlpTextBox
æåãAlpTextBoxã¨ãã.NET Frameworkã§ä½¿ããããã¹ãããã¯ã¹ã®ã³ã³ãã¼ãã³ãã使ã£ã¦ã¿ããvectorã§æ¤ç´¢ããã¨ããããç¡ãã£ãã®ã ã
é度ã¯ããããéããWindowsAPIãç´æ¥å¼ã³åºãã¦è¡çªå·ãæç»ãã¦ããã
使ã£ã¦ã¿ã¦ããã£ããã¨ã¯è¡çªå·ã表示ããã¨è¡ã®1æåç®ãå·¦2ãããã»ã©æ¬ ããããããè´å½çã ãã½ã¼ã¹ãã¤ãã¦ãªãããDotfuscatorã§é£èªåãã¦ããã
C#ã®reflectionã使ã£ã¦privateã¡ã³ãã®å¤ãæ¸ãæããã°ãã®2ãããæ¬ ãã¦ããåé¡èªä½ã¯åé¿ã§ãããã¨ãçºè¦ãããã.NET Framework1.1ã§æ¸ããã¦ãããä½è ã¯ã¡ã³ããã³ã¹ãããã¦ãªãã¨æãããã®ã§ããã®ã³ã³ãã¼ãã³ãã¯çµ¶å¯¾ã«ä½¿ã£ã¦ã¯é§ç®ã ãæ¬å½ãæéãç¡é§ã«ãããAlpTextBoxççºããï¼
AlpTextBoxã®ãã¦ã³ãã¼ãå ã«ãªã³ã¯ãè²¼ãã¨SEOçã«ååãããã¨ã«ãªã£ã¦ç ç²è ãå¢ããã¨ãããªãã®ã§ãªã³ã¯ã¯è²¼ããªãã
ScintillaNET
ScintillaNET(âãhttp://scintillanet.codeplex.com/ )ã¯ãä¸ççã«ä½¿ããã¦ããScintillaã.NETç¨ã«wrapãããã®ã ãç¾å¨ã®ææ°ã®ãã¼ã¸ã§ã³ã¯2.2ã
æ©é使ã£ã¦ã¿ããè¡çªå·è¡¨ç¤ºãC#ã®ã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ãã¨ãã«åé¡ãªãã
ãããæ¥æ¬èªãå ¥åæã«å ¥åä¸ã®æåã®ãã©ã³ããå°ãããªããã¾ãscintilla.Fontãå¤æ´ãã¦ã表示ããã¦ãããã©ã³ããåæ ãããªããscintillaã®APIãç´æ¥å¼ã³åºãã°è§£æ±ºããã®ããç¥ããªããããããªãã¨ã¯ããããªãããã¡ãã¨wrapãã¦æ¬²ããã
ãã¨scintilla.InsertTextãè¡ãªãå ´åã1è¡åã«æ¥æ¬èªæåã使ã£ã¦ããã¨æ¿å ¥å ´æããããããªãã
ãã¶ãå é¨çã«ã¯utf-16ã«ãªã£ã¦ããããutf-8ã§æ±ããã¦ããã®ã§ã¯ãªããã¨æããæååã®æ¤ç´¢ã»ç½®æãªã©ã§ããã®åé¡ãããã
ç§ã¯ããã®ã³ã³ãã¼ãã³ãã¯æ¥æ¬èªç°å¢ã§ä½¿ãç©ã«ãªãã¨ã¯æããªãã£ããã²ã¨ã¤ããµãã¤ãããã®ãã°ãªãèªåã§ç´ãã¦ããããcommitããã¤ããã ã£ãããå é¨çã«utf-8ã ã£ãããããããªã³ã³ãã¼ãã³ããä¿®æ£ãã¦ã¦ãããªãç¡ããutf-16ã§ä½ãç´ãã¨è¨ããããªãã
ãããªããã§ãç§ã¯ScintillaNETã¯ç¾æ®µéã§æ¥æ¬èªç°å¢ã§æºè¶³ã«ä½¿ããã¨ã¯æããªãã®ã§ãè¦ãããªãããã¼ã¸ã§ã³ããããã°ã¾ãfixãããããç¥ããªãããã¡ãã¨.NET Frameworkã®TextBoxã¨äºææ§ãããããã«wrapãã¦ãããªãã¨é常ã«ä½¿ãã«ããã
ä¾ãã°ReadOnlyã«ããã¨Textããããã£ã«ä»£å ¥ãã¦ãåæ ãããªããReadOnlyã£ã¦æ®éã¦ã¼ã¶ã¼ããã®UIã§ã®æä½ã«å¯¾ãã¦read onlyã«ããã®ã§ãã£ã¦ã誰ãæ¬å½ã«Textã¾ã§read onlyã«ããã¨â¦ã¨è¨ã£ãæãã§ã使ã£ã¦ããã¨ããããããããã¨ããã«æ°ã¥ãã
ICSharpCode.TextEditor
SharpDevelopã§å
é¨çã«ä½¿ããã¦ããããã¹ãããã¯ã¹ã試ãã¦ã¿ãããã¨SharpDevelopã®ã½ã¼ã¹ããã¦ã³ãã¼ããã¦ããã®ã ãããµã³ãã«ãVisual Studioã§ãã«ãã§ããªããåç
§è¨å®ã¨ããã¡ãã¨ããã°åºæ¥ããã ãããã©ãVisual Studioã§ãã«ãã§ããªãããã¸ã§ã¯ããã¡ã¤ã«ãã¤ãã¦ãæç¹ã§èããã®ã§èª¿æ»çµäºã
ICSharpCode.TextEditorã«ã¤ãã¦è©³ãããã¨ã¯Azukiã®ä½è ã«ããã¬ãã¥ã¼è¨äº(âãhttp://sgry.jp/pgarticles/cs_editor_component.html )ã¨ãã覧ãã
Azuki ããã¹ãã¨ãã£ã¿ã¨ã³ã¸ã³
Azuki ããã¹ãã¨ãã£ã¿ã¨ã³ã¸ã³
http://azuki.sourceforge.jp/
æ¥æ¬äººã®æ¸ããããã¹ãã¨ãã£ã¿ã¨ã³ã¸ã³ãC#ãã使ãããè¡çªå·è¡¨ç¤ºãã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ããªã©ãåºæ¥ããç¾å¨ã®ãã¼ã¸ã§ã³ã¯1.55ã
ãã£ã¨ä½¿ã£ã¦ã¿ãææ³ã ããã¾ããã£ãã©ã«ãã®ãã¶ã¤ã³ã«ç§ã«ã¯éåæããããèæ¯è²ãèããã³ã¯ã«ãªã£ã¦ãã¦æ°æã¡æªããç½ã§ãããã ããç½ã§ãè²ãå¤æ´ãããã¨ãã©ã¼ã ãã¶ã¤ãã§BackColorã«Whiteãæå®ãããåæ ãããªãã£ããã³ã³ãã¼ãã³ãåæåã®ãã¨ã«èªåã§BackColorã«Whiteãä»£å ¥ããã°åæ ãããããªãã§ã ãâ¦ã
ã¾ããé è²ã«é¢ãã¦ã¯ããã¹ãããã¯ã¹ã®ä»£ããã«ã½ããã«åãã¦ä½¿ãããããã§ãèªå·±ä¸»å¼µã®æ¿ããé è²ã¯è¿·æãªã®ã§ããããã¨Tabã®è¨å·ãåå¨æã主張ãããããããªæ¨ªé·ã®Tabã®è¨å·è¦ããã¨ããªãã
ããããã¼ãè¦ãã¨ãTabã®è¨å·ãããã¨Tabå¹ ã«ãã¦ãã¹ãã¼ã¹ã¨æ··å¨ãããã¨ãã«ã©ãã¾ã§ãTabã§ãããè¦ã¦ãããããã«ãã¦ããã®ã ã¨æ°ã¥ãããªãã»ã©ããããªãTabã¨ã¹ãã¼ã¹ãæ··å¨ããã¦ãTabã®ç´å¾ã«ã¹ãã¼ã¹ãããã°è¦ã¦ãããããã ããã®ä½è ã¯é ãããªâ¦ã
æ¥æ¬èªå ¥åã«é¢ãã¦ã¯ä½ã®åé¡ããªããã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ãã¯åæ ãããã®ãã¯ã³ãã³ãé ããä½è ã«ããã¨1.6ã§æ¹åããã¨ã®ãã¨ã ãç§ã¯ã½ã¼ã¹ããã«ãããªããã¦ã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ãã®åæ æéã1/4ã®æéã«å¤æ´ããã
ãã¨ãAppendããInsertããDeleteããæ®éããã ããã¨æããããªã¡ã½ãããã¾ã£ããç¨æããã¦ããªããããã®ã¯ãReplaceã ãã ã
ããããã®Replaceããããå¼·åã§ãéå§ä½ç½®ã¨çµäºä½ç½®ãæå®ãã¦æåç½®æã§ããã®ã§ãInsertã®ä»£ããã«Replace(string)ã使ã£ãããå é è¡ãã100è¡ç®ã¾ã§åé¤ããããã°ããæ¸ãã¨ãï¼
int end = azukiControl1.Document.GetLineHeadIndex( 100 );
azukiControl1.Document.Replace("",0,end);
ä¸ã®ããã«è¡çªå·ãããã®ãã¸ã·ã§ã³ãåå¾ã§ããã®ã§Replaceã¨çµã¿åãããã°ä½ã ã£ã¦åºæ¥ãã ããããReplaceã ãç¨æãã¦ããã®Replaceãéããªãé«éåãã¨ãã°ãããããã¨ããè¨è¨ææ³ãªã®ã ã¨æããæåæ¸æã£ãããããã¯ããã§ãããã
ãã¨ãCanCopy,CanCut,CanPasteãå®è£ ããã¦ããªãã(CanUndoã¨CanRedoã¯ãã)ãCanCopy,CanCutã¯é¸æç¯å²ãããã°trueã¨ãã¦æ±ãã°ããã¨ãã¦ãCanPasteã¯å®è£ ãã¨ããªãããããªãã¨æãã
çµè«ã¨ãã¦
.NET Frameworkã®æ¨æºã®ããã¹ãããã¯ã¹ãé«æ©è½ã«ãªãã¨ããã®ã¯å°æ¥çã«ããã¾ãæå¾
ã§ããªããç´ ç´ã«èª°ãã®ã³ã³ãã¼ãã³ãã使ãã®ãä¸çªããã¨æãã
ç§ãä»å調æ»ããç¯å²ã«ããã¦Azuki以å¤ã«ã¯è¡çªå·ã表示ã¨ã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ãã¨ãåºæ¥ã¦ãæ¥æ¬èªããã¡ãã¨æ±ããããã¹ãããã¯ã¹ãç¡ãã£ãã¨ããã®ãå®æ ã§ãããAzukiã«ãããããä¸æºã¯ããã®ã ããããã¹ãããã¯ã¹ã®èªåå®è£ ã¨ããã®ã¯æ³åãã以ä¸ã«å¤§å¤ãªã®ã§ãã¯ã誰ããä½ã£ããã®ããã®ã¾ã¾ä½¿ãããã
æ¥æ¬èªã¾ããã®ãã°ãããªããªãã°Azukiããã¯ScintillaNETã®ã»ããããã¸ã§ã¯ãæ¯ä½ã¯å¤§ããããªã®ã§è¯ããããªæ°ããããã¨ããããç¾ç¶ã¯ããã§æ¸ãã¦ããéãã ã