From 0aecb50e0ed3320ca2d1d3dc13db40e659f00fc3 Mon Sep 17 00:00:00 2001 From: Jim Saxton Date: Thu, 5 Apr 2018 10:37:03 -0700 Subject: [PATCH] add easy method for setting system plain | fixed | bold fonts to textedit. --- Documentation/yab-Commands | 5 +- src/YabInterface.cpp | 58 +++++++++++++++++++++-- yab-IDE/data/Help_En.dat | 4 +- yab-IDE/data/Help_En_Index.dat | 84 +++++++++++++++++----------------- 4 files changed, 102 insertions(+), 49 deletions(-) diff --git a/Documentation/yab-Commands b/Documentation/yab-Commands index 5a23902..5e7c329 100644 --- a/Documentation/yab-Commands +++ b/Documentation/yab-Commands @@ -624,8 +624,7 @@ TEXTCONTROL SET TextControl$, IsPassword IsPassword = true Hide typing TEXTCONTROL SET TextControl$, Option$, Value$ Option$="align" Value$= "left" / "right" / "center" - *** note *** Haiku has issues align right. There are open tickets. - Option$="exclude", Value$=characters to disallow. + Option$="exclude", Value$=characters to disallow. Option$="include", Value$=characters to allow. Option$="length", Value$=str$(number) of characters allowed. Sets the font used to the system fixed font. @@ -698,6 +697,8 @@ TEXTEDIT SET TextEdit$, Option$, Value$ Add a word Value$ to the auto-completion list. Option$ = "font" Set the font to Value$ (similar to DRAW SET); default is "system-plain" + Option$="align" value$= "left | center | right" Sets the alignment for text in the textedit view. + Option$ = "plain | bold |fixed" valu$=str$(point_size) Sets the font face to system plain | bold | fixed font and sets the size to point_size TEXTEDIT COLOR TextEdit$, Option$, Command$ Option$ = "color1, color2, color3, color4, char-color", Command$ Add the command Command$ to the list of words that are checked for syntax highlighting diff --git a/src/YabInterface.cpp b/src/YabInterface.cpp index a130b89..1ad7142 100644 --- a/src/YabInterface.cpp +++ b/src/YabInterface.cpp @@ -2871,6 +2871,7 @@ void YabInterface::TextControl(const char* id, const char* option, const char* v ErrorGen("Bad length"); } } + if(tmpOption.IFindFirst("exclude")!=B_ERROR) { int i; @@ -3677,6 +3678,11 @@ void YabInterface::TextSet(const char* title, const char* option, const char* va myText = cast_as(myView->FindView(title),YabText); if(myText) { + + + + + if(tmp.IFindFirst("align")!=B_ERROR) { if(tmp2.IFindFirst("left")!=B_ERROR) @@ -3685,7 +3691,52 @@ void YabInterface::TextSet(const char* title, const char* option, const char* va myText->SetAlignment(B_ALIGN_CENTER); else if(tmp2.IFindFirst("right")!=B_ERROR) myText->SetAlignment(B_ALIGN_RIGHT); - } + } + else if(tmp.IFindFirst("fixed")!=B_ERROR) + { + const char* str_int = tmp2.String(); + int i = atoi(str_int); + if (i>6) + { + BFont myFont=(be_fixed_font); + int myFontSize = i; + myFont.SetSize(myFontSize); + int TL = myText->TextLength(); + const rgb_color Textcolor = {0,0,0,255}; + myText->SetFontAndColor(0,TL,&myFont,B_FONT_ALL,&Textcolor); + } + + } + else if(tmp.IFindFirst("plain")!=B_ERROR) + { + const char* str_int = tmp2.String(); + int i = atoi(str_int); + if (i>6) + { + BFont myFont=(be_plain_font); + int myFontSize = i; + myFont.SetSize(myFontSize); + int TL = myText->TextLength(); + const rgb_color Textcolor = {0,0,0,255}; + myText->SetFontAndColor(0,TL,&myFont,B_FONT_ALL,&Textcolor); + } + + } + else if(tmp.IFindFirst("bold")!=B_ERROR) + { + const char* str_int = tmp2.String(); + int i = atoi(str_int); + if (i>6) + { + BFont myFont=(be_bold_font); + int myFontSize = i; + myFont.SetSize(myFontSize); + int TL = myText->TextLength(); + const rgb_color Textcolor = {0,0,0,255}; + myText->SetFontAndColor(0,TL,&myFont,B_FONT_ALL,&Textcolor); + } + + } else if(tmp.IFindFirst("autocomplete")!=B_ERROR) myText->AddWord(new BString(value)); else if(tmp.IFindFirst("font")!=B_ERROR) @@ -3805,10 +3856,9 @@ void YabInterface::TextSet(const char* title, const char* option, int value) else if(tmp.IFindFirst("tabwidth")!=B_ERROR) myText->SetTabWidth(value); else if(tmp.IFindFirst("cursor")!=B_ERROR) - myText->Select(value, value); + myText->Select(value, value); else if(tmp.IFindFirst("textwidth")!=B_ERROR) - - + { // BRect txtframe = myText->TextRect(); // txtframe.right = txtframe.left + value; diff --git a/yab-IDE/data/Help_En.dat b/yab-IDE/data/Help_En.dat index e927fd0..c67381d 100644 --- a/yab-IDE/data/Help_En.dat +++ b/yab-IDE/data/Help_En.dat @@ -8306,7 +8306,6 @@ Set the text control's text to Text$. TEXTCONTROL SET TextControl$, Option$, Value$ Option$="align" Value$= "left" / "right" / "center" -*** note *** Haiku has issues align right. There are open tickets. Option$="exclude", Value$=characters to disallow. Option$="include", Value$=characters to allow. Option$="length", Value$=str$(number) of characters allowed. @@ -8515,6 +8514,9 @@ Given three parameters, the following options are valid for the textedit named T Option$ = "font" -- set the font to Value$ (see draw set for details), default is "system-plain" Option$ = "autocomplete" -- add the word Value$ to the auto-completion list Option$ = "align" and value$ = "left|center|right" -- set the alignment for text in the textedit view. +Option$ = "plain" value$ = str$(point) sets the font to system plain font of point size (number from 7 and up +Option$ = "fixed" value$ = str$(point) sets the font to system fixed font of point size (number from 7 and up +Option$ = "bold" value$ = str$(point) sets the font to system bold font of point size (number from 7 and up Related: textedit, textedit add, textedit clear, textedit color, textedit get, textedit get$ &TextURL diff --git a/yab-IDE/data/Help_En_Index.dat b/yab-IDE/data/Help_En_Index.dat index 455b656..3a0d454 100644 --- a/yab-IDE/data/Help_En_Index.dat +++ b/yab-IDE/data/Help_En_Index.dat @@ -579,86 +579,86 @@ textcontrol get$ textcontrol set 261477 textedit -262603 +262535 textedit add -263266 +263198 textedit clear -263591 +263523 textedit color -263933 +263865 textedit get -264914 +264846 textedit get$ -266606 +266538 textedit set -267045 +266977 & -270252 +270515 texturl -270260 +270523 texturl color -270868 +271131 tooltip -271248 +271511 tooltip color -272928 +273191 & -274211 +274474 treebox -274219 +274482 treebox add -274582 +274845 treebox clear -275107 -treebox collapse 275370 +treebox collapse +275633 treebox count -275668 +275931 treebox expand -275976 +276239 treebox get$ -276259 +276522 treebox remove -276586 +276849 treebox select -277071 +277334 treebox sort -277374 +277637 & -277668 +277931 localize -277677 +277940 translate$() -280909 +281172 &Sound -281662 +281925 & -281664 +281927 beep -281669 +281932 bell -281903 +282166 sound play -282266 +282529 sound stop -283191 +283454 sound wait -283565 +283828 &Window -283970 +284233 & -283972 +284235 alert -283978 +284241 filepanel -285756 +286019 window open -289046 +289309 window close -291761 +292024 window count -292253 +292516 window get -292880 +293143 window set -294714 +294977