qsciscintilla.h 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252
  1. // This module defines the "official" high-level API of the Qt port of
  2. // Scintilla.
  3. //
  4. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  5. //
  6. // This file is part of QScintilla.
  7. //
  8. // This file may be used under the terms of the GNU General Public License
  9. // version 3.0 as published by the Free Software Foundation and appearing in
  10. // the file LICENSE included in the packaging of this file. Please review the
  11. // following information to ensure the GNU General Public License version 3.0
  12. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  13. //
  14. // If you do not wish to use this file under the terms of the GPL version 3.0
  15. // then you may purchase a commercial license. For more information contact
  16. // info@riverbankcomputing.com.
  17. //
  18. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  19. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20. #ifndef QSCISCINTILLA_H
  21. #define QSCISCINTILLA_H
  22. #include <QByteArray>
  23. #include <QList>
  24. #include <QObject>
  25. #include <QPointer>
  26. #include <QStringList>
  27. #include <Qsci/qsciglobal.h>
  28. #include <Qsci/qscicommand.h>
  29. #include <Qsci/qscidocument.h>
  30. #include <Qsci/qsciscintillabase.h>
  31. QT_BEGIN_NAMESPACE
  32. class QAction;
  33. class QImage;
  34. class QIODevice;
  35. class QMenu;
  36. class QPoint;
  37. QT_END_NAMESPACE
  38. class QsciCommandSet;
  39. class QsciLexer;
  40. class QsciStyle;
  41. class QsciStyledText;
  42. class QsciListBoxQt;
  43. //! \brief The QsciScintilla class implements a higher level, more Qt-like,
  44. //! API to the Scintilla editor widget.
  45. //!
  46. //! QsciScintilla implements methods, signals and slots similar to those found
  47. //! in other Qt editor classes. It also provides a higher level interface to
  48. //! features specific to Scintilla such as syntax styling, call tips,
  49. //! auto-indenting and auto-completion than that provided by QsciScintillaBase.
  50. class QSCINTILLA_EXPORT QsciScintilla : public QsciScintillaBase
  51. {
  52. Q_OBJECT
  53. public:
  54. //! This enum defines the different auto-indentation styles.
  55. enum {
  56. //! A line is automatically indented to match the previous line.
  57. AiMaintain = 0x01,
  58. //! If the language supported by the current lexer has a specific start
  59. //! of block character (e.g. { in C++), then a line that begins with
  60. //! that character is indented as well as the lines that make up the
  61. //! block. It may be logically ored with AiClosing.
  62. AiOpening = 0x02,
  63. //! If the language supported by the current lexer has a specific end
  64. //! of block character (e.g. } in C++), then a line that begins with
  65. //! that character is indented as well as the lines that make up the
  66. //! block. It may be logically ored with AiOpening.
  67. AiClosing = 0x04
  68. };
  69. //! This enum defines the different annotation display styles.
  70. enum AnnotationDisplay {
  71. //! Annotations are not displayed.
  72. AnnotationHidden = ANNOTATION_HIDDEN,
  73. //! Annotations are drawn left justified with no adornment.
  74. AnnotationStandard = ANNOTATION_STANDARD,
  75. //! Annotations are surrounded by a box.
  76. AnnotationBoxed = ANNOTATION_BOXED,
  77. //! Annotations are indented to match the text.
  78. AnnotationIndented = ANNOTATION_INDENTED,
  79. };
  80. //! This enum defines the behavior if an auto-completion list contains a
  81. //! single entry.
  82. enum AutoCompletionUseSingle {
  83. //! The single entry is not used automatically and the auto-completion
  84. //! list is displayed.
  85. AcusNever,
  86. //! The single entry is used automatically when auto-completion is
  87. //! explicitly requested (using autoCompleteFromAPIs() or
  88. //! autoCompleteFromDocument()) but not when auto-completion is
  89. //! triggered as the user types.
  90. AcusExplicit,
  91. //! The single entry is used automatically and the auto-completion list
  92. //! is not displayed.
  93. AcusAlways
  94. };
  95. //! This enum defines the different sources for auto-completion lists.
  96. enum class AutoCompletionSource {
  97. //! No sources are used, ie. automatic auto-completion is disabled.
  98. AcsNone,
  99. //! The source is all available sources.
  100. AcsAll,
  101. //! The source is the current document.
  102. AcsDocument,
  103. //! The source is any installed APIs.
  104. AcsAPIs
  105. };
  106. //! This enum defines the different brace matching modes. The character
  107. //! pairs {}, [] and () are treated as braces. The Python lexer will also
  108. //! match a : with the end of the corresponding indented block.
  109. enum class BraceMatch {
  110. //! Brace matching is disabled.
  111. NoBraceMatch,
  112. //! Brace matching is enabled for a brace immediately before the
  113. //! current position.
  114. StrictBraceMatch,
  115. //! Brace matching is enabled for a brace immediately before or after
  116. //! the current position.
  117. SloppyBraceMatch
  118. };
  119. //! This enum defines the different call tip positions.
  120. enum class CallTipsPosition {
  121. //! Call tips are placed below the text.
  122. CallTipsBelowText,
  123. //! Call tips are placed above the text.
  124. CallTipsAboveText,
  125. };
  126. //! This enum defines the different call tip styles.
  127. enum class CallTipsStyle {
  128. //! Call tips are disabled.
  129. CallTipsNone,
  130. //! Call tips are displayed without a context. A context is any scope
  131. //! (e.g. a C++ namespace or a Python module) prior to the function
  132. //! name.
  133. CallTipsNoContext,
  134. //! Call tips are displayed with a context only if the user hasn't
  135. //! already implicitly identified the context using autocompletion.
  136. //! Note that this style may not always be able to align the call tip
  137. //! with the text being entered.
  138. CallTipsNoAutoCompletionContext,
  139. //! Call tips are displayed with a context. Note that this style
  140. //! may not always be able to align the call tip with the text being
  141. //! entered.
  142. CallTipsContext
  143. };
  144. //! This enum defines the different edge modes for long lines.
  145. enum /*class*/ EdgeMode {
  146. //! Long lines are not marked.
  147. EdgeNone = EDGE_NONE,
  148. //! A vertical line is drawn at the column set by setEdgeColumn().
  149. //! This is recommended for monospace fonts.
  150. EdgeLine = EDGE_LINE,
  151. //! The background color of characters after the column limit is
  152. //! changed to the color set by setEdgeColor(). This is recommended
  153. //! for proportional fonts.
  154. EdgeBackground = EDGE_BACKGROUND,
  155. //! Multiple vertical lines are drawn at the columns defined by
  156. //! multiple calls to addEdgeColumn().
  157. EdgeMultipleLines = EDGE_MULTILINE,
  158. };
  159. //! This enum defines the different end-of-line modes.
  160. enum /*class*/ EolMode {
  161. //! A carriage return/line feed as used on Windows systems.
  162. EolWindows = SC_EOL_CRLF,
  163. //! A line feed as used on Unix systems, including OS/X.
  164. EolUnix = SC_EOL_LF,
  165. //! A carriage return as used on Mac systems prior to OS/X.
  166. EolMac = SC_EOL_CR
  167. };
  168. //! This enum defines the different styles for the folding margin.
  169. enum /*class*/ FoldStyle {
  170. //! Folding is disabled.
  171. NoFoldStyle,
  172. //! Plain folding style using plus and minus symbols.
  173. PlainFoldStyle,
  174. //! Circled folding style using circled plus and minus symbols.
  175. CircledFoldStyle,
  176. //! Boxed folding style using boxed plus and minus symbols.
  177. BoxedFoldStyle,
  178. //! Circled tree style using a flattened tree with circled plus and
  179. //! minus symbols and rounded corners.
  180. CircledTreeFoldStyle,
  181. //! Boxed tree style using a flattened tree with boxed plus and minus
  182. //! symbols and right-angled corners.
  183. BoxedTreeFoldStyle
  184. };
  185. //! This enum defines the different indicator styles.
  186. enum class IndicatorStyle {
  187. //! A single straight underline.
  188. PlainIndicator = INDIC_PLAIN,
  189. //! A squiggly underline that requires 3 pixels of descender space.
  190. SquiggleIndicator = INDIC_SQUIGGLE,
  191. //! A line of small T shapes.
  192. TTIndicator = INDIC_TT,
  193. //! Diagonal hatching.
  194. DiagonalIndicator = INDIC_DIAGONAL,
  195. //! Strike out.
  196. StrikeIndicator = INDIC_STRIKE,
  197. //! An indicator with no visual appearence.
  198. HiddenIndicator = INDIC_HIDDEN,
  199. //! A rectangle around the text.
  200. BoxIndicator = INDIC_BOX,
  201. //! A rectangle with rounded corners around the text with the interior
  202. //! usually more transparent than the border.
  203. RoundBoxIndicator = INDIC_ROUNDBOX,
  204. //! A rectangle around the text with the interior usually more
  205. //! transparent than the border. It does not colour the top pixel of
  206. //! the line so that indicators on contiguous lines are visually
  207. //! distinct and disconnected.
  208. StraightBoxIndicator = INDIC_STRAIGHTBOX,
  209. //! A rectangle around the text with the interior usually more
  210. //! transparent than the border. Unlike StraightBoxIndicator it covers
  211. //! the entire character area.
  212. FullBoxIndicator = INDIC_FULLBOX,
  213. //! A dashed underline.
  214. DashesIndicator = INDIC_DASH,
  215. //! A dotted underline.
  216. DotsIndicator = INDIC_DOTS,
  217. //! A squiggly underline that requires 2 pixels of descender space and
  218. //! so will fit under smaller fonts.
  219. SquiggleLowIndicator = INDIC_SQUIGGLELOW,
  220. //! A dotted rectangle around the text with the interior usually more
  221. //! transparent than the border.
  222. DotBoxIndicator = INDIC_DOTBOX,
  223. //! A version of SquiggleIndicator that uses a pixmap. This is quicker
  224. //! but may be of lower quality.
  225. SquigglePixmapIndicator = INDIC_SQUIGGLEPIXMAP,
  226. //! A thick underline typically used for the target during Asian
  227. //! language input composition.
  228. ThickCompositionIndicator = INDIC_COMPOSITIONTHICK,
  229. //! A thin underline typically used for non-target ranges during Asian
  230. //! language input composition.
  231. ThinCompositionIndicator = INDIC_COMPOSITIONTHIN,
  232. //! The color of the text is set to the color of the indicator's
  233. //! foreground.
  234. TextColorIndicator = INDIC_TEXTFORE,
  235. //! A triangle below the start of the indicator range.
  236. TriangleIndicator = INDIC_POINT,
  237. //! A triangle below the centre of the first character in the indicator
  238. //! range.
  239. TriangleCharacterIndicator = INDIC_POINTCHARACTER,
  240. };
  241. //! This enum defines the different margin options.
  242. enum {
  243. //! Reset all margin options.
  244. MoNone = SC_MARGINOPTION_NONE,
  245. //! If this is set then only the first sub-line of a wrapped line will
  246. //! be selected when clicking on a margin.
  247. MoSublineSelect = SC_MARGINOPTION_SUBLINESELECT
  248. };
  249. //! This enum defines the different margin types.
  250. enum /*class*/ MarginType {
  251. //! The margin contains symbols, including those used for folding.
  252. SymbolMargin = SC_MARGIN_SYMBOL,
  253. //! The margin contains symbols and uses the default foreground color
  254. //! as its background color.
  255. SymbolMarginDefaultForegroundColor = SC_MARGIN_FORE,
  256. //! The margin contains symbols and uses the default background color
  257. //! as its background color.
  258. SymbolMarginDefaultBackgroundColor = SC_MARGIN_BACK,
  259. //! The margin contains line numbers.
  260. NumberMargin = SC_MARGIN_NUMBER,
  261. //! The margin contains styled text.
  262. TextMargin = SC_MARGIN_TEXT,
  263. //! The margin contains right justified styled text.
  264. TextMarginRightJustified = SC_MARGIN_RTEXT,
  265. //! The margin contains symbols and uses the color set by
  266. //! setMarginBackgroundColor() as its background color.
  267. SymbolMarginColor = SC_MARGIN_COLOUR,
  268. };
  269. //! This enum defines the different pre-defined marker symbols.
  270. enum MarkerSymbol {
  271. //! A circle.
  272. Circle = SC_MARK_CIRCLE,
  273. //! A rectangle.
  274. Rectangle = SC_MARK_ROUNDRECT,
  275. //! A triangle pointing to the right.
  276. RightTriangle = SC_MARK_ARROW,
  277. //! A smaller rectangle.
  278. SmallRectangle = SC_MARK_SMALLRECT,
  279. //! An arrow pointing to the right.
  280. RightArrow = SC_MARK_SHORTARROW,
  281. //! An invisible marker that allows code to track the movement
  282. //! of lines.
  283. Invisible = SC_MARK_EMPTY,
  284. //! A triangle pointing down.
  285. DownTriangle = SC_MARK_ARROWDOWN,
  286. //! A drawn minus sign.
  287. Minus = SC_MARK_MINUS,
  288. //! A drawn plus sign.
  289. Plus = SC_MARK_PLUS,
  290. //! A vertical line drawn in the background colour.
  291. VerticalLine = SC_MARK_VLINE,
  292. //! A bottom left corner drawn in the background colour.
  293. BottomLeftCorner = SC_MARK_LCORNER,
  294. //! A vertical line with a centre right horizontal line drawn
  295. //! in the background colour.
  296. LeftSideSplitter = SC_MARK_TCORNER,
  297. //! A drawn plus sign in a box.
  298. BoxedPlus = SC_MARK_BOXPLUS,
  299. //! A drawn plus sign in a connected box.
  300. BoxedPlusConnected = SC_MARK_BOXPLUSCONNECTED,
  301. //! A drawn minus sign in a box.
  302. BoxedMinus = SC_MARK_BOXMINUS,
  303. //! A drawn minus sign in a connected box.
  304. BoxedMinusConnected = SC_MARK_BOXMINUSCONNECTED,
  305. //! A rounded bottom left corner drawn in the background
  306. //! colour.
  307. RoundedBottomLeftCorner = SC_MARK_LCORNERCURVE,
  308. //! A vertical line with a centre right curved line drawn in the
  309. //! background colour.
  310. LeftSideRoundedSplitter = SC_MARK_TCORNERCURVE,
  311. //! A drawn plus sign in a circle.
  312. CircledPlus = SC_MARK_CIRCLEPLUS,
  313. //! A drawn plus sign in a connected box.
  314. CircledPlusConnected = SC_MARK_CIRCLEPLUSCONNECTED,
  315. //! A drawn minus sign in a circle.
  316. CircledMinus = SC_MARK_CIRCLEMINUS,
  317. //! A drawn minus sign in a connected circle.
  318. CircledMinusConnected = SC_MARK_CIRCLEMINUSCONNECTED,
  319. //! No symbol is drawn but the line is drawn with the same background
  320. //! color as the marker's.
  321. Background = SC_MARK_BACKGROUND,
  322. //! Three drawn dots.
  323. ThreeDots = SC_MARK_DOTDOTDOT,
  324. //! Three drawn arrows pointing right.
  325. ThreeRightArrows = SC_MARK_ARROWS,
  326. //! A full rectangle (ie. the margin background) using the marker's
  327. //! background color.
  328. FullRectangle = SC_MARK_FULLRECT,
  329. //! A left rectangle (ie. the left part of the margin background) using
  330. //! the marker's background color.
  331. LeftRectangle = SC_MARK_LEFTRECT,
  332. //! No symbol is drawn but the line is drawn underlined using the
  333. //! marker's background color.
  334. Underline = SC_MARK_UNDERLINE,
  335. //! A bookmark.
  336. Bookmark = SC_MARK_BOOKMARK,
  337. };
  338. //! This enum defines how tab characters are drawn when whitespace is
  339. //! visible.
  340. enum TabDrawMode {
  341. //! An arrow stretching to the tab stop.
  342. TabLongArrow = SCTD_LONGARROW,
  343. //! A horizontal line stretching to the tab stop.
  344. TabStrikeOut = SCTD_STRIKEOUT,
  345. };
  346. //! This enum defines the different whitespace visibility modes. When
  347. //! whitespace is visible spaces are displayed as small centred dots and
  348. //! tabs are displayed as light arrows pointing to the right.
  349. enum WhitespaceVisibility {
  350. //! Whitespace is invisible.
  351. WsInvisible = SCWS_INVISIBLE,
  352. //! Whitespace is always visible.
  353. WsVisible = SCWS_VISIBLEALWAYS,
  354. //! Whitespace is visible after the whitespace used for indentation.
  355. WsVisibleAfterIndent = SCWS_VISIBLEAFTERINDENT,
  356. //! Whitespace used for indentation is visible.
  357. WsVisibleOnlyInIndent = SCWS_VISIBLEONLYININDENT,
  358. };
  359. //! This enum defines the different line wrap modes.
  360. enum WrapMode {
  361. //! Lines are not wrapped.
  362. WrapNone = SC_WRAP_NONE,
  363. //! Lines are wrapped at word boundaries.
  364. WrapWord = SC_WRAP_WORD,
  365. //! Lines are wrapped at character boundaries.
  366. WrapCharacter = SC_WRAP_CHAR,
  367. //! Lines are wrapped at whitespace boundaries.
  368. WrapWhitespace = SC_WRAP_WHITESPACE,
  369. };
  370. //! This enum defines the different line wrap visual flags.
  371. enum WrapVisualFlag {
  372. //! No wrap flag is displayed.
  373. WrapFlagNone,
  374. //! A wrap flag is displayed by the text.
  375. WrapFlagByText,
  376. //! A wrap flag is displayed by the border.
  377. WrapFlagByBorder,
  378. //! A wrap flag is displayed in the line number margin.
  379. WrapFlagInMargin
  380. };
  381. //! This enum defines the different line wrap indentation modes.
  382. enum WrapIndentMode {
  383. //! Wrapped sub-lines are indented by the amount set by
  384. //! setWrapVisualFlags().
  385. WrapIndentFixed = SC_WRAPINDENT_FIXED,
  386. //! Wrapped sub-lines are indented by the same amount as the first
  387. //! sub-line.
  388. WrapIndentSame = SC_WRAPINDENT_SAME,
  389. //! Wrapped sub-lines are indented by the same amount as the first
  390. //! sub-line plus one more level of indentation.
  391. WrapIndentIndented = SC_WRAPINDENT_INDENT
  392. };
  393. //! Construct an empty QsciScintilla with parent \a parent.
  394. QsciScintilla(QWidget *parent = 0);
  395. //! Destroys the QsciScintilla instance.
  396. virtual ~QsciScintilla();
  397. //! Returns the API context, which is a list of words, before the position
  398. //! \a pos in the document. The context can be used by auto-completion and
  399. //! call tips to help to identify which API call the user is referring to.
  400. //! In the default implementation the current lexer determines what
  401. //! characters make up a word, and what characters determine the boundaries
  402. //! of words (ie. the start characters). If there is no current lexer then
  403. //! the context will consist of a single word. On return \a context_start
  404. //! will contain the position in the document of the start of the context
  405. //! and \a last_word_start will contain the position in the document of the
  406. //! start of the last word of the context.
  407. virtual QStringList apiContext(int pos, int &context_start,
  408. int &last_word_start);
  409. //! Annotate the line \a line with the text \a text using the style number
  410. //! \a style.
  411. void annotate(int line, const QString &text, int style);
  412. //! Annotate the line \a line with the text \a text using the style \a
  413. //! style.
  414. void annotate(int line, const QString &text, const QsciStyle &style);
  415. //! Annotate the line \a line with the styled text \a text.
  416. void annotate(int line, const QsciStyledText &text);
  417. //! Annotate the line \a line with the list of styled text \a text.
  418. void annotate(int line, const QList<QsciStyledText> &text);
  419. //! Returns the annotation on line \a line, if any.
  420. QString annotation(int line) const;
  421. //! Returns the display style for annotations.
  422. //!
  423. //! \sa setAnnotationDisplay()
  424. AnnotationDisplay annotationDisplay() const;
  425. //! The annotations on line \a line are removed. If \a line is negative
  426. //! then all annotations are removed.
  427. void clearAnnotations(int line = -1);
  428. //! Returns true if auto-completion lists are case sensitive.
  429. //!
  430. //! \sa setAutoCompletionCaseSensitivity()
  431. bool autoCompletionCaseSensitivity() const;
  432. //! Returns true if auto-completion fill-up characters are enabled.
  433. //!
  434. //! \sa setAutoCompletionFillups(), setAutoCompletionFillupsEnabled()
  435. bool autoCompletionFillupsEnabled() const;
  436. //! Returns true if the rest of the word to the right of the current cursor
  437. //! is removed when an item from an auto-completion list is selected.
  438. //!
  439. //! \sa setAutoCompletionReplaceWord()
  440. bool autoCompletionReplaceWord() const;
  441. //! Returns true if the only item in an auto-completion list with a single
  442. //! entry is automatically used and the list not displayed. Note that this
  443. //! is deprecated and autoCompletionUseSingle() should be used instead.
  444. //!
  445. //! \sa setAutoCompletionShowSingle()
  446. bool autoCompletionShowSingle() const;
  447. //! Returns the current source for the auto-completion list when it is
  448. //! being displayed automatically as the user types.
  449. //!
  450. //! \sa setAutoCompletionSource()
  451. AutoCompletionSource autoCompletionSource() const {return acSource;}
  452. //! Returns the current threshold for the automatic display of the
  453. //! auto-completion list as the user types.
  454. //!
  455. //! \sa setAutoCompletionThreshold()
  456. int autoCompletionThreshold() const {return acThresh;}
  457. //! Returns the current behavior when an auto-completion list contains a
  458. //! single entry.
  459. //!
  460. //! \sa setAutoCompletionUseSingle()
  461. AutoCompletionUseSingle autoCompletionUseSingle() const;
  462. //! Returns true if auto-indentation is enabled.
  463. //!
  464. //! \sa setAutoIndent()
  465. bool autoIndent() const {return autoInd;}
  466. //! Returns true if the backspace key unindents a line instead of deleting
  467. //! a character. The default is false.
  468. //!
  469. //! \sa setBackspaceUnindents(), tabIndents(), setTabIndents()
  470. bool backspaceUnindents() const;
  471. //! Mark the beginning of a sequence of actions that can be undone by a
  472. //! single call to undo().
  473. //!
  474. //! \sa endUndoAction(), undo()
  475. void beginUndoAction();
  476. //! Returns the brace matching mode.
  477. //!
  478. //! \sa setBraceMatching()
  479. BraceMatch braceMatching() const {return braceMode;}
  480. //! Returns the encoded text between positions \a start and \a end. This
  481. //! is typically used by QsciLexerCustom::styleText().
  482. //!
  483. //! \sa text()
  484. QByteArray bytes(int start, int end) const;
  485. //! Returns the current call tip position.
  486. //!
  487. //! \sa setCallTipsPosition()
  488. CallTipsPosition callTipsPosition() const {return call_tips_position;}
  489. //! Returns the current call tip style.
  490. //!
  491. //! \sa setCallTipsStyle()
  492. CallTipsStyle callTipsStyle() const {return call_tips_style;}
  493. //! Returns the maximum number of call tips that are displayed.
  494. //!
  495. //! \sa setCallTipsVisible()
  496. int callTipsVisible() const {return maxCallTips;}
  497. //! Cancel any current auto-completion or user defined list.
  498. void cancelList();
  499. //! Returns true if the current language lexer is case sensitive. If there
  500. //! is no current lexer then true is returned.
  501. bool caseSensitive() const;
  502. //! Clear all current folds, i.e. ensure that all lines are displayed
  503. //! unfolded.
  504. //!
  505. //! \sa setFolding()
  506. void clearFolds();
  507. //! Clears the range of text with indicator \a indicatorNumber starting at
  508. //! position \a indexFrom in line \a lineFrom and finishing at position
  509. //! \a indexTo in line \a lineTo.
  510. //!
  511. //! \sa fillIndicatorRange()
  512. void clearIndicatorRange(int lineFrom, int indexFrom, int lineTo,
  513. int indexTo, int indicatorNumber);
  514. //! Clear all registered images.
  515. //!
  516. //! \sa registerImage()
  517. void clearRegisteredImages();
  518. //! Returns the widget's text (ie. foreground) colour.
  519. //!
  520. //! \sa setColor()
  521. QColor color() const;
  522. //! Returns a list of the line numbers that have contracted folds. This is
  523. //! typically used to save the fold state of a document.
  524. //!
  525. //! \sa setContractedFolds()
  526. QList<int> contractedFolds() const;
  527. //! All the lines of the text have their end-of-lines converted to mode
  528. //! \a mode.
  529. //!
  530. //! \sa eolMode(), setEolMode()
  531. void convertEols(EolMode mode);
  532. //! Create the standard context menu which is shown when the user clicks
  533. //! with the right mouse button. It is called from contextMenuEvent().
  534. //! The menu's ownership is transferred to the caller.
  535. QMenu *createStandardContextMenu();
  536. //! Returns the attached document.
  537. //!
  538. //! \sa setDocument()
  539. QsciDocument document() const {return doc;}
  540. //! Mark the end of a sequence of actions that can be undone by a single
  541. //! call to undo().
  542. //!
  543. //! \sa beginUndoAction(), undo()
  544. void endUndoAction();
  545. //! Returns the color of the marker used to show that a line has exceeded
  546. //! the length set by setEdgeColumn().
  547. //!
  548. //! \sa setEdgeColor(), \sa setEdgeColumn
  549. QColor edgeColor() const;
  550. //! Returns the number of the column after which lines are considered to be
  551. //! long.
  552. //!
  553. //! \sa setEdgeColumn()
  554. int edgeColumn() const;
  555. //! Returns the edge mode which determines how long lines are marked.
  556. //!
  557. //! \sa setEdgeMode()
  558. EdgeMode edgeMode() const;
  559. //! Set the default font. This has no effect if a language lexer has been
  560. //! set.
  561. void setFont(const QFont &f);
  562. //! Returns the end-of-line mode.
  563. //!
  564. //! \sa setEolMode()
  565. EolMode eolMode() const;
  566. //! Returns the visibility of end-of-lines.
  567. //!
  568. //! \sa setEolVisibility()
  569. bool eolVisibility() const;
  570. //! Returns the extra space added to the height of a line above the
  571. //! baseline of the text.
  572. //!
  573. //! \sa setExtraAscent(), extraDescent()
  574. int extraAscent() const;
  575. //! Returns the extra space added to the height of a line below the
  576. //! baseline of the text.
  577. //!
  578. //! \sa setExtraDescent(), extraAscent()
  579. int extraDescent() const;
  580. //! Fills the range of text with indicator \a indicatorNumber starting at
  581. //! position \a indexFrom in line \a lineFrom and finishing at position
  582. //! \a indexTo in line \a lineTo.
  583. //!
  584. //! \sa clearIndicatorRange()
  585. void fillIndicatorRange(int lineFrom, int indexFrom, int lineTo,
  586. int indexTo, int indicatorNumber);
  587. //! Find the first occurrence of the string \a expr and return true if
  588. //! \a expr was found, otherwise returns false. If \a expr is found it
  589. //! becomes the current selection.
  590. //!
  591. //! If \a re is true then \a expr is interpreted as a regular expression
  592. //! rather than a simple string.
  593. //!
  594. //! If \a cs is true then the search is case sensitive.
  595. //!
  596. //! If \a wo is true then the search looks for whole word matches only,
  597. //! otherwise it searches for any matching text.
  598. //!
  599. //! If \a wrap is true then the search wraps around the end of the text.
  600. //!
  601. //! If \a forward is true (the default) then the search is forward from the
  602. //! starting position to the end of the text, otherwise it is backwards to
  603. //! the beginning of the text.
  604. //!
  605. //! If either \a line or \a index are negative (the default) then the
  606. //! search begins from the current cursor position. Otherwise the search
  607. //! begins at position \a index of line \a line.
  608. //!
  609. //! If \a show is true (the default) then any text found is made visible
  610. //! (ie. it is unfolded).
  611. //!
  612. //! If \a posix is true then a regular expression is treated in a more
  613. //! POSIX compatible manner by interpreting bare ( and ) as tagged sections
  614. //! rather than \( and \).
  615. //!
  616. //! \sa findFirstInSelection(), findNext(), replace()
  617. virtual bool findFirst(const QString &expr, bool re, bool cs, bool wo,
  618. bool wrap, bool forward = true, int line = -1, int index = -1,
  619. bool show = true, bool posix = false);
  620. //! Find the first occurrence of the string \a expr in the current
  621. //! selection and return true if \a expr was found, otherwise returns
  622. //! false. If \a expr is found it becomes the current selection. The
  623. //! original selection is restored when a subsequent call to findNext()
  624. //! returns false.
  625. //!
  626. //! If \a re is true then \a expr is interpreted as a regular expression
  627. //! rather than a simple string.
  628. //!
  629. //! If \a cs is true then the search is case sensitive.
  630. //!
  631. //! If \a wo is true then the search looks for whole word matches only,
  632. //! otherwise it searches for any matching text.
  633. //!
  634. //! If \a forward is true (the default) then the search is forward from the
  635. //! start to the end of the selection, otherwise it is backwards from the
  636. //! end to the start of the selection.
  637. //!
  638. //! If \a show is true (the default) then any text found is made visible
  639. //! (ie. it is unfolded).
  640. //!
  641. //! If \a posix is true then a regular expression is treated in a more
  642. //! POSIX compatible manner by interpreting bare ( and ) as tagged sections
  643. //! rather than \( and \).
  644. //!
  645. //! \sa findFirstInSelection(), findNext(), replace()
  646. virtual bool findFirstInSelection(const QString &expr, bool re, bool cs,
  647. bool wo, bool forward = true, bool show = true,
  648. bool posix = false);
  649. //! Find the next occurence of the string found using findFirst() or
  650. //! findFirstInSelection().
  651. //!
  652. //! \sa findFirst(), findFirstInSelection(), replace()
  653. virtual bool findNext();
  654. //! Returns the number of the first visible line.
  655. //!
  656. //! \sa setFirstVisibleLine()
  657. int firstVisibleLine() const;
  658. //! Returns the current folding style.
  659. //!
  660. //! \sa setFolding()
  661. FoldStyle folding() const {return fold;}
  662. //! Sets \a *line and \a *index to the line and index of the cursor.
  663. //!
  664. //! \sa setCursorPosition()
  665. void getCursorPosition(int *line, int *index) const;
  666. //! If there is a selection, \a *lineFrom is set to the line number in
  667. //! which the selection begins and \a *lineTo is set to the line number in
  668. //! which the selection ends. (They could be the same.) \a *indexFrom is
  669. //! set to the index at which the selection begins within \a *lineFrom, and
  670. //! \a *indexTo is set to the index at which the selection ends within
  671. //! \a *lineTo. If there is no selection, \a *lineFrom, \a *indexFrom,
  672. //! \a *lineTo and \a *indexTo are all set to -1.
  673. //!
  674. //! \sa setSelection()
  675. void getSelection(int *lineFrom, int *indexFrom, int *lineTo,
  676. int *indexTo) const;
  677. //! Returns true if some text is selected.
  678. //!
  679. //! \sa selectedText()
  680. bool hasSelectedText() const {return selText;}
  681. //! Returns the number of characters that line \a line is indented by.
  682. //!
  683. //! \sa setIndentation()
  684. int indentation(int line) const;
  685. //! Returns true if the display of indentation guides is enabled.
  686. //!
  687. //! \sa setIndentationGuides()
  688. bool indentationGuides() const;
  689. //! Returns true if indentations are created using tabs and spaces, rather
  690. //! than just spaces. The default is true.
  691. //!
  692. //! \sa setIndentationsUseTabs()
  693. bool indentationsUseTabs() const;
  694. //! Returns the indentation width in characters. The default is 0 which
  695. //! means that the value returned by tabWidth() is actually used.
  696. //!
  697. //! \sa setIndentationWidth(), tabWidth()
  698. int indentationWidth() const;
  699. //! Define a type of indicator using the style \a style with the indicator
  700. //! number \a indicatorNumber. If \a indicatorNumber is -1 then the
  701. //! indicator number is automatically allocated. The indicator number is
  702. //! returned or -1 if too many types of indicator have been defined.
  703. //!
  704. //! Indicators are used to display additional information over the top of
  705. //! styling. They can be used to show, for example, syntax errors,
  706. //! deprecated names and bad indentation by drawing lines under text or
  707. //! boxes around text.
  708. //!
  709. //! There may be up to 32 types of indicator defined at a time. The first
  710. //! 8 are normally used by lexers. By default indicator number 0 is a
  711. //! dark green SquiggleIndicator, 1 is a blue TTIndicator, and 2 is a red
  712. //! PlainIndicator.
  713. int indicatorDefine(IndicatorStyle style, int indicatorNumber = -1);
  714. //! Returns true if the indicator \a indicatorNumber is drawn under the
  715. //! text (i.e. in the background). The default is false.
  716. //!
  717. //! \sa setIndicatorDrawUnder()
  718. bool indicatorDrawUnder(int indicatorNumber) const;
  719. //! Returns true if a call tip is currently active.
  720. bool isCallTipActive() const;
  721. //! Returns true if an auto-completion or user defined list is currently
  722. //! active.
  723. bool isListActive() const;
  724. //! Returns true if the text has been modified.
  725. //!
  726. //! \sa setModified(), modificationChanged()
  727. bool isModified() const;
  728. //! Returns true if the text edit is read-only.
  729. //!
  730. //! \sa setReadOnly()
  731. bool isReadOnly() const;
  732. //! Returns true if there is something that can be redone.
  733. //!
  734. //! \sa redo()
  735. bool isRedoAvailable() const;
  736. //! Returns true if there is something that can be undone.
  737. //!
  738. //! \sa undo()
  739. bool isUndoAvailable() const;
  740. //! Returns true if text is interpreted as being UTF8 encoded. The default
  741. //! is to interpret the text as Latin1 encoded.
  742. //!
  743. //! \sa setUtf8()
  744. bool isUtf8() const;
  745. //! Returns true if character \a ch is a valid word character.
  746. //!
  747. //! \sa wordCharacters()
  748. bool isWordCharacter(char ch) const;
  749. //! Returns the line which is at \a point pixel coordinates or -1 if there
  750. //! is no line at that point.
  751. int lineAt(const QPoint &point) const;
  752. //! QScintilla uses the combination of a line number and a character index
  753. //! from the start of that line to specify the position of a character
  754. //! within the text. The underlying Scintilla instead uses a byte index
  755. //! from the start of the text. This will convert the \a position byte
  756. //! index to the \a *line line number and \a *index character index.
  757. //!
  758. //! \sa positionFromLineIndex()
  759. void lineIndexFromPosition(int position, int *line, int *index) const;
  760. //! Returns the length of line \a line int bytes or -1 if there is no such
  761. //! line. In order to get the length in characters use text(line).length().
  762. int lineLength(int line) const;
  763. //! Returns the number of lines of text.
  764. int lines() const;
  765. //! Returns the length of the text edit's text in bytes. In order to get
  766. //! the length in characters use text().length().
  767. int length() const;
  768. //! Returns the current language lexer used to style text. If it is 0 then
  769. //! syntax styling is disabled.
  770. //!
  771. //! \sa setLexer()
  772. QsciLexer *lexer() const;
  773. //! Returns the background color of margin \a margin.
  774. //!
  775. //! \sa setMarginBackgroundColor()
  776. QColor marginBackgroundColor(int margin) const;
  777. //! Returns true if line numbers are enabled for margin \a margin.
  778. //!
  779. //! \sa setMarginLineNumbers(), marginType(), SCI_GETMARGINTYPEN
  780. bool marginLineNumbers(int margin) const;
  781. //! Returns the marker mask of margin \a margin.
  782. //!
  783. //! \sa setMarginMask(), QsciMarker, SCI_GETMARGINMASKN
  784. int marginMarkerMask(int margin) const;
  785. //! Returns the margin options. The default is MoNone.
  786. //!
  787. //! \sa setMarginOptions(), MoNone, MoSublineSelect.
  788. int marginOptions() const;
  789. //! Returns true if margin \a margin is sensitive to mouse clicks.
  790. //!
  791. //! \sa setMarginSensitivity(), marginClicked(), SCI_GETMARGINTYPEN
  792. bool marginSensitivity(int margin) const;
  793. //! Returns the type of margin \a margin.
  794. //!
  795. //! \sa setMarginType(), SCI_GETMARGINTYPEN
  796. MarginType marginType(int margin) const;
  797. //! Returns the width in pixels of margin \a margin.
  798. //!
  799. //! \sa setMarginWidth(), SCI_GETMARGINWIDTHN
  800. int marginWidth(int margin) const;
  801. //! Returns the number of margins.
  802. //!
  803. //! \sa setMargins()
  804. int margins() const;
  805. //! Define a type of marker using the symbol \a sym with the marker number
  806. //! \a markerNumber. If \a markerNumber is -1 then the marker number is
  807. //! automatically allocated. The marker number is returned or -1 if too
  808. //! many types of marker have been defined.
  809. //!
  810. //! Markers are small geometric symbols and characters used, for example,
  811. //! to indicate the current line or, in debuggers, to indicate breakpoints.
  812. //! If a margin has a width of 0 then its markers are not drawn, but their
  813. //! background colours affect the background colour of the corresponding
  814. //! line of text.
  815. //!
  816. //! There may be up to 32 types of marker defined at a time and each line
  817. //! of text has a set of marker instances associated with it. Markers are
  818. //! drawn according to their numerical identifier. Markers try to move
  819. //! with their text by tracking where the start of their line moves to.
  820. //! For example, when a line is deleted its markers are added to previous
  821. //! line's markers.
  822. //!
  823. //! Each marker type is identified by a marker number. Each instance of a
  824. //! marker is identified by a marker handle.
  825. int markerDefine(MarkerSymbol sym, int markerNumber = -1);
  826. //! Define a marker using the character \a ch with the marker number
  827. //! \a markerNumber. If \a markerNumber is -1 then the marker number is
  828. //! automatically allocated. The marker number is returned or -1 if too
  829. //! many markers have been defined.
  830. int markerDefine(char ch, int markerNumber = -1);
  831. //! Define a marker using a copy of the pixmap \a pm with the marker number
  832. //! \a markerNumber. If \a markerNumber is -1 then the marker number is
  833. //! automatically allocated. The marker number is returned or -1 if too
  834. //! many markers have been defined.
  835. int markerDefine(const QPixmap &pm, int markerNumber = -1);
  836. //! Define a marker using a copy of the image \a im with the marker number
  837. //! \a markerNumber. If \a markerNumber is -1 then the marker number is
  838. //! automatically allocated. The marker number is returned or -1 if too
  839. //! many markers have been defined.
  840. int markerDefine(const QImage &im, int markerNumber = -1);
  841. //! Add an instance of marker number \a markerNumber to line number
  842. //! \a linenr. A handle for the marker is returned which can be used to
  843. //! track the marker's position, or -1 if the \a markerNumber was invalid.
  844. //!
  845. //! \sa markerDelete(), markerDeleteAll(), markerDeleteHandle()
  846. int markerAdd(int linenr, int markerNumber);
  847. //! Returns the 32 bit mask of marker numbers at line number \a linenr.
  848. //!
  849. //! \sa markerAdd()
  850. unsigned markersAtLine(int linenr) const;
  851. //! Delete all markers with the marker number \a markerNumber in the line
  852. //! \a linenr. If \a markerNumber is -1 then delete all markers from line
  853. //! \a linenr.
  854. //!
  855. //! \sa markerAdd(), markerDeleteAll(), markerDeleteHandle()
  856. void markerDelete(int linenr, int markerNumber = -1);
  857. //! Delete the all markers with the marker number \a markerNumber. If
  858. //! \a markerNumber is -1 then delete all markers.
  859. //!
  860. //! \sa markerAdd(), markerDelete(), markerDeleteHandle()
  861. void markerDeleteAll(int markerNumber = -1);
  862. //! Delete the the marker instance with the marker handle \a mhandle.
  863. //!
  864. //! \sa markerAdd(), markerDelete(), markerDeleteAll()
  865. void markerDeleteHandle(int mhandle);
  866. //! Return the line number that contains the marker instance with the
  867. //! marker handle \a mhandle.
  868. int markerLine(int mhandle) const;
  869. //! Return the number of the next line to contain at least one marker from
  870. //! a 32 bit mask of markers. \a linenr is the line number to start the
  871. //! search from. \a mask is the mask of markers to search for.
  872. //!
  873. //! \sa markerFindPrevious()
  874. int markerFindNext(int linenr, unsigned mask) const;
  875. //! Return the number of the previous line to contain at least one marker
  876. //! from a 32 bit mask of markers. \a linenr is the line number to start
  877. //! the search from. \a mask is the mask of markers to search for.
  878. //!
  879. //! \sa markerFindNext()
  880. int markerFindPrevious(int linenr, unsigned mask) const;
  881. //! Returns true if text entered by the user will overwrite existing text.
  882. //!
  883. //! \sa setOverwriteMode()
  884. bool overwriteMode() const;
  885. //! Returns the widget's paper (ie. background) colour.
  886. //!
  887. //! \sa setPaper()
  888. QColor paper() const;
  889. //! QScintilla uses the combination of a line number and a character index
  890. //! from the start of that line to specify the position of a character
  891. //! within the text. The underlying Scintilla instead uses a byte index
  892. //! from the start of the text. This will return the byte index
  893. //! corresponding to the \a line line number and \a index character index.
  894. //!
  895. //! \sa lineIndexFromPosition()
  896. int positionFromLineIndex(int line, int index) const;
  897. //! Reads the current document from the \a io device and returns true if
  898. //! there was no error.
  899. //!
  900. //! \sa write()
  901. bool read(QIODevice *io);
  902. //! Recolours the document between the \a start and \a end positions.
  903. //! \a start defaults to the start of the document and \a end defaults to
  904. //! the end of the document.
  905. virtual void recolor(int start = 0, int end = -1);
  906. //! Register an image \a pm with ID \a id. Registered images can be
  907. //! displayed in auto-completion lists.
  908. //!
  909. //! \sa clearRegisteredImages(), QsciLexer::apiLoad()
  910. void registerImage(int id, const QPixmap &pm);
  911. //! Register an image \a im with ID \a id. Registered images can be
  912. //! displayed in auto-completion lists.
  913. //!
  914. //! \sa clearRegisteredImages(), QsciLexer::apiLoad()
  915. void registerImage(int id, const QImage &im);
  916. //! Replace the current selection, set by a previous call to findFirst(),
  917. //! findFirstInSelection() or findNext(), with \a replaceStr.
  918. //!
  919. //! \sa findFirst(), findFirstInSelection(), findNext()
  920. virtual void replace(const QString &replaceStr);
  921. //! Reset the fold margin colours to their defaults.
  922. //!
  923. //! \sa setFoldMarginColors()
  924. void resetFoldMarginColors();
  925. //! Resets the background colour of an active hotspot area to the default.
  926. //!
  927. //! \sa setHotspotBackgroundColor(), resetHotspotForegroundColor()
  928. void resetHotspotBackgroundColor();
  929. //! Resets the foreground colour of an active hotspot area to the default.
  930. //!
  931. //! \sa setHotspotForegroundColor(), resetHotspotBackgroundColor()
  932. void resetHotspotForegroundColor();
  933. //! The fold margin may be drawn as a one pixel sized checkerboard pattern
  934. //! of two colours, \a fore and \a back.
  935. //!
  936. //! \sa resetFoldMarginColors()
  937. void setFoldMarginColors(const QColor &fore, const QColor &back);
  938. //! Set the display style for annotations. The default is
  939. //! AnnotationStandard.
  940. //!
  941. //! \sa annotationDisplay()
  942. void setAnnotationDisplay(AnnotationDisplay display);
  943. //! Enable the use of fill-up characters, either those explicitly set or
  944. //! those set by a lexer. By default, fill-up characters are disabled.
  945. //!
  946. //! \sa autoCompletionFillupsEnabled(), setAutoCompletionFillups()
  947. void setAutoCompletionFillupsEnabled(bool enabled);
  948. //! A fill-up character is one that, when entered while an auto-completion
  949. //! list is being displayed, causes the currently selected item from the
  950. //! list to be added to the text followed by the fill-up character.
  951. //! \a fillups is the set of fill-up characters. If a language lexer has
  952. //! been set then this is ignored and the lexer defines the fill-up
  953. //! characters. The default is that no fill-up characters are set.
  954. //!
  955. //! \sa autoCompletionFillupsEnabled(), setAutoCompletionFillupsEnabled()
  956. void setAutoCompletionFillups(const char *fillups);
  957. //! A word separator is a sequence of characters that, when entered, causes
  958. //! the auto-completion list to be displayed. If a language lexer has been
  959. //! set then this is ignored and the lexer defines the word separators.
  960. //! The default is that no word separators are set.
  961. //!
  962. //! \sa setAutoCompletionThreshold()
  963. void setAutoCompletionWordSeparators(const QStringList &separators);
  964. //! Set the background colour of call tips to \a col. The default is
  965. //! white.
  966. void setCallTipsBackgroundColor(const QColor &col);
  967. //! Set the foreground colour of call tips to \a col. The default is
  968. //! mid-gray.
  969. void setCallTipsForegroundColor(const QColor &col);
  970. //! Set the highlighted colour of call tip text to \a col. The default is
  971. //! dark blue.
  972. void setCallTipsHighlightColor(const QColor &col);
  973. //! Set the current call tip position. The default is CallTipsBelowText.
  974. //!
  975. //! \sa callTipsPosition()
  976. void setCallTipsPosition(CallTipsPosition position);
  977. //! Set the current call tip style. The default is CallTipsNoContext.
  978. //!
  979. //! \sa callTipsStyle()
  980. void setCallTipsStyle(CallTipsStyle style);
  981. //! Set the maximum number of call tips that are displayed to \a nr. If
  982. //! the maximum number is 0 then all applicable call tips are displayed.
  983. //! If the maximum number is -1 then one call tip will be displayed with up
  984. //! and down arrows that allow the use to scroll through the full list.
  985. //! The default is -1.
  986. //!
  987. //! \sa callTipsVisible()
  988. void setCallTipsVisible(int nr);
  989. //! Sets each line in the \a folds list of line numbers to be a contracted
  990. //! fold. This is typically used to restore the fold state of a document.
  991. //!
  992. //! \sa contractedFolds()
  993. void setContractedFolds(const QList<int> &folds);
  994. //! Attach the document \a document, replacing the currently attached
  995. //! document.
  996. //!
  997. //! \sa document()
  998. void setDocument(const QsciDocument &document);
  999. //! Add \a colnr to the columns which are displayed with a vertical line.
  1000. //! The edge mode must be set to EdgeMultipleLines.
  1001. //!
  1002. //! \sa clearEdgeColumns()
  1003. void addEdgeColumn(int colnr, const QColor &col);
  1004. //! Remove any columns added by previous calls to addEdgeColumn().
  1005. //!
  1006. //! \sa addEdgeColumn()
  1007. void clearEdgeColumns();
  1008. //! Set the color of the marker used to show that a line has exceeded the
  1009. //! length set by setEdgeColumn().
  1010. //!
  1011. //! \sa edgeColor(), \sa setEdgeColumn
  1012. void setEdgeColor(const QColor &col);
  1013. //! Set the number of the column after which lines are considered to be
  1014. //! long.
  1015. //!
  1016. //! \sa edgeColumn()
  1017. void setEdgeColumn(int colnr);
  1018. //! Set the edge mode which determines how long lines are marked.
  1019. //!
  1020. //! \sa edgeMode()
  1021. void setEdgeMode(EdgeMode mode);
  1022. //! Set the number of the first visible line to \a linenr.
  1023. //!
  1024. //! \sa firstVisibleLine()
  1025. void setFirstVisibleLine(int linenr);
  1026. //! Enables or disables, according to \a under, if the indicator
  1027. //! \a indicatorNumber is drawn under or over the text (i.e. in the
  1028. //! background or foreground). If \a indicatorNumber is -1 then the state
  1029. //! of all indicators is set.
  1030. //!
  1031. //! \sa indicatorDrawUnder()
  1032. void setIndicatorDrawUnder(bool under, int indicatorNumber = -1);
  1033. //! Set the foreground colour of indicator \a indicatorNumber to \a col.
  1034. //! If \a indicatorNumber is -1 then the colour of all indicators is set.
  1035. void setIndicatorForegroundColor(const QColor &col, int indicatorNumber = -1);
  1036. //! Set the foreground colour of indicator \a indicatorNumber to \a col
  1037. //! when the mouse is over it or the caret moved into it. If
  1038. //! \a indicatorNumber is -1 then the colour of all indicators is set.
  1039. void setIndicatorHoverForegroundColor(const QColor &col, int indicatorNumber = -1);
  1040. //! Set the style of indicator \a indicatorNumber to \a style when the
  1041. //! mouse is over it or the caret moved into it. If \a indicatorNumber is
  1042. //! -1 then the style of all indicators is set.
  1043. void setIndicatorHoverStyle(IndicatorStyle style, int indicatorNumber = -1);
  1044. //! Set the outline colour of indicator \a indicatorNumber to \a col.
  1045. //! If \a indicatorNumber is -1 then the colour of all indicators is set.
  1046. //! At the moment only the alpha value of the colour has any affect.
  1047. void setIndicatorOutlineColor(const QColor &col, int indicatorNumber = -1);
  1048. //! Sets the background color of margin \a margin to \a col.
  1049. //!
  1050. //! \sa marginBackgroundColor()
  1051. void setMarginBackgroundColor(int margin, const QColor &col);
  1052. //! Set the margin options to \a options.
  1053. //!
  1054. //! \sa marginOptions(), MoNone, MoSublineSelect.
  1055. void setMarginOptions(int options);
  1056. //! Set the margin text of line \a line with the text \a text using the
  1057. //! style number \a style.
  1058. void setMarginText(int line, const QString &text, int style);
  1059. //! Set the margin text of line \a line with the text \a text using the
  1060. //! style \a style.
  1061. void setMarginText(int line, const QString &text, const QsciStyle &style);
  1062. //! Set the margin text of line \a line with the styled text \a text.
  1063. void setMarginText(int line, const QsciStyledText &text);
  1064. //! Set the margin text of line \a line with the list of styled text \a
  1065. //! text.
  1066. void setMarginText(int line, const QList<QsciStyledText> &text);
  1067. //! Set the type of margin \a margin to type \a type.
  1068. //!
  1069. //! \sa marginType(), SCI_SETMARGINTYPEN
  1070. void setMarginType(int margin, MarginType type);
  1071. //! The margin text on line \a line is removed. If \a line is negative
  1072. //! then all margin text is removed.
  1073. void clearMarginText(int line = -1);
  1074. //! Set the number of margins to \a margins.
  1075. //!
  1076. //! \sa margins()
  1077. void setMargins(int margins);
  1078. //! Set the background colour, including the alpha component, of marker
  1079. //! \a markerNumber to \a col. If \a markerNumber is -1 then the colour of
  1080. //! all markers is set. The default is white.
  1081. //!
  1082. //! \sa setMarkerForegroundColor()
  1083. void setMarkerBackgroundColor(const QColor &col, int markerNumber = -1);
  1084. //! Set the foreground colour of marker \a markerNumber to \a col. If
  1085. //! \a markerNumber is -1 then the colour of all markers is set. The
  1086. //! default is black.
  1087. //!
  1088. //! \sa setMarkerBackgroundColor()
  1089. void setMarkerForegroundColor(const QColor &col, int markerNumber = -1);
  1090. //! Set the background colour used to display matched braces to \a col. It
  1091. //! is ignored if an indicator is being used. The default is white.
  1092. //!
  1093. //! \sa setMatchedBraceForegroundColor(), setMatchedBraceIndicator()
  1094. void setMatchedBraceBackgroundColor(const QColor &col);
  1095. //! Set the foreground colour used to display matched braces to \a col. It
  1096. //! is ignored if an indicator is being used. The default is red.
  1097. //!
  1098. //! \sa setMatchedBraceBackgroundColor(), setMatchedBraceIndicator()
  1099. void setMatchedBraceForegroundColor(const QColor &col);
  1100. //! Set the indicator used to display matched braces to \a indicatorNumber.
  1101. //! The default is not to use an indicator.
  1102. //!
  1103. //! \sa resetMatchedBraceIndicator(), setMatchedBraceBackgroundColor()
  1104. void setMatchedBraceIndicator(int indicatorNumber);
  1105. //! Stop using an indicator to display matched braces.
  1106. //!
  1107. //! \sa setMatchedBraceIndicator()
  1108. void resetMatchedBraceIndicator();
  1109. //! Sets the mode used to draw tab characters when whitespace is visible to
  1110. //! \a mode. The default is to use an arrow.
  1111. //!
  1112. //! \sa tabDrawMode()
  1113. void setTabDrawMode(TabDrawMode mode);
  1114. //! Set the background colour used to display unmatched braces to \a col.
  1115. //! It is ignored if an indicator is being used. The default is white.
  1116. //!
  1117. //! \sa setUnmatchedBraceForegroundColor(), setUnmatchedBraceIndicator()
  1118. void setUnmatchedBraceBackgroundColor(const QColor &col);
  1119. //! Set the foreground colour used to display unmatched braces to \a col.
  1120. //! It is ignored if an indicator is being used. The default is blue.
  1121. //!
  1122. //! \sa setUnmatchedBraceBackgroundColor(), setUnmatchedBraceIndicator()
  1123. void setUnmatchedBraceForegroundColor(const QColor &col);
  1124. //! Set the indicator used to display unmatched braces to
  1125. //! \a indicatorNumber. The default is not to use an indicator.
  1126. //!
  1127. //! \sa resetUnmatchedBraceIndicator(), setUnmatchedBraceBackgroundColor()
  1128. void setUnmatchedBraceIndicator(int indicatorNumber);
  1129. //! Stop using an indicator to display unmatched braces.
  1130. //!
  1131. //! \sa setUnmatchedBraceIndicator()
  1132. void resetUnmatchedBraceIndicator();
  1133. //! Set the visual flags displayed when a line is wrapped. \a endFlag
  1134. //! determines if and where the flag at the end of a line is displayed.
  1135. //! \a startFlag determines if and where the flag at the start of a line is
  1136. //! displayed. \a indent is the number of characters a wrapped line is
  1137. //! indented by. By default no visual flags are displayed.
  1138. void setWrapVisualFlags(WrapVisualFlag endFlag,
  1139. WrapVisualFlag startFlag = WrapFlagNone, int indent = 0);
  1140. //! Returns the selected text or an empty string if there is no currently
  1141. //! selected text.
  1142. //!
  1143. //! \sa hasSelectedText()
  1144. QString selectedText() const;
  1145. //! Returns whether or not the selection is drawn up to the right hand
  1146. //! border.
  1147. //!
  1148. //! \sa setSelectionToEol()
  1149. bool selectionToEol() const;
  1150. //! Sets the background colour of an active hotspot area to \a col.
  1151. //!
  1152. //! \sa resetHotspotBackgroundColor(), setHotspotForegroundColor()
  1153. void setHotspotBackgroundColor(const QColor &col);
  1154. //! Sets the foreground colour of an active hotspot area to \a col.
  1155. //!
  1156. //! \sa resetHotspotForegroundColor(), setHotspotBackgroundColor()
  1157. void setHotspotForegroundColor(const QColor &col);
  1158. //! Enables or disables, according to \a enable, the underlining of an
  1159. //! active hotspot area. The default is false.
  1160. void setHotspotUnderline(bool enable);
  1161. //! Enables or disables, according to \a enable, the wrapping of a hotspot
  1162. //! area to following lines. The default is true.
  1163. void setHotspotWrap(bool enable);
  1164. //! Sets whether or not the selection is drawn up to the right hand border.
  1165. //! \a filled is set if the selection is drawn to the border.
  1166. //!
  1167. //! \sa selectionToEol()
  1168. void setSelectionToEol(bool filled);
  1169. //! Sets the extra space added to the height of a line above the baseline
  1170. //! of the text to \a extra.
  1171. //!
  1172. //! \sa extraAscent(), setExtraDescent()
  1173. void setExtraAscent(int extra);
  1174. //! Sets the extra space added to the height of a line below the baseline
  1175. //! of the text to \a extra.
  1176. //!
  1177. //! \sa extraDescent(), setExtraAscent()
  1178. void setExtraDescent(int extra);
  1179. //! Text entered by the user will overwrite existing text if \a overwrite
  1180. //! is true.
  1181. //!
  1182. //! \sa overwriteMode()
  1183. void setOverwriteMode(bool overwrite);
  1184. //! Sets the background colour of visible whitespace to \a col. If \a col
  1185. //! is an invalid color (the default) then the color specified by the
  1186. //! current lexer is used.
  1187. void setWhitespaceBackgroundColor(const QColor &col);
  1188. //! Sets the foreground colour of visible whitespace to \a col. If \a col
  1189. //! is an invalid color (the default) then the color specified by the
  1190. //! current lexer is used.
  1191. void setWhitespaceForegroundColor(const QColor &col);
  1192. //! Sets the size of the dots used to represent visible whitespace.
  1193. //!
  1194. //! \sa whitespaceSize()
  1195. void setWhitespaceSize(int size);
  1196. //! Sets the line wrap indentation mode to \a mode. The default is
  1197. //! WrapIndentFixed.
  1198. //!
  1199. //! \sa wrapIndentMode()
  1200. void setWrapIndentMode(WrapIndentMode mode);
  1201. //! Displays a user defined list which can be interacted with like an
  1202. //! auto-completion list. \a id is an identifier for the list which is
  1203. //! passed as an argument to the userListActivated() signal and must be at
  1204. //! least 1. \a list is the text with which the list is populated.
  1205. //!
  1206. //! \sa cancelList(), isListActive(), userListActivated()
  1207. void showUserList(int id, const QStringList &list);
  1208. //! The standard command set is returned.
  1209. QsciCommandSet *standardCommands() const {return stdCmds;}
  1210. //! Returns the mode used to draw tab characters when whitespace is
  1211. //! visible.
  1212. //!
  1213. //! \sa setTabDrawMode()
  1214. TabDrawMode tabDrawMode() const;
  1215. //! Returns true if the tab key indents a line instead of inserting a tab
  1216. //! character. The default is true.
  1217. //!
  1218. //! \sa setTabIndents(), backspaceUnindents(), setBackspaceUnindents()
  1219. bool tabIndents() const;
  1220. //! Returns the tab width in characters. The default is 8.
  1221. //!
  1222. //! \sa setTabWidth()
  1223. int tabWidth() const;
  1224. //! Returns the text of the current document.
  1225. //!
  1226. //! \sa setText()
  1227. QString text() const;
  1228. //! \overload
  1229. //!
  1230. //! Returns the text of line \a line.
  1231. //!
  1232. //! \sa setText()
  1233. QString text(int line) const;
  1234. //! \overload
  1235. //!
  1236. //! Returns the text between positions \a start and \a end. This is
  1237. //! typically used by QsciLexerCustom::styleText().
  1238. //!
  1239. //! \sa bytes(), setText()
  1240. QString text(int start, int end) const;
  1241. //! Returns the height in pixels of the text in line number \a linenr.
  1242. int textHeight(int linenr) const;
  1243. //! Returns the size of the dots used to represent visible whitespace.
  1244. //!
  1245. //! \sa setWhitespaceSize()
  1246. int whitespaceSize() const;
  1247. //! Returns the visibility of whitespace.
  1248. //!
  1249. //! \sa setWhitespaceVisibility()
  1250. WhitespaceVisibility whitespaceVisibility() const;
  1251. //! Returns the word at the \a line line number and \a index character
  1252. //! index.
  1253. QString wordAtLineIndex(int line, int index) const;
  1254. //! Returns the word at the \a point pixel coordinates.
  1255. QString wordAtPoint(const QPoint &point) const;
  1256. //! Returns the set of valid word character as defined by the current
  1257. //! language lexer. If there is no current lexer then the set contains an
  1258. //! an underscore, numbers and all upper and lower case alphabetic
  1259. //! characters.
  1260. //!
  1261. //! \sa isWordCharacter()
  1262. const char *wordCharacters() const;
  1263. //! Returns the line wrap mode.
  1264. //!
  1265. //! \sa setWrapMode()
  1266. WrapMode wrapMode() const;
  1267. //! Returns the line wrap indentation mode.
  1268. //!
  1269. //! \sa setWrapIndentMode()
  1270. WrapIndentMode wrapIndentMode() const;
  1271. //! Writes the current document to the \a io device and returns true if
  1272. //! there was no error.
  1273. //!
  1274. //! \sa read()
  1275. bool write(QIODevice *io) const;
  1276. public slots:
  1277. //! Appends the text \a text to the end of the text edit. Note that the
  1278. //! undo/redo history is cleared by this function.
  1279. virtual void append(const QString &text);
  1280. //! Display an auto-completion list based on any installed APIs, the
  1281. //! current contents of the document and the characters immediately to the
  1282. //! left of the cursor.
  1283. //!
  1284. //! \sa autoCompleteFromAPIs(), autoCompleteFromDocument()
  1285. virtual void autoCompleteFromAll();
  1286. //! Display an auto-completion list based on any installed APIs and the
  1287. //! characters immediately to the left of the cursor.
  1288. //!
  1289. //! \sa autoCompleteFromAll(), autoCompleteFromDocument(),
  1290. //! setAutoCompletionAPIs()
  1291. virtual void autoCompleteFromAPIs();
  1292. //! Display an auto-completion list based on the current contents of the
  1293. //! document and the characters immediately to the left of the cursor.
  1294. //!
  1295. //! \sa autoCompleteFromAll(), autoCompleteFromAPIs()
  1296. virtual void autoCompleteFromDocument();
  1297. //! Display a call tip based on the the characters immediately to the left
  1298. //! of the cursor.
  1299. virtual void callTip();
  1300. //! Deletes all the text in the text edit.
  1301. virtual void clear();
  1302. //! Copies any selected text to the clipboard.
  1303. //!
  1304. //! \sa copyAvailable(), cut(), paste()
  1305. virtual void copy();
  1306. //! Copies any selected text to the clipboard and then deletes the text.
  1307. //!
  1308. //! \sa copy(), paste()
  1309. virtual void cut();
  1310. //! Ensures that the cursor is visible.
  1311. virtual void ensureCursorVisible();
  1312. //! Ensures that the line number \a line is visible.
  1313. virtual void ensureLineVisible(int line);
  1314. //! If any lines are currently folded then they are all unfolded.
  1315. //! Otherwise all lines are folded. This has the same effect as clicking
  1316. //! in the fold margin with the shift and control keys pressed. If
  1317. //! \a children is not set (the default) then only the top level fold
  1318. //! points are affected, otherwise the state of all fold points are
  1319. //! changed.
  1320. virtual void foldAll(bool children = false);
  1321. //! If the line \a line is folded then it is unfolded. Otherwise it is
  1322. //! folded. This has the same effect as clicking in the fold margin.
  1323. virtual void foldLine(int line);
  1324. //! Increases the indentation of line \a line by an indentation width.
  1325. //!
  1326. //! \sa unindent()
  1327. virtual void indent(int line);
  1328. //! Insert the text \a text at the current position.
  1329. virtual void insert(const QString &text);
  1330. //! Insert the text \a text in the line \a line at the position
  1331. //! \a index.
  1332. virtual void insertAt(const QString &text, int line, int index);
  1333. //! If the cursor is either side of a brace character then move it to the
  1334. //! position of the corresponding brace.
  1335. virtual void moveToMatchingBrace();
  1336. //! Pastes any text from the clipboard into the text edit at the current
  1337. //! cursor position.
  1338. //!
  1339. //! \sa copy(), cut()
  1340. virtual void paste();
  1341. //! Redo the last change or sequence of changes.
  1342. //!
  1343. //! \sa isRedoAvailable()
  1344. virtual void redo();
  1345. //! Removes any selected text.
  1346. //!
  1347. //! \sa replaceSelectedText()
  1348. virtual void removeSelectedText();
  1349. //! Replaces any selected text with \a text.
  1350. //!
  1351. //! \sa removeSelectedText()
  1352. virtual void replaceSelectedText(const QString &text);
  1353. //! Resets the background colour of selected text to the default.
  1354. //!
  1355. //! \sa setSelectionBackgroundColor(), resetSelectionForegroundColor()
  1356. virtual void resetSelectionBackgroundColor();
  1357. //! Resets the foreground colour of selected text to the default.
  1358. //!
  1359. //! \sa setSelectionForegroundColor(), resetSelectionBackgroundColor()
  1360. virtual void resetSelectionForegroundColor();
  1361. //! If \a select is true (the default) then all the text is selected. If
  1362. //! \a select is false then any currently selected text is deselected.
  1363. virtual void selectAll(bool select = true);
  1364. //! If the cursor is either side of a brace character then move it to the
  1365. //! position of the corresponding brace and select the text between the
  1366. //! braces.
  1367. virtual void selectToMatchingBrace();
  1368. //! If \a cs is true then auto-completion lists are case sensitive. The
  1369. //! default is true. Note that setting a lexer may change the case
  1370. //! sensitivity.
  1371. //!
  1372. //! \sa autoCompletionCaseSensitivity()
  1373. virtual void setAutoCompletionCaseSensitivity(bool cs);
  1374. //! If \a replace is true then when an item from an auto-completion list is
  1375. //! selected, the rest of the word to the right of the current cursor is
  1376. //! removed. The default is false.
  1377. //!
  1378. //! \sa autoCompletionReplaceWord()
  1379. virtual void setAutoCompletionReplaceWord(bool replace);
  1380. //! If \a single is true then when there is only a single entry in an
  1381. //! auto-completion list it is automatically used and the list is not
  1382. //! displayed. This only has an effect when auto-completion is explicitly
  1383. //! requested (using autoCompleteFromAPIs() and autoCompleteFromDocument())
  1384. //! and has no effect when auto-completion is triggered as the user types.
  1385. //! The default is false. Note that this is deprecated and
  1386. //! setAutoCompletionUseSingle() should be used instead.
  1387. //!
  1388. //! \sa autoCompletionShowSingle()
  1389. virtual void setAutoCompletionShowSingle(bool single);
  1390. //! Sets the source for the auto-completion list when it is being displayed
  1391. //! automatically as the user types to \a source. The default is AcsNone,
  1392. //! ie. it is disabled.
  1393. //!
  1394. //! \sa autoCompletionSource()
  1395. virtual void setAutoCompletionSource(AutoCompletionSource source);
  1396. //! Sets the threshold for the automatic display of the auto-completion
  1397. //! list as the user types to \a thresh. The threshold is the number of
  1398. //! characters that the user must type before the list is displayed. If
  1399. //! the threshold is less than or equal to 0 then the list is disabled.
  1400. //! The default is -1.
  1401. //!
  1402. //! \sa autoCompletionThreshold(), setAutoCompletionWordSeparators()
  1403. virtual void setAutoCompletionThreshold(int thresh);
  1404. //! Sets the behavior of the auto-completion list when it has a single
  1405. //! entry. The default is AcusNever.
  1406. //!
  1407. //! \sa autoCompletionUseSingle()
  1408. virtual void setAutoCompletionUseSingle(AutoCompletionUseSingle single);
  1409. //! If \a autoindent is true then auto-indentation is enabled. The default
  1410. //! is false.
  1411. //!
  1412. //! \sa autoIndent()
  1413. virtual void setAutoIndent(bool autoindent);
  1414. //! Sets the brace matching mode to \a bm. The default is NoBraceMatching.
  1415. //!
  1416. //! \sa braceMatching()
  1417. virtual void setBraceMatching(BraceMatch bm);
  1418. //! If \a deindent is true then the backspace key will unindent a line
  1419. //! rather then delete a character.
  1420. //!
  1421. //! \sa backspaceUnindents(), tabIndents(), setTabIndents()
  1422. virtual void setBackspaceUnindents(bool unindent);
  1423. //! Sets the foreground colour of the caret to \a col.
  1424. virtual void setCaretForegroundColor(const QColor &col);
  1425. //! Sets the background colour, including the alpha component, of the line
  1426. //! containing the caret to \a col.
  1427. //!
  1428. //! \sa setCaretLineVisible()
  1429. virtual void setCaretLineBackgroundColor(const QColor &col);
  1430. //! Enables or disables, according to \a enable, the background color of
  1431. //! the line containing the caret.
  1432. //!
  1433. //! \sa setCaretLineBackgroundColor()
  1434. virtual void setCaretLineVisible(bool enable);
  1435. //! Sets the width of the caret to \a width pixels. A \a width of 0 makes
  1436. //! the caret invisible.
  1437. virtual void setCaretWidth(int width);
  1438. //! The widget's text (ie. foreground) colour is set to \a c. This has no
  1439. //! effect if a language lexer has been set.
  1440. //!
  1441. //! \sa color()
  1442. virtual void setColor(const QColor &c);
  1443. //! Sets the cursor to the line \a line at the position \a index.
  1444. //!
  1445. //! \sa getCursorPosition()
  1446. virtual void setCursorPosition(int line, int index);
  1447. //! Sets the end-of-line mode to \a mode. The default is the platform's
  1448. //! natural mode.
  1449. //!
  1450. //! \sa eolMode()
  1451. virtual void setEolMode(QsciScintilla::EolMode mode);
  1452. //! If \a visible is true then end-of-lines are made visible. The default
  1453. //! is that they are invisible.
  1454. //!
  1455. //! \sa eolVisibility()
  1456. virtual void setEolVisibility(bool visible);
  1457. //! Sets the folding style for margin \a margin to \a fold. The default
  1458. //! style is NoFoldStyle (ie. folding is disabled) and the default margin
  1459. //! is 2.
  1460. //!
  1461. //! \sa folding()
  1462. virtual void setFolding(FoldStyle fold, int margin = 2);
  1463. //! Sets the indentation of line \a line to \a indentation characters.
  1464. //!
  1465. //! \sa indentation()
  1466. virtual void setIndentation(int line, int indentation);
  1467. //! Enables or disables, according to \a enable, this display of
  1468. //! indentation guides.
  1469. //!
  1470. //! \sa indentationGuides()
  1471. virtual void setIndentationGuides(bool enable);
  1472. //! Set the background colour of indentation guides to \a col.
  1473. //!
  1474. //! \sa setIndentationGuidesForegroundColor()
  1475. virtual void setIndentationGuidesBackgroundColor(const QColor &col);
  1476. //! Set the foreground colour of indentation guides to \a col.
  1477. //!
  1478. //! \sa setIndentationGuidesBackgroundColor()
  1479. virtual void setIndentationGuidesForegroundColor(const QColor &col);
  1480. //! If \a tabs is true then indentations are created using tabs and spaces,
  1481. //! rather than just spaces.
  1482. //!
  1483. //! \sa indentationsUseTabs()
  1484. virtual void setIndentationsUseTabs(bool tabs);
  1485. //! Sets the indentation width to \a width characters. If \a width is 0
  1486. //! then the value returned by tabWidth() is used.
  1487. //!
  1488. //! \sa indentationWidth(), tabWidth()
  1489. virtual void setIndentationWidth(int width);
  1490. //! Sets the specific language lexer used to style text to \a lex. If
  1491. //! \a lex is 0 then syntax styling is disabled.
  1492. //!
  1493. //! \sa lexer()
  1494. virtual void setLexer(QsciLexer *lexer = 0);
  1495. //! Set the background colour of all margins to \a col. The default is a
  1496. //! gray.
  1497. //!
  1498. //! \sa setMarginsForegroundColor()
  1499. virtual void setMarginsBackgroundColor(const QColor &col);
  1500. //! Set the font used in all margins to \a f.
  1501. virtual void setMarginsFont(const QFont &f);
  1502. //! Set the foreground colour of all margins to \a col. The default is
  1503. //! black.
  1504. //!
  1505. //! \sa setMarginsBackgroundColor()
  1506. virtual void setMarginsForegroundColor(const QColor &col);
  1507. //! Enables or disables, according to \a lnrs, the display of line numbers
  1508. //! in margin \a margin.
  1509. //!
  1510. //! \sa marginLineNumbers(), setMarginType(), SCI_SETMARGINTYPEN
  1511. virtual void setMarginLineNumbers(int margin, bool lnrs);
  1512. //! Sets the marker mask of margin \a margin to \a mask. Only those
  1513. //! markers whose bit is set in the mask are displayed in the margin.
  1514. //!
  1515. //! \sa marginMarkerMask(), QsciMarker, SCI_SETMARGINMASKN
  1516. virtual void setMarginMarkerMask(int margin, int mask);
  1517. //! Enables or disables, according to \a sens, the sensitivity of margin
  1518. //! \a margin to mouse clicks. If the user clicks in a sensitive margin
  1519. //! the marginClicked() signal is emitted.
  1520. //!
  1521. //! \sa marginSensitivity(), marginClicked(), SCI_SETMARGINSENSITIVEN
  1522. virtual void setMarginSensitivity(int margin, bool sens);
  1523. //! Sets the width of margin \a margin to \a width pixels. If the width of
  1524. //! a margin is 0 then it is not displayed.
  1525. //!
  1526. //! \sa marginWidth(), SCI_SETMARGINWIDTHN
  1527. virtual void setMarginWidth(int margin, int width);
  1528. //! Sets the width of margin \a margin so that it is wide enough to display
  1529. //! \a s in the current margin font.
  1530. //!
  1531. //! \sa marginWidth(), SCI_SETMARGINWIDTHN
  1532. virtual void setMarginWidth(int margin, const QString &s);
  1533. //! Sets the modified state of the text edit to \a m. Note that it is only
  1534. //! possible to clear the modified state (where \a m is false). Attempts
  1535. //! to set the modified state (where \a m is true) are ignored.
  1536. //!
  1537. //! \sa isModified(), modificationChanged()
  1538. virtual void setModified(bool m);
  1539. //! The widget's paper (ie. background) colour is set to \a c. This has no
  1540. //! effect if a language lexer has been set.
  1541. //!
  1542. //! \sa paper()
  1543. virtual void setPaper(const QColor &c);
  1544. //! Sets the read-only state of the text edit to \a ro.
  1545. //!
  1546. //! \sa isReadOnly()
  1547. virtual void setReadOnly(bool ro);
  1548. //! Sets the selection which starts at position \a indexFrom in line
  1549. //! \a lineFrom and ends at position \a indexTo in line \a lineTo. The
  1550. //! cursor is moved to position \a indexTo in \a lineTo.
  1551. //!
  1552. //! \sa getSelection()
  1553. virtual void setSelection(int lineFrom, int indexFrom, int lineTo,
  1554. int indexTo);
  1555. //! Sets the background colour, including the alpha component, of selected
  1556. //! text to \a col.
  1557. //!
  1558. //! \sa resetSelectionBackgroundColor(), setSelectionForegroundColor()
  1559. virtual void setSelectionBackgroundColor(const QColor &col);
  1560. //! Sets the foreground colour of selected text to \a col.
  1561. //!
  1562. //! \sa resetSelectionForegroundColor(), setSelectionBackgroundColor()
  1563. virtual void setSelectionForegroundColor(const QColor &col);
  1564. //! If \a indent is true then the tab key will indent a line rather than
  1565. //! insert a tab character.
  1566. //!
  1567. //! \sa tabIndents(), backspaceUnindents(), setBackspaceUnindents()
  1568. virtual void setTabIndents(bool indent);
  1569. //! Sets the tab width to \a width characters.
  1570. //!
  1571. //! \sa tabWidth()
  1572. virtual void setTabWidth(int width);
  1573. //! Replaces all of the current text with \a text. Note that the
  1574. //! undo/redo history is cleared by this function.
  1575. //!
  1576. //! \sa text()
  1577. virtual void setText(const QString &text);
  1578. //! Sets the current text encoding. If \a cp is true then UTF8 is used,
  1579. //! otherwise Latin1 is used.
  1580. //!
  1581. //! \sa isUtf8()
  1582. virtual void setUtf8(bool cp);
  1583. //! Sets the visibility of whitespace to mode \a mode. The default is that
  1584. //! whitespace is invisible.
  1585. //!
  1586. //! \sa whitespaceVisibility()
  1587. virtual void setWhitespaceVisibility(WhitespaceVisibility mode);
  1588. //! Sets the line wrap mode to \a mode. The default is that lines are not
  1589. //! wrapped.
  1590. //!
  1591. //! \sa wrapMode()
  1592. virtual void setWrapMode(WrapMode mode);
  1593. //! Undo the last change or sequence of changes.
  1594. //!
  1595. //! Scintilla has multiple level undo and redo. It will continue to record
  1596. //! undoable actions until memory runs out. Sequences of typing or
  1597. //! deleting are compressed into single actions to make it easier to undo
  1598. //! and redo at a sensible level of detail. Sequences of actions can be
  1599. //! combined into actions that are undone as a unit. These sequences occur
  1600. //! between calls to beginUndoAction() and endUndoAction(). These
  1601. //! sequences can be nested and only the top level sequences are undone as
  1602. //! units.
  1603. //!
  1604. //! \sa beginUndoAction(), endUndoAction(), isUndoAvailable()
  1605. virtual void undo();
  1606. //! Decreases the indentation of line \a line by an indentation width.
  1607. //!
  1608. //! \sa indent()
  1609. virtual void unindent(int line);
  1610. //! Zooms in on the text by by making the base font size \a range points
  1611. //! larger and recalculating all font sizes.
  1612. //!
  1613. //! \sa zoomOut(), zoomTo()
  1614. virtual void zoomIn(int range);
  1615. //! \overload
  1616. //!
  1617. //! Zooms in on the text by by making the base font size one point larger
  1618. //! and recalculating all font sizes.
  1619. virtual void zoomIn();
  1620. //! Zooms out on the text by by making the base font size \a range points
  1621. //! smaller and recalculating all font sizes.
  1622. //!
  1623. //! \sa zoomIn(), zoomTo()
  1624. virtual void zoomOut(int range);
  1625. //! \overload
  1626. //!
  1627. //! Zooms out on the text by by making the base font size one point larger
  1628. //! and recalculating all font sizes.
  1629. virtual void zoomOut();
  1630. //! Zooms the text by making the base font size \a size points and
  1631. //! recalculating all font sizes.
  1632. //!
  1633. //! \sa zoomIn(), zoomOut()
  1634. virtual void zoomTo(int size);
  1635. signals:
  1636. //! This signal is emitted whenever the cursor position changes. \a line
  1637. //! contains the line number and \a index contains the character index
  1638. //! within the line.
  1639. void cursorPositionChanged(int line, int index);
  1640. //! This signal is emitted whenever text is selected or de-selected.
  1641. //! \a yes is true if text has been selected and false if text has been
  1642. //! deselected. If \a yes is true then copy() can be used to copy the
  1643. //! selection to the clipboard. If \a yes is false then copy() does
  1644. //! nothing.
  1645. //!
  1646. //! \sa copy(), selectionChanged()
  1647. void copyAvailable(bool yes);
  1648. //! This signal is emitted whenever the user clicks on an indicator. \a
  1649. //! line is the number of the line where the user clicked. \a index is the
  1650. //! character index within the line. \a state is the state of the modifier
  1651. //! keys (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and
  1652. //! Qt::MetaModifier) when the user clicked.
  1653. //!
  1654. //! \sa indicatorReleased()
  1655. void indicatorClicked(int line, int index, Qt::KeyboardModifiers state);
  1656. //! This signal is emitted whenever the user releases the mouse on an
  1657. //! indicator. \a line is the number of the line where the user clicked.
  1658. //! \a index is the character index within the line. \a state is the state
  1659. //! of the modifier keys (Qt::ShiftModifier, Qt::ControlModifier,
  1660. //! Qt::AltModifer and Qt::MetaModifier) when the user released the mouse.
  1661. //!
  1662. //! \sa indicatorClicked()
  1663. void indicatorReleased(int line, int index, Qt::KeyboardModifiers state);
  1664. //! This signal is emitted whenever the number of lines of text changes.
  1665. void linesChanged();
  1666. //! This signal is emitted whenever the user clicks on a sensitive margin.
  1667. //! \a margin is the margin. \a line is the number of the line where the
  1668. //! user clicked. \a state is the state of the modifier keys
  1669. //! (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and
  1670. //! Qt::MetaModifier) when the user clicked.
  1671. //!
  1672. //! \sa marginSensitivity(), setMarginSensitivity()
  1673. void marginClicked(int margin, int line, Qt::KeyboardModifiers state);
  1674. //! This signal is emitted whenever the user right-clicks on a sensitive
  1675. //! margin. \a margin is the margin. \a line is the number of the line
  1676. //! where the user clicked. \a state is the state of the modifier keys
  1677. //! (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and
  1678. //! Qt::MetaModifier) when the user clicked.
  1679. //!
  1680. //! \sa marginSensitivity(), setMarginSensitivity()
  1681. void marginRightClicked(int margin, int line, Qt::KeyboardModifiers state);
  1682. //! This signal is emitted whenever the user attempts to modify read-only
  1683. //! text.
  1684. //!
  1685. //! \sa isReadOnly(), setReadOnly()
  1686. void modificationAttempted();
  1687. //! This signal is emitted whenever the modification state of the text
  1688. //! changes. \a m is true if the text has been modified.
  1689. //!
  1690. //! \sa isModified(), setModified()
  1691. void modificationChanged(bool m);
  1692. //! This signal is emitted whenever the selection changes.
  1693. //!
  1694. //! \sa copyAvailable()
  1695. void selectionChanged();
  1696. //! This signal is emitted whenever the text in the text edit changes.
  1697. void textChanged();
  1698. //! This signal is emitted when an item in a user defined list is activated
  1699. //! (selected). \a id is the list identifier. \a string is the text of
  1700. //! the item.
  1701. //!
  1702. //! \sa showUserList()
  1703. void userListActivated(int id, const QString &string);
  1704. protected:
  1705. //! \reimp
  1706. virtual bool event(QEvent *e);
  1707. //! \reimp
  1708. virtual void changeEvent(QEvent *e);
  1709. //! \reimp
  1710. virtual void contextMenuEvent(QContextMenuEvent *e);
  1711. private slots:
  1712. void handleCallTipClick(int dir);
  1713. void handleCharAdded(int charadded);
  1714. void handleIndicatorClick(int pos, int modifiers);
  1715. void handleIndicatorRelease(int pos, int modifiers);
  1716. void handleMarginClick(int pos, int margin, int modifiers);
  1717. void handleMarginRightClick(int pos, int margin, int modifiers);
  1718. void handleModified(int pos, int mtype, const char *text, int len,
  1719. int added, int line, int foldNow, int foldPrev, int token,
  1720. int annotationLinesAdded);
  1721. void handlePropertyChange(const char *prop, const char *val);
  1722. void handleSavePointReached();
  1723. void handleSavePointLeft();
  1724. void handleSelectionChanged(bool yes);
  1725. void handleAutoCompletionSelection();
  1726. void handleUserListSelection(const char *text, int id);
  1727. void handleStyleColorChange(const QColor &c, int style);
  1728. void handleStyleEolFillChange(bool eolfill, int style);
  1729. void handleStyleFontChange(const QFont &f, int style);
  1730. void handleStylePaperChange(const QColor &c, int style);
  1731. void handleUpdateUI(int updated);
  1732. void delete_selection();
  1733. private:
  1734. void detachLexer();
  1735. enum IndentState {
  1736. isNone,
  1737. isKeywordStart,
  1738. isBlockStart,
  1739. isBlockEnd
  1740. };
  1741. void maintainIndentation(char ch, long pos);
  1742. void autoIndentation(char ch, long pos);
  1743. void autoIndentLine(long pos, int line, int indent);
  1744. int blockIndent(int line);
  1745. IndentState getIndentState(int line);
  1746. bool rangeIsWhitespace(long spos, long epos);
  1747. int findStyledWord(const char *text, int style, const char *words);
  1748. void checkMarker(int &markerNumber);
  1749. void checkIndicator(int &indicatorNumber);
  1750. static void allocateId(int &id, unsigned &allocated, int min, int max);
  1751. int currentIndent() const;
  1752. int indentWidth() const;
  1753. bool doFind();
  1754. int simpleFind();
  1755. void foldClick(int lineClick, int bstate);
  1756. void foldChanged(int line, int levelNow, int levelPrev);
  1757. void foldExpand(int &line, bool doExpand, bool force = false,
  1758. int visLevels = 0, int level = -1);
  1759. void setFoldMarker(int marknr, int mark = SC_MARK_EMPTY);
  1760. void setLexerStyle(int style);
  1761. void setStylesFont(const QFont &f, int style);
  1762. void setEnabledColors(int style, QColor &fore, QColor &back);
  1763. void braceMatch();
  1764. bool findMatchingBrace(long &brace, long &other, BraceMatch mode);
  1765. long checkBrace(long pos, int brace_style, bool &colonMode);
  1766. void gotoMatchingBrace(bool select);
  1767. void startAutoCompletion(AutoCompletionSource acs, bool checkThresh,
  1768. bool choose_single);
  1769. int adjustedCallTipPosition(int ctshift) const;
  1770. bool getSeparator(int &pos) const;
  1771. QString getWord(int &pos) const;
  1772. char getCharacter(int &pos) const;
  1773. bool isStartChar(char ch) const;
  1774. bool ensureRW();
  1775. void insertAtPos(const QString &text, int pos);
  1776. static int mapModifiers(int modifiers);
  1777. QString wordAtPosition(int position) const;
  1778. ScintillaBytes styleText(const QList<QsciStyledText> &styled_text,
  1779. char **styles, int style_offset = 0);
  1780. struct FindState
  1781. {
  1782. enum Status
  1783. {
  1784. Finding,
  1785. FindingInSelection,
  1786. Idle
  1787. };
  1788. FindState() : status(Idle) {}
  1789. Status status;
  1790. QString expr;
  1791. bool wrap = false;
  1792. bool forward = false;
  1793. int flags = 0;
  1794. long startpos, startpos_orig = 0;
  1795. long endpos, endpos_orig = 0;
  1796. bool show = false;;
  1797. };
  1798. FindState findState;
  1799. unsigned allocatedMarkers;
  1800. unsigned allocatedIndicators;
  1801. int oldPos;
  1802. int ctPos;
  1803. bool selText;
  1804. FoldStyle fold;
  1805. int foldmargin;
  1806. bool autoInd;
  1807. BraceMatch braceMode;
  1808. AutoCompletionSource acSource;
  1809. int acThresh;
  1810. QStringList wseps;
  1811. const char *wchars;
  1812. CallTipsPosition call_tips_position;
  1813. CallTipsStyle call_tips_style;
  1814. int maxCallTips;
  1815. QStringList ct_entries;
  1816. int ct_cursor;
  1817. QList<int> ct_shifts;
  1818. AutoCompletionUseSingle use_single;
  1819. QPointer<QsciLexer> lex;
  1820. QsciCommandSet *stdCmds;
  1821. QsciDocument doc;
  1822. QColor nl_text_colour;
  1823. QColor nl_paper_colour;
  1824. QByteArray explicit_fillups;
  1825. bool fillups_enabled;
  1826. // The following allow QsciListBoxQt to distinguish between an
  1827. // auto-completion list and a user list, and to return the full selection
  1828. // of an auto-completion list.
  1829. friend class QsciListBoxQt;
  1830. QString acSelection;
  1831. bool isAutoCompletionList() const;
  1832. void set_shortcut(QAction *action, QsciCommand::Command cmd_id) const;
  1833. QsciScintilla(const QsciScintilla &);
  1834. QsciScintilla &operator=(const QsciScintilla &);
  1835. };
  1836. #endif