monaco.d.ts 191 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708
  1. /*!-----------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Type definitions for monaco-editor v0.14.2
  4. * Released under the MIT license
  5. *-----------------------------------------------------------*/
  6. /*---------------------------------------------------------------------------------------------
  7. * Copyright (c) Microsoft Corporation. All rights reserved.
  8. * Licensed under the MIT License. See License.txt in the project root for license information.
  9. *--------------------------------------------------------------------------------------------*/
  10. declare namespace monaco {
  11. export type Thenable<T> = PromiseLike<T>;
  12. export interface IDisposable {
  13. dispose(): void;
  14. }
  15. export interface IEvent<T> {
  16. (listener: (e: T) => any, thisArg?: any): IDisposable;
  17. }
  18. /**
  19. * A helper that allows to emit and listen to typed events
  20. */
  21. export class Emitter<T> {
  22. constructor();
  23. readonly event: IEvent<T>;
  24. fire(event?: T): void;
  25. dispose(): void;
  26. }
  27. export enum MarkerTag {
  28. Unnecessary = 1,
  29. }
  30. export enum MarkerSeverity {
  31. Hint = 1,
  32. Info = 2,
  33. Warning = 4,
  34. Error = 8,
  35. }
  36. export type TValueCallback<T = any> = (value: T | PromiseLike<T>) => void;
  37. export type ProgressCallback<TProgress = any> = (progress: TProgress) => void;
  38. export class Promise<T = any, TProgress = any> {
  39. constructor(
  40. executor: (
  41. resolve: (value: T | PromiseLike<T>) => void,
  42. reject: (reason: any) => void,
  43. progress: (progress: TProgress) => void) => void,
  44. oncancel?: () => void);
  45. public then<TResult1 = T, TResult2 = never>(
  46. onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
  47. onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,
  48. onprogress?: (progress: TProgress) => void): Promise<TResult1 | TResult2, TProgress>;
  49. public done(
  50. onfulfilled?: (value: T) => void,
  51. onrejected?: (reason: any) => void,
  52. onprogress?: (progress: TProgress) => void): void;
  53. public cancel(): void;
  54. public static as(value: null): Promise<null>;
  55. public static as(value: undefined): Promise<undefined>;
  56. public static as<T>(value: PromiseLike<T>): PromiseLike<T>;
  57. public static as<T, SomePromise extends PromiseLike<T>>(value: SomePromise): SomePromise;
  58. public static as<T>(value: T): Promise<T>;
  59. public static is(value: any): value is PromiseLike<any>;
  60. public static timeout(delay: number): Promise<void>;
  61. public static join<T1, T2>(promises: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
  62. public static join<T>(promises: (T | PromiseLike<T>)[]): Promise<T[]>;
  63. public static any<T>(promises: (T | PromiseLike<T>)[]): Promise<{ key: string; value: Promise<T>; }>;
  64. public static wrap<T>(value: T | PromiseLike<T>): Promise<T>;
  65. public static wrapError<T = never>(error: Error): Promise<T>;
  66. }
  67. export class CancellationTokenSource {
  68. readonly token: CancellationToken;
  69. cancel(): void;
  70. dispose(): void;
  71. }
  72. export interface CancellationToken {
  73. readonly isCancellationRequested: boolean;
  74. /**
  75. * An event emitted when cancellation is requested
  76. * @event
  77. */
  78. readonly onCancellationRequested: IEvent<any>;
  79. }
  80. /**
  81. * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986.
  82. * This class is a simple parser which creates the basic component paths
  83. * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
  84. * and encoding.
  85. *
  86. * foo://example.com:8042/over/there?name=ferret#nose
  87. * \_/ \______________/\_________/ \_________/ \__/
  88. * | | | | |
  89. * scheme authority path query fragment
  90. * | _____________________|__
  91. * / \ / \
  92. * urn:example:animal:ferret:nose
  93. *
  94. *
  95. */
  96. export class Uri implements UriComponents {
  97. static isUri(thing: any): thing is Uri;
  98. /**
  99. * scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'.
  100. * The part before the first colon.
  101. */
  102. readonly scheme: string;
  103. /**
  104. * authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'.
  105. * The part between the first double slashes and the next slash.
  106. */
  107. readonly authority: string;
  108. /**
  109. * path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'.
  110. */
  111. readonly path: string;
  112. /**
  113. * query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'.
  114. */
  115. readonly query: string;
  116. /**
  117. * fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'.
  118. */
  119. readonly fragment: string;
  120. /**
  121. * Returns a string representing the corresponding file system path of this Uri.
  122. * Will handle UNC paths and normalize windows drive letters to lower-case. Also
  123. * uses the platform specific path separator. Will *not* validate the path for
  124. * invalid characters and semantics. Will *not* look at the scheme of this Uri.
  125. */
  126. readonly fsPath: string;
  127. with(change: {
  128. scheme?: string;
  129. authority?: string;
  130. path?: string;
  131. query?: string;
  132. fragment?: string;
  133. }): Uri;
  134. static parse(value: string): Uri;
  135. static file(path: string): Uri;
  136. static from(components: {
  137. scheme?: string;
  138. authority?: string;
  139. path?: string;
  140. query?: string;
  141. fragment?: string;
  142. }): Uri;
  143. /**
  144. *
  145. * @param skipEncoding Do not encode the result, default is `false`
  146. */
  147. toString(skipEncoding?: boolean): string;
  148. toJSON(): object;
  149. static revive(data: UriComponents | any): Uri;
  150. }
  151. export interface UriComponents {
  152. scheme: string;
  153. authority: string;
  154. path: string;
  155. query: string;
  156. fragment: string;
  157. }
  158. /**
  159. * Virtual Key Codes, the value does not hold any inherent meaning.
  160. * Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  161. * But these are "more general", as they should work across browsers & OS`s.
  162. */
  163. export enum KeyCode {
  164. /**
  165. * Placed first to cover the 0 value of the enum.
  166. */
  167. Unknown = 0,
  168. Backspace = 1,
  169. Tab = 2,
  170. Enter = 3,
  171. Shift = 4,
  172. Ctrl = 5,
  173. Alt = 6,
  174. PauseBreak = 7,
  175. CapsLock = 8,
  176. Escape = 9,
  177. Space = 10,
  178. PageUp = 11,
  179. PageDown = 12,
  180. End = 13,
  181. Home = 14,
  182. LeftArrow = 15,
  183. UpArrow = 16,
  184. RightArrow = 17,
  185. DownArrow = 18,
  186. Insert = 19,
  187. Delete = 20,
  188. KEY_0 = 21,
  189. KEY_1 = 22,
  190. KEY_2 = 23,
  191. KEY_3 = 24,
  192. KEY_4 = 25,
  193. KEY_5 = 26,
  194. KEY_6 = 27,
  195. KEY_7 = 28,
  196. KEY_8 = 29,
  197. KEY_9 = 30,
  198. KEY_A = 31,
  199. KEY_B = 32,
  200. KEY_C = 33,
  201. KEY_D = 34,
  202. KEY_E = 35,
  203. KEY_F = 36,
  204. KEY_G = 37,
  205. KEY_H = 38,
  206. KEY_I = 39,
  207. KEY_J = 40,
  208. KEY_K = 41,
  209. KEY_L = 42,
  210. KEY_M = 43,
  211. KEY_N = 44,
  212. KEY_O = 45,
  213. KEY_P = 46,
  214. KEY_Q = 47,
  215. KEY_R = 48,
  216. KEY_S = 49,
  217. KEY_T = 50,
  218. KEY_U = 51,
  219. KEY_V = 52,
  220. KEY_W = 53,
  221. KEY_X = 54,
  222. KEY_Y = 55,
  223. KEY_Z = 56,
  224. Meta = 57,
  225. ContextMenu = 58,
  226. F1 = 59,
  227. F2 = 60,
  228. F3 = 61,
  229. F4 = 62,
  230. F5 = 63,
  231. F6 = 64,
  232. F7 = 65,
  233. F8 = 66,
  234. F9 = 67,
  235. F10 = 68,
  236. F11 = 69,
  237. F12 = 70,
  238. F13 = 71,
  239. F14 = 72,
  240. F15 = 73,
  241. F16 = 74,
  242. F17 = 75,
  243. F18 = 76,
  244. F19 = 77,
  245. NumLock = 78,
  246. ScrollLock = 79,
  247. /**
  248. * Used for miscellaneous characters; it can vary by keyboard.
  249. * For the US standard keyboard, the ';:' key
  250. */
  251. US_SEMICOLON = 80,
  252. /**
  253. * For any country/region, the '+' key
  254. * For the US standard keyboard, the '=+' key
  255. */
  256. US_EQUAL = 81,
  257. /**
  258. * For any country/region, the ',' key
  259. * For the US standard keyboard, the ',<' key
  260. */
  261. US_COMMA = 82,
  262. /**
  263. * For any country/region, the '-' key
  264. * For the US standard keyboard, the '-_' key
  265. */
  266. US_MINUS = 83,
  267. /**
  268. * For any country/region, the '.' key
  269. * For the US standard keyboard, the '.>' key
  270. */
  271. US_DOT = 84,
  272. /**
  273. * Used for miscellaneous characters; it can vary by keyboard.
  274. * For the US standard keyboard, the '/?' key
  275. */
  276. US_SLASH = 85,
  277. /**
  278. * Used for miscellaneous characters; it can vary by keyboard.
  279. * For the US standard keyboard, the '`~' key
  280. */
  281. US_BACKTICK = 86,
  282. /**
  283. * Used for miscellaneous characters; it can vary by keyboard.
  284. * For the US standard keyboard, the '[{' key
  285. */
  286. US_OPEN_SQUARE_BRACKET = 87,
  287. /**
  288. * Used for miscellaneous characters; it can vary by keyboard.
  289. * For the US standard keyboard, the '\|' key
  290. */
  291. US_BACKSLASH = 88,
  292. /**
  293. * Used for miscellaneous characters; it can vary by keyboard.
  294. * For the US standard keyboard, the ']}' key
  295. */
  296. US_CLOSE_SQUARE_BRACKET = 89,
  297. /**
  298. * Used for miscellaneous characters; it can vary by keyboard.
  299. * For the US standard keyboard, the ''"' key
  300. */
  301. US_QUOTE = 90,
  302. /**
  303. * Used for miscellaneous characters; it can vary by keyboard.
  304. */
  305. OEM_8 = 91,
  306. /**
  307. * Either the angle bracket key or the backslash key on the RT 102-key keyboard.
  308. */
  309. OEM_102 = 92,
  310. NUMPAD_0 = 93,
  311. NUMPAD_1 = 94,
  312. NUMPAD_2 = 95,
  313. NUMPAD_3 = 96,
  314. NUMPAD_4 = 97,
  315. NUMPAD_5 = 98,
  316. NUMPAD_6 = 99,
  317. NUMPAD_7 = 100,
  318. NUMPAD_8 = 101,
  319. NUMPAD_9 = 102,
  320. NUMPAD_MULTIPLY = 103,
  321. NUMPAD_ADD = 104,
  322. NUMPAD_SEPARATOR = 105,
  323. NUMPAD_SUBTRACT = 106,
  324. NUMPAD_DECIMAL = 107,
  325. NUMPAD_DIVIDE = 108,
  326. /**
  327. * Cover all key codes when IME is processing input.
  328. */
  329. KEY_IN_COMPOSITION = 109,
  330. ABNT_C1 = 110,
  331. ABNT_C2 = 111,
  332. /**
  333. * Placed last to cover the length of the enum.
  334. * Please do not depend on this value!
  335. */
  336. MAX_VALUE = 112
  337. }
  338. export class KeyMod {
  339. static readonly CtrlCmd: number;
  340. static readonly Shift: number;
  341. static readonly Alt: number;
  342. static readonly WinCtrl: number;
  343. static chord(firstPart: number, secondPart: number): number;
  344. }
  345. export interface IMarkdownString {
  346. value: string;
  347. isTrusted?: boolean;
  348. }
  349. export interface IKeyboardEvent {
  350. readonly browserEvent: KeyboardEvent;
  351. readonly target: HTMLElement;
  352. readonly ctrlKey: boolean;
  353. readonly shiftKey: boolean;
  354. readonly altKey: boolean;
  355. readonly metaKey: boolean;
  356. readonly keyCode: KeyCode;
  357. readonly code: string;
  358. equals(keybinding: number): boolean;
  359. preventDefault(): void;
  360. stopPropagation(): void;
  361. }
  362. export interface IMouseEvent {
  363. readonly browserEvent: MouseEvent;
  364. readonly leftButton: boolean;
  365. readonly middleButton: boolean;
  366. readonly rightButton: boolean;
  367. readonly target: HTMLElement;
  368. readonly detail: number;
  369. readonly posx: number;
  370. readonly posy: number;
  371. readonly ctrlKey: boolean;
  372. readonly shiftKey: boolean;
  373. readonly altKey: boolean;
  374. readonly metaKey: boolean;
  375. readonly timestamp: number;
  376. preventDefault(): void;
  377. stopPropagation(): void;
  378. }
  379. export interface IScrollEvent {
  380. readonly scrollTop: number;
  381. readonly scrollLeft: number;
  382. readonly scrollWidth: number;
  383. readonly scrollHeight: number;
  384. readonly scrollTopChanged: boolean;
  385. readonly scrollLeftChanged: boolean;
  386. readonly scrollWidthChanged: boolean;
  387. readonly scrollHeightChanged: boolean;
  388. }
  389. /**
  390. * A position in the editor. This interface is suitable for serialization.
  391. */
  392. export interface IPosition {
  393. /**
  394. * line number (starts at 1)
  395. */
  396. readonly lineNumber: number;
  397. /**
  398. * column (the first character in a line is between column 1 and column 2)
  399. */
  400. readonly column: number;
  401. }
  402. /**
  403. * A position in the editor.
  404. */
  405. export class Position {
  406. /**
  407. * line number (starts at 1)
  408. */
  409. readonly lineNumber: number;
  410. /**
  411. * column (the first character in a line is between column 1 and column 2)
  412. */
  413. readonly column: number;
  414. constructor(lineNumber: number, column: number);
  415. /**
  416. * Test if this position equals other position
  417. */
  418. equals(other: IPosition): boolean;
  419. /**
  420. * Test if position `a` equals position `b`
  421. */
  422. static equals(a: IPosition, b: IPosition): boolean;
  423. /**
  424. * Test if this position is before other position.
  425. * If the two positions are equal, the result will be false.
  426. */
  427. isBefore(other: IPosition): boolean;
  428. /**
  429. * Test if position `a` is before position `b`.
  430. * If the two positions are equal, the result will be false.
  431. */
  432. static isBefore(a: IPosition, b: IPosition): boolean;
  433. /**
  434. * Test if this position is before other position.
  435. * If the two positions are equal, the result will be true.
  436. */
  437. isBeforeOrEqual(other: IPosition): boolean;
  438. /**
  439. * Test if position `a` is before position `b`.
  440. * If the two positions are equal, the result will be true.
  441. */
  442. static isBeforeOrEqual(a: IPosition, b: IPosition): boolean;
  443. /**
  444. * A function that compares positions, useful for sorting
  445. */
  446. static compare(a: IPosition, b: IPosition): number;
  447. /**
  448. * Clone this position.
  449. */
  450. clone(): Position;
  451. /**
  452. * Convert to a human-readable representation.
  453. */
  454. toString(): string;
  455. /**
  456. * Create a `Position` from an `IPosition`.
  457. */
  458. static lift(pos: IPosition): Position;
  459. /**
  460. * Test if `obj` is an `IPosition`.
  461. */
  462. static isIPosition(obj: any): obj is IPosition;
  463. }
  464. /**
  465. * A range in the editor. This interface is suitable for serialization.
  466. */
  467. export interface IRange {
  468. /**
  469. * Line number on which the range starts (starts at 1).
  470. */
  471. readonly startLineNumber: number;
  472. /**
  473. * Column on which the range starts in line `startLineNumber` (starts at 1).
  474. */
  475. readonly startColumn: number;
  476. /**
  477. * Line number on which the range ends.
  478. */
  479. readonly endLineNumber: number;
  480. /**
  481. * Column on which the range ends in line `endLineNumber`.
  482. */
  483. readonly endColumn: number;
  484. }
  485. /**
  486. * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
  487. */
  488. export class Range {
  489. /**
  490. * Line number on which the range starts (starts at 1).
  491. */
  492. readonly startLineNumber: number;
  493. /**
  494. * Column on which the range starts in line `startLineNumber` (starts at 1).
  495. */
  496. readonly startColumn: number;
  497. /**
  498. * Line number on which the range ends.
  499. */
  500. readonly endLineNumber: number;
  501. /**
  502. * Column on which the range ends in line `endLineNumber`.
  503. */
  504. readonly endColumn: number;
  505. constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number);
  506. /**
  507. * Test if this range is empty.
  508. */
  509. isEmpty(): boolean;
  510. /**
  511. * Test if `range` is empty.
  512. */
  513. static isEmpty(range: IRange): boolean;
  514. /**
  515. * Test if position is in this range. If the position is at the edges, will return true.
  516. */
  517. containsPosition(position: IPosition): boolean;
  518. /**
  519. * Test if `position` is in `range`. If the position is at the edges, will return true.
  520. */
  521. static containsPosition(range: IRange, position: IPosition): boolean;
  522. /**
  523. * Test if range is in this range. If the range is equal to this range, will return true.
  524. */
  525. containsRange(range: IRange): boolean;
  526. /**
  527. * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
  528. */
  529. static containsRange(range: IRange, otherRange: IRange): boolean;
  530. /**
  531. * A reunion of the two ranges.
  532. * The smallest position will be used as the start point, and the largest one as the end point.
  533. */
  534. plusRange(range: IRange): Range;
  535. /**
  536. * A reunion of the two ranges.
  537. * The smallest position will be used as the start point, and the largest one as the end point.
  538. */
  539. static plusRange(a: IRange, b: IRange): Range;
  540. /**
  541. * A intersection of the two ranges.
  542. */
  543. intersectRanges(range: IRange): Range;
  544. /**
  545. * A intersection of the two ranges.
  546. */
  547. static intersectRanges(a: IRange, b: IRange): Range;
  548. /**
  549. * Test if this range equals other.
  550. */
  551. equalsRange(other: IRange): boolean;
  552. /**
  553. * Test if range `a` equals `b`.
  554. */
  555. static equalsRange(a: IRange, b: IRange): boolean;
  556. /**
  557. * Return the end position (which will be after or equal to the start position)
  558. */
  559. getEndPosition(): Position;
  560. /**
  561. * Return the start position (which will be before or equal to the end position)
  562. */
  563. getStartPosition(): Position;
  564. /**
  565. * Transform to a user presentable string representation.
  566. */
  567. toString(): string;
  568. /**
  569. * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
  570. */
  571. setEndPosition(endLineNumber: number, endColumn: number): Range;
  572. /**
  573. * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
  574. */
  575. setStartPosition(startLineNumber: number, startColumn: number): Range;
  576. /**
  577. * Create a new empty range using this range's start position.
  578. */
  579. collapseToStart(): Range;
  580. /**
  581. * Create a new empty range using this range's start position.
  582. */
  583. static collapseToStart(range: IRange): Range;
  584. static fromPositions(start: IPosition, end?: IPosition): Range;
  585. /**
  586. * Create a `Range` from an `IRange`.
  587. */
  588. static lift(range: IRange): Range;
  589. /**
  590. * Test if `obj` is an `IRange`.
  591. */
  592. static isIRange(obj: any): obj is IRange;
  593. /**
  594. * Test if the two ranges are touching in any way.
  595. */
  596. static areIntersectingOrTouching(a: IRange, b: IRange): boolean;
  597. /**
  598. * Test if the two ranges are intersecting. If the ranges are touching it returns true.
  599. */
  600. static areIntersecting(a: IRange, b: IRange): boolean;
  601. /**
  602. * A function that compares ranges, useful for sorting ranges
  603. * It will first compare ranges on the startPosition and then on the endPosition
  604. */
  605. static compareRangesUsingStarts(a: IRange, b: IRange): number;
  606. /**
  607. * A function that compares ranges, useful for sorting ranges
  608. * It will first compare ranges on the endPosition and then on the startPosition
  609. */
  610. static compareRangesUsingEnds(a: IRange, b: IRange): number;
  611. /**
  612. * Test if the range spans multiple lines.
  613. */
  614. static spansMultipleLines(range: IRange): boolean;
  615. }
  616. /**
  617. * A selection in the editor.
  618. * The selection is a range that has an orientation.
  619. */
  620. export interface ISelection {
  621. /**
  622. * The line number on which the selection has started.
  623. */
  624. readonly selectionStartLineNumber: number;
  625. /**
  626. * The column on `selectionStartLineNumber` where the selection has started.
  627. */
  628. readonly selectionStartColumn: number;
  629. /**
  630. * The line number on which the selection has ended.
  631. */
  632. readonly positionLineNumber: number;
  633. /**
  634. * The column on `positionLineNumber` where the selection has ended.
  635. */
  636. readonly positionColumn: number;
  637. }
  638. /**
  639. * A selection in the editor.
  640. * The selection is a range that has an orientation.
  641. */
  642. export class Selection extends Range {
  643. /**
  644. * The line number on which the selection has started.
  645. */
  646. readonly selectionStartLineNumber: number;
  647. /**
  648. * The column on `selectionStartLineNumber` where the selection has started.
  649. */
  650. readonly selectionStartColumn: number;
  651. /**
  652. * The line number on which the selection has ended.
  653. */
  654. readonly positionLineNumber: number;
  655. /**
  656. * The column on `positionLineNumber` where the selection has ended.
  657. */
  658. readonly positionColumn: number;
  659. constructor(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number);
  660. /**
  661. * Clone this selection.
  662. */
  663. clone(): Selection;
  664. /**
  665. * Transform to a human-readable representation.
  666. */
  667. toString(): string;
  668. /**
  669. * Test if equals other selection.
  670. */
  671. equalsSelection(other: ISelection): boolean;
  672. /**
  673. * Test if the two selections are equal.
  674. */
  675. static selectionsEqual(a: ISelection, b: ISelection): boolean;
  676. /**
  677. * Get directions (LTR or RTL).
  678. */
  679. getDirection(): SelectionDirection;
  680. /**
  681. * Create a new selection with a different `positionLineNumber` and `positionColumn`.
  682. */
  683. setEndPosition(endLineNumber: number, endColumn: number): Selection;
  684. /**
  685. * Get the position at `positionLineNumber` and `positionColumn`.
  686. */
  687. getPosition(): Position;
  688. /**
  689. * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`.
  690. */
  691. setStartPosition(startLineNumber: number, startColumn: number): Selection;
  692. /**
  693. * Create a `Selection` from one or two positions
  694. */
  695. static fromPositions(start: IPosition, end?: IPosition): Selection;
  696. /**
  697. * Create a `Selection` from an `ISelection`.
  698. */
  699. static liftSelection(sel: ISelection): Selection;
  700. /**
  701. * `a` equals `b`.
  702. */
  703. static selectionsArrEqual(a: ISelection[], b: ISelection[]): boolean;
  704. /**
  705. * Test if `obj` is an `ISelection`.
  706. */
  707. static isISelection(obj: any): obj is ISelection;
  708. /**
  709. * Create with a direction.
  710. */
  711. static createWithDirection(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, direction: SelectionDirection): Selection;
  712. }
  713. /**
  714. * The direction of a selection.
  715. */
  716. export enum SelectionDirection {
  717. /**
  718. * The selection starts above where it ends.
  719. */
  720. LTR = 0,
  721. /**
  722. * The selection starts below where it ends.
  723. */
  724. RTL = 1
  725. }
  726. export class Token {
  727. _tokenBrand: void;
  728. readonly offset: number;
  729. readonly type: string;
  730. readonly language: string;
  731. constructor(offset: number, type: string, language: string);
  732. toString(): string;
  733. }
  734. }
  735. declare namespace monaco.editor {
  736. /**
  737. * Create a new editor under `domElement`.
  738. * `domElement` should be empty (not contain other dom nodes).
  739. * The editor will read the size of `domElement`.
  740. */
  741. export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor;
  742. /**
  743. * Emitted when an editor is created.
  744. * Creating a diff editor might cause this listener to be invoked with the two editors.
  745. * @event
  746. */
  747. export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void): IDisposable;
  748. /**
  749. * Create a new diff editor under `domElement`.
  750. * `domElement` should be empty (not contain other dom nodes).
  751. * The editor will read the size of `domElement`.
  752. */
  753. export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneDiffEditor;
  754. export interface IDiffNavigator {
  755. canNavigate(): boolean;
  756. next(): void;
  757. previous(): void;
  758. dispose(): void;
  759. }
  760. export interface IDiffNavigatorOptions {
  761. readonly followsCaret?: boolean;
  762. readonly ignoreCharChanges?: boolean;
  763. readonly alwaysRevealFirst?: boolean;
  764. }
  765. export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator;
  766. /**
  767. * Create a new editor model.
  768. * You can specify the language that should be set for this model or let the language be inferred from the `uri`.
  769. */
  770. export function createModel(value: string, language?: string, uri?: Uri): ITextModel;
  771. /**
  772. * Change the language for a model.
  773. */
  774. export function setModelLanguage(model: ITextModel, languageId: string): void;
  775. /**
  776. * Set the markers for a model.
  777. */
  778. export function setModelMarkers(model: ITextModel, owner: string, markers: IMarkerData[]): void;
  779. /**
  780. * Get markers for owner and/or resource
  781. * @returns {IMarker[]} list of markers
  782. * @param filter
  783. */
  784. export function getModelMarkers(filter: {
  785. owner?: string;
  786. resource?: Uri;
  787. take?: number;
  788. }): IMarker[];
  789. /**
  790. * Get the model that has `uri` if it exists.
  791. */
  792. export function getModel(uri: Uri): ITextModel;
  793. /**
  794. * Get all the created models.
  795. */
  796. export function getModels(): ITextModel[];
  797. /**
  798. * Emitted when a model is created.
  799. * @event
  800. */
  801. export function onDidCreateModel(listener: (model: ITextModel) => void): IDisposable;
  802. /**
  803. * Emitted right before a model is disposed.
  804. * @event
  805. */
  806. export function onWillDisposeModel(listener: (model: ITextModel) => void): IDisposable;
  807. /**
  808. * Emitted when a different language is set to a model.
  809. * @event
  810. */
  811. export function onDidChangeModelLanguage(listener: (e: {
  812. readonly model: ITextModel;
  813. readonly oldLanguage: string;
  814. }) => void): IDisposable;
  815. /**
  816. * Create a new web worker that has model syncing capabilities built in.
  817. * Specify an AMD module to load that will `create` an object that will be proxied.
  818. */
  819. export function createWebWorker<T>(opts: IWebWorkerOptions): MonacoWebWorker<T>;
  820. /**
  821. * Colorize the contents of `domNode` using attribute `data-lang`.
  822. */
  823. export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise<void>;
  824. /**
  825. * Colorize `text` using language `languageId`.
  826. */
  827. export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise<string>;
  828. /**
  829. * Colorize a line in a model.
  830. */
  831. export function colorizeModelLine(model: ITextModel, lineNumber: number, tabSize?: number): string;
  832. /**
  833. * Tokenize `text` using language `languageId`
  834. */
  835. export function tokenize(text: string, languageId: string): Token[][];
  836. /**
  837. * Define a new theme or updte an existing theme.
  838. */
  839. export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void;
  840. /**
  841. * Switches to a theme.
  842. */
  843. export function setTheme(themeName: string): void;
  844. export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black';
  845. export interface IStandaloneThemeData {
  846. base: BuiltinTheme;
  847. inherit: boolean;
  848. rules: ITokenThemeRule[];
  849. encodedTokensColors?: string[];
  850. colors: IColors;
  851. }
  852. export type IColors = {
  853. [colorId: string]: string;
  854. };
  855. export interface ITokenThemeRule {
  856. token: string;
  857. foreground?: string;
  858. background?: string;
  859. fontStyle?: string;
  860. }
  861. /**
  862. * A web worker that can provide a proxy to an arbitrary file.
  863. */
  864. export interface MonacoWebWorker<T> {
  865. /**
  866. * Terminate the web worker, thus invalidating the returned proxy.
  867. */
  868. dispose(): void;
  869. /**
  870. * Get a proxy to the arbitrary loaded code.
  871. */
  872. getProxy(): Promise<T>;
  873. /**
  874. * Synchronize (send) the models at `resources` to the web worker,
  875. * making them available in the monaco.worker.getMirrorModels().
  876. */
  877. withSyncedResources(resources: Uri[]): Promise<T>;
  878. }
  879. export interface IWebWorkerOptions {
  880. /**
  881. * The AMD moduleId to load.
  882. * It should export a function `create` that should return the exported proxy.
  883. */
  884. moduleId: string;
  885. /**
  886. * The data to send over when calling create on the module.
  887. */
  888. createData?: any;
  889. /**
  890. * A label to be used to identify the web worker for debugging purposes.
  891. */
  892. label?: string;
  893. }
  894. /**
  895. * Description of an action contribution
  896. */
  897. export interface IActionDescriptor {
  898. /**
  899. * An unique identifier of the contributed action.
  900. */
  901. id: string;
  902. /**
  903. * A label of the action that will be presented to the user.
  904. */
  905. label: string;
  906. /**
  907. * Precondition rule.
  908. */
  909. precondition?: string;
  910. /**
  911. * An array of keybindings for the action.
  912. */
  913. keybindings?: number[];
  914. /**
  915. * The keybinding rule (condition on top of precondition).
  916. */
  917. keybindingContext?: string;
  918. /**
  919. * Control if the action should show up in the context menu and where.
  920. * The context menu of the editor has these default:
  921. * navigation - The navigation group comes first in all cases.
  922. * 1_modification - This group comes next and contains commands that modify your code.
  923. * 9_cutcopypaste - The last default group with the basic editing commands.
  924. * You can also create your own group.
  925. * Defaults to null (don't show in context menu).
  926. */
  927. contextMenuGroupId?: string;
  928. /**
  929. * Control the order in the context menu group.
  930. */
  931. contextMenuOrder?: number;
  932. /**
  933. * Method that will be executed when the action is triggered.
  934. * @param editor The editor instance is passed in as a convinience
  935. */
  936. run(editor: ICodeEditor): void | Promise<void>;
  937. }
  938. /**
  939. * The options to create an editor.
  940. */
  941. export interface IEditorConstructionOptions extends IEditorOptions {
  942. /**
  943. * The initial model associated with this code editor.
  944. */
  945. model?: ITextModel | null;
  946. /**
  947. * The initial value of the auto created model in the editor.
  948. * To not create automatically a model, use `model: null`.
  949. */
  950. value?: string;
  951. /**
  952. * The initial language of the auto created model in the editor.
  953. * To not create automatically a model, use `model: null`.
  954. */
  955. language?: string;
  956. /**
  957. * Initial theme to be used for rendering.
  958. * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
  959. * You can create custom themes via `monaco.editor.defineTheme`.
  960. * To switch a theme, use `monaco.editor.setTheme`
  961. */
  962. theme?: string;
  963. /**
  964. * An URL to open when Ctrl+H (Windows and Linux) or Cmd+H (OSX) is pressed in
  965. * the accessibility help dialog in the editor.
  966. *
  967. * Defaults to "https://go.microsoft.com/fwlink/?linkid=852450"
  968. */
  969. accessibilityHelpUrl?: string;
  970. }
  971. /**
  972. * The options to create a diff editor.
  973. */
  974. export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
  975. /**
  976. * Initial theme to be used for rendering.
  977. * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
  978. * You can create custom themes via `monaco.editor.defineTheme`.
  979. * To switch a theme, use `monaco.editor.setTheme`
  980. */
  981. theme?: string;
  982. }
  983. export interface IStandaloneCodeEditor extends ICodeEditor {
  984. addCommand(keybinding: number, handler: ICommandHandler, context: string): string;
  985. createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
  986. addAction(descriptor: IActionDescriptor): IDisposable;
  987. }
  988. export interface IStandaloneDiffEditor extends IDiffEditor {
  989. addCommand(keybinding: number, handler: ICommandHandler, context: string): string;
  990. createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
  991. addAction(descriptor: IActionDescriptor): IDisposable;
  992. getOriginalEditor(): IStandaloneCodeEditor;
  993. getModifiedEditor(): IStandaloneCodeEditor;
  994. }
  995. export interface ICommandHandler {
  996. (...args: any[]): void;
  997. }
  998. export interface IContextKey<T> {
  999. set(value: T): void;
  1000. reset(): void;
  1001. get(): T;
  1002. }
  1003. export interface IEditorOverrideServices {
  1004. [index: string]: any;
  1005. }
  1006. export interface IMarker {
  1007. owner: string;
  1008. resource: Uri;
  1009. severity: MarkerSeverity;
  1010. code?: string;
  1011. message: string;
  1012. source?: string;
  1013. startLineNumber: number;
  1014. startColumn: number;
  1015. endLineNumber: number;
  1016. endColumn: number;
  1017. relatedInformation?: IRelatedInformation[];
  1018. tags?: MarkerTag[];
  1019. }
  1020. /**
  1021. * A structure defining a problem/warning/etc.
  1022. */
  1023. export interface IMarkerData {
  1024. code?: string;
  1025. severity: MarkerSeverity;
  1026. message: string;
  1027. source?: string;
  1028. startLineNumber: number;
  1029. startColumn: number;
  1030. endLineNumber: number;
  1031. endColumn: number;
  1032. relatedInformation?: IRelatedInformation[];
  1033. tags?: MarkerTag[];
  1034. }
  1035. /**
  1036. *
  1037. */
  1038. export interface IRelatedInformation {
  1039. resource: Uri;
  1040. message: string;
  1041. startLineNumber: number;
  1042. startColumn: number;
  1043. endLineNumber: number;
  1044. endColumn: number;
  1045. }
  1046. export interface IColorizerOptions {
  1047. tabSize?: number;
  1048. }
  1049. export interface IColorizerElementOptions extends IColorizerOptions {
  1050. theme?: string;
  1051. mimeType?: string;
  1052. }
  1053. export enum ScrollbarVisibility {
  1054. Auto = 1,
  1055. Hidden = 2,
  1056. Visible = 3
  1057. }
  1058. export interface ThemeColor {
  1059. id: string;
  1060. }
  1061. /**
  1062. * Vertical Lane in the overview ruler of the editor.
  1063. */
  1064. export enum OverviewRulerLane {
  1065. Left = 1,
  1066. Center = 2,
  1067. Right = 4,
  1068. Full = 7
  1069. }
  1070. /**
  1071. * Options for rendering a model decoration in the overview ruler.
  1072. */
  1073. export interface IModelDecorationOverviewRulerOptions {
  1074. /**
  1075. * CSS color to render in the overview ruler.
  1076. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
  1077. */
  1078. color: string | ThemeColor;
  1079. /**
  1080. * CSS color to render in the overview ruler.
  1081. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
  1082. */
  1083. darkColor: string | ThemeColor;
  1084. /**
  1085. * CSS color to render in the overview ruler.
  1086. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
  1087. */
  1088. hcColor?: string | ThemeColor;
  1089. /**
  1090. * The position in the overview ruler.
  1091. */
  1092. position: OverviewRulerLane;
  1093. }
  1094. /**
  1095. * Options for a model decoration.
  1096. */
  1097. export interface IModelDecorationOptions {
  1098. /**
  1099. * Customize the growing behavior of the decoration when typing at the edges of the decoration.
  1100. * Defaults to TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges
  1101. */
  1102. stickiness?: TrackedRangeStickiness;
  1103. /**
  1104. * CSS class name describing the decoration.
  1105. */
  1106. className?: string;
  1107. /**
  1108. * Message to be rendered when hovering over the glyph margin decoration.
  1109. */
  1110. glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[];
  1111. /**
  1112. * Array of MarkdownString to render as the decoration message.
  1113. */
  1114. hoverMessage?: IMarkdownString | IMarkdownString[];
  1115. /**
  1116. * Should the decoration expand to encompass a whole line.
  1117. */
  1118. isWholeLine?: boolean;
  1119. /**
  1120. * Specifies the stack order of a decoration.
  1121. * A decoration with greater stack order is always in front of a decoration with a lower stack order.
  1122. */
  1123. zIndex?: number;
  1124. /**
  1125. * If set, render this decoration in the overview ruler.
  1126. */
  1127. overviewRuler?: IModelDecorationOverviewRulerOptions;
  1128. /**
  1129. * If set, the decoration will be rendered in the glyph margin with this CSS class name.
  1130. */
  1131. glyphMarginClassName?: string;
  1132. /**
  1133. * If set, the decoration will be rendered in the lines decorations with this CSS class name.
  1134. */
  1135. linesDecorationsClassName?: string;
  1136. /**
  1137. * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name.
  1138. */
  1139. marginClassName?: string;
  1140. /**
  1141. * If set, the decoration will be rendered inline with the text with this CSS class name.
  1142. * Please use this only for CSS rules that must impact the text. For example, use `className`
  1143. * to have a background color decoration.
  1144. */
  1145. inlineClassName?: string;
  1146. /**
  1147. * If there is an `inlineClassName` which affects letter spacing.
  1148. */
  1149. inlineClassNameAffectsLetterSpacing?: boolean;
  1150. /**
  1151. * If set, the decoration will be rendered before the text with this CSS class name.
  1152. */
  1153. beforeContentClassName?: string;
  1154. /**
  1155. * If set, the decoration will be rendered after the text with this CSS class name.
  1156. */
  1157. afterContentClassName?: string;
  1158. }
  1159. /**
  1160. * New model decorations.
  1161. */
  1162. export interface IModelDeltaDecoration {
  1163. /**
  1164. * Range that this decoration covers.
  1165. */
  1166. range: IRange;
  1167. /**
  1168. * Options associated with this decoration.
  1169. */
  1170. options: IModelDecorationOptions;
  1171. }
  1172. /**
  1173. * A decoration in the model.
  1174. */
  1175. export interface IModelDecoration {
  1176. /**
  1177. * Identifier for a decoration.
  1178. */
  1179. readonly id: string;
  1180. /**
  1181. * Identifier for a decoration's owener.
  1182. */
  1183. readonly ownerId: number;
  1184. /**
  1185. * Range that this decoration covers.
  1186. */
  1187. readonly range: Range;
  1188. /**
  1189. * Options associated with this decoration.
  1190. */
  1191. readonly options: IModelDecorationOptions;
  1192. }
  1193. /**
  1194. * Word inside a model.
  1195. */
  1196. export interface IWordAtPosition {
  1197. /**
  1198. * The word.
  1199. */
  1200. readonly word: string;
  1201. /**
  1202. * The column where the word starts.
  1203. */
  1204. readonly startColumn: number;
  1205. /**
  1206. * The column where the word ends.
  1207. */
  1208. readonly endColumn: number;
  1209. }
  1210. /**
  1211. * End of line character preference.
  1212. */
  1213. export enum EndOfLinePreference {
  1214. /**
  1215. * Use the end of line character identified in the text buffer.
  1216. */
  1217. TextDefined = 0,
  1218. /**
  1219. * Use line feed (\n) as the end of line character.
  1220. */
  1221. LF = 1,
  1222. /**
  1223. * Use carriage return and line feed (\r\n) as the end of line character.
  1224. */
  1225. CRLF = 2
  1226. }
  1227. /**
  1228. * The default end of line to use when instantiating models.
  1229. */
  1230. export enum DefaultEndOfLine {
  1231. /**
  1232. * Use line feed (\n) as the end of line character.
  1233. */
  1234. LF = 1,
  1235. /**
  1236. * Use carriage return and line feed (\r\n) as the end of line character.
  1237. */
  1238. CRLF = 2
  1239. }
  1240. /**
  1241. * End of line character preference.
  1242. */
  1243. export enum EndOfLineSequence {
  1244. /**
  1245. * Use line feed (\n) as the end of line character.
  1246. */
  1247. LF = 0,
  1248. /**
  1249. * Use carriage return and line feed (\r\n) as the end of line character.
  1250. */
  1251. CRLF = 1
  1252. }
  1253. /**
  1254. * An identifier for a single edit operation.
  1255. */
  1256. export interface ISingleEditOperationIdentifier {
  1257. /**
  1258. * Identifier major
  1259. */
  1260. major: number;
  1261. /**
  1262. * Identifier minor
  1263. */
  1264. minor: number;
  1265. }
  1266. /**
  1267. * A single edit operation, that acts as a simple replace.
  1268. * i.e. Replace text at `range` with `text` in model.
  1269. */
  1270. export interface ISingleEditOperation {
  1271. /**
  1272. * The range to replace. This can be empty to emulate a simple insert.
  1273. */
  1274. range: IRange;
  1275. /**
  1276. * The text to replace with. This can be null to emulate a simple delete.
  1277. */
  1278. text: string;
  1279. /**
  1280. * This indicates that this operation has "insert" semantics.
  1281. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
  1282. */
  1283. forceMoveMarkers?: boolean;
  1284. }
  1285. /**
  1286. * A single edit operation, that has an identifier.
  1287. */
  1288. export interface IIdentifiedSingleEditOperation {
  1289. /**
  1290. * The range to replace. This can be empty to emulate a simple insert.
  1291. */
  1292. range: Range;
  1293. /**
  1294. * The text to replace with. This can be null to emulate a simple delete.
  1295. */
  1296. text: string;
  1297. /**
  1298. * This indicates that this operation has "insert" semantics.
  1299. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
  1300. */
  1301. forceMoveMarkers?: boolean;
  1302. }
  1303. /**
  1304. * A callback that can compute the cursor state after applying a series of edit operations.
  1305. */
  1306. export interface ICursorStateComputer {
  1307. /**
  1308. * A callback that can compute the resulting cursors state after some edit operations have been executed.
  1309. */
  1310. (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[];
  1311. }
  1312. export class TextModelResolvedOptions {
  1313. _textModelResolvedOptionsBrand: void;
  1314. readonly tabSize: number;
  1315. readonly insertSpaces: boolean;
  1316. readonly defaultEOL: DefaultEndOfLine;
  1317. readonly trimAutoWhitespace: boolean;
  1318. }
  1319. export interface ITextModelUpdateOptions {
  1320. tabSize?: number;
  1321. insertSpaces?: boolean;
  1322. trimAutoWhitespace?: boolean;
  1323. }
  1324. export class FindMatch {
  1325. _findMatchBrand: void;
  1326. readonly range: Range;
  1327. readonly matches: string[];
  1328. }
  1329. /**
  1330. * Describes the behavior of decorations when typing/editing near their edges.
  1331. * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior`
  1332. */
  1333. export enum TrackedRangeStickiness {
  1334. AlwaysGrowsWhenTypingAtEdges = 0,
  1335. NeverGrowsWhenTypingAtEdges = 1,
  1336. GrowsOnlyWhenTypingBefore = 2,
  1337. GrowsOnlyWhenTypingAfter = 3
  1338. }
  1339. /**
  1340. * A model.
  1341. */
  1342. export interface ITextModel {
  1343. /**
  1344. * Gets the resource associated with this editor model.
  1345. */
  1346. readonly uri: Uri;
  1347. /**
  1348. * A unique identifier associated with this model.
  1349. */
  1350. readonly id: string;
  1351. /**
  1352. * Get the resolved options for this model.
  1353. */
  1354. getOptions(): TextModelResolvedOptions;
  1355. /**
  1356. * Get the current version id of the model.
  1357. * Anytime a change happens to the model (even undo/redo),
  1358. * the version id is incremented.
  1359. */
  1360. getVersionId(): number;
  1361. /**
  1362. * Get the alternative version id of the model.
  1363. * This alternative version id is not always incremented,
  1364. * it will return the same values in the case of undo-redo.
  1365. */
  1366. getAlternativeVersionId(): number;
  1367. /**
  1368. * Replace the entire text buffer value contained in this model.
  1369. */
  1370. setValue(newValue: string): void;
  1371. /**
  1372. * Get the text stored in this model.
  1373. * @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`.
  1374. * @param preserverBOM Preserve a BOM character if it was detected when the model was constructed.
  1375. * @return The text.
  1376. */
  1377. getValue(eol?: EndOfLinePreference, preserveBOM?: boolean): string;
  1378. /**
  1379. * Get the length of the text stored in this model.
  1380. */
  1381. getValueLength(eol?: EndOfLinePreference, preserveBOM?: boolean): number;
  1382. /**
  1383. * Get the text in a certain range.
  1384. * @param range The range describing what text to get.
  1385. * @param eol The end of line character preference. This will only be used for multiline ranges. Defaults to `EndOfLinePreference.TextDefined`.
  1386. * @return The text.
  1387. */
  1388. getValueInRange(range: IRange, eol?: EndOfLinePreference): string;
  1389. /**
  1390. * Get the length of text in a certain range.
  1391. * @param range The range describing what text length to get.
  1392. * @return The text length.
  1393. */
  1394. getValueLengthInRange(range: IRange): number;
  1395. /**
  1396. * Get the number of lines in the model.
  1397. */
  1398. getLineCount(): number;
  1399. /**
  1400. * Get the text for a certain line.
  1401. */
  1402. getLineContent(lineNumber: number): string;
  1403. /**
  1404. * Get the text length for a certain line.
  1405. */
  1406. getLineLength(lineNumber: number): number;
  1407. /**
  1408. * Get the text for all lines.
  1409. */
  1410. getLinesContent(): string[];
  1411. /**
  1412. * Get the end of line sequence predominantly used in the text buffer.
  1413. * @return EOL char sequence (e.g.: '\n' or '\r\n').
  1414. */
  1415. getEOL(): string;
  1416. /**
  1417. * Get the minimum legal column for line at `lineNumber`
  1418. */
  1419. getLineMinColumn(lineNumber: number): number;
  1420. /**
  1421. * Get the maximum legal column for line at `lineNumber`
  1422. */
  1423. getLineMaxColumn(lineNumber: number): number;
  1424. /**
  1425. * Returns the column before the first non whitespace character for line at `lineNumber`.
  1426. * Returns 0 if line is empty or contains only whitespace.
  1427. */
  1428. getLineFirstNonWhitespaceColumn(lineNumber: number): number;
  1429. /**
  1430. * Returns the column after the last non whitespace character for line at `lineNumber`.
  1431. * Returns 0 if line is empty or contains only whitespace.
  1432. */
  1433. getLineLastNonWhitespaceColumn(lineNumber: number): number;
  1434. /**
  1435. * Create a valid position,
  1436. */
  1437. validatePosition(position: IPosition): Position;
  1438. /**
  1439. * Advances the given position by the given offest (negative offsets are also accepted)
  1440. * and returns it as a new valid position.
  1441. *
  1442. * If the offset and position are such that their combination goes beyond the beginning or
  1443. * end of the model, throws an exception.
  1444. *
  1445. * If the ofsset is such that the new position would be in the middle of a multi-byte
  1446. * line terminator, throws an exception.
  1447. */
  1448. modifyPosition(position: IPosition, offset: number): Position;
  1449. /**
  1450. * Create a valid range.
  1451. */
  1452. validateRange(range: IRange): Range;
  1453. /**
  1454. * Converts the position to a zero-based offset.
  1455. *
  1456. * The position will be [adjusted](#TextDocument.validatePosition).
  1457. *
  1458. * @param position A position.
  1459. * @return A valid zero-based offset.
  1460. */
  1461. getOffsetAt(position: IPosition): number;
  1462. /**
  1463. * Converts a zero-based offset to a position.
  1464. *
  1465. * @param offset A zero-based offset.
  1466. * @return A valid [position](#Position).
  1467. */
  1468. getPositionAt(offset: number): Position;
  1469. /**
  1470. * Get a range covering the entire model
  1471. */
  1472. getFullModelRange(): Range;
  1473. /**
  1474. * Returns if the model was disposed or not.
  1475. */
  1476. isDisposed(): boolean;
  1477. /**
  1478. * Search the model.
  1479. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1480. * @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model.
  1481. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1482. * @param matchCase Force the matching to match lower/upper case exactly.
  1483. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1484. * @param captureMatches The result will contain the captured groups.
  1485. * @param limitResultCount Limit the number of results
  1486. * @return The ranges where the matches are. It is empty if not matches have been found.
  1487. */
  1488. findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean, limitResultCount?: number): FindMatch[];
  1489. /**
  1490. * Search the model.
  1491. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1492. * @param searchScope Limit the searching to only search inside this range.
  1493. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1494. * @param matchCase Force the matching to match lower/upper case exactly.
  1495. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1496. * @param captureMatches The result will contain the captured groups.
  1497. * @param limitResultCount Limit the number of results
  1498. * @return The ranges where the matches are. It is empty if no matches have been found.
  1499. */
  1500. findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean, limitResultCount?: number): FindMatch[];
  1501. /**
  1502. * Search the model for the next match. Loops to the beginning of the model if needed.
  1503. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1504. * @param searchStart Start the searching at the specified position.
  1505. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1506. * @param matchCase Force the matching to match lower/upper case exactly.
  1507. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1508. * @param captureMatches The result will contain the captured groups.
  1509. * @return The range where the next match is. It is null if no next match has been found.
  1510. */
  1511. findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch;
  1512. /**
  1513. * Search the model for the previous match. Loops to the end of the model if needed.
  1514. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1515. * @param searchStart Start the searching at the specified position.
  1516. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1517. * @param matchCase Force the matching to match lower/upper case exactly.
  1518. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1519. * @param captureMatches The result will contain the captured groups.
  1520. * @return The range where the previous match is. It is null if no previous match has been found.
  1521. */
  1522. findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch;
  1523. /**
  1524. * Get the language associated with this model.
  1525. */
  1526. getModeId(): string;
  1527. /**
  1528. * Get the word under or besides `position`.
  1529. * @param position The position to look for a word.
  1530. * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode.
  1531. * @return The word under or besides `position`. Might be null.
  1532. */
  1533. getWordAtPosition(position: IPosition): IWordAtPosition;
  1534. /**
  1535. * Get the word under or besides `position` trimmed to `position`.column
  1536. * @param position The position to look for a word.
  1537. * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode.
  1538. * @return The word under or besides `position`. Will never be null.
  1539. */
  1540. getWordUntilPosition(position: IPosition): IWordAtPosition;
  1541. /**
  1542. * Get the language associated with this model.
  1543. */
  1544. getModeId(): string;
  1545. /**
  1546. * Get the word under or besides `position`.
  1547. * @param position The position to look for a word.
  1548. * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode.
  1549. * @return The word under or besides `position`. Might be null.
  1550. */
  1551. getWordAtPosition(position: IPosition): IWordAtPosition;
  1552. /**
  1553. * Get the word under or besides `position` trimmed to `position`.column
  1554. * @param position The position to look for a word.
  1555. * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode.
  1556. * @return The word under or besides `position`. Will never be null.
  1557. */
  1558. getWordUntilPosition(position: IPosition): IWordAtPosition;
  1559. /**
  1560. * Perform a minimum ammount of operations, in order to transform the decorations
  1561. * identified by `oldDecorations` to the decorations described by `newDecorations`
  1562. * and returns the new identifiers associated with the resulting decorations.
  1563. *
  1564. * @param oldDecorations Array containing previous decorations identifiers.
  1565. * @param newDecorations Array describing what decorations should result after the call.
  1566. * @param ownerId Identifies the editor id in which these decorations should appear. If no `ownerId` is provided, the decorations will appear in all editors that attach this model.
  1567. * @return An array containing the new decorations identifiers.
  1568. */
  1569. deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[], ownerId?: number): string[];
  1570. /**
  1571. * Get the options associated with a decoration.
  1572. * @param id The decoration id.
  1573. * @return The decoration options or null if the decoration was not found.
  1574. */
  1575. getDecorationOptions(id: string): IModelDecorationOptions;
  1576. /**
  1577. * Get the range associated with a decoration.
  1578. * @param id The decoration id.
  1579. * @return The decoration range or null if the decoration was not found.
  1580. */
  1581. getDecorationRange(id: string): Range;
  1582. /**
  1583. * Gets all the decorations for the line `lineNumber` as an array.
  1584. * @param lineNumber The line number
  1585. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1586. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1587. * @return An array with the decorations
  1588. */
  1589. getLineDecorations(lineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1590. /**
  1591. * Gets all the decorations for the lines between `startLineNumber` and `endLineNumber` as an array.
  1592. * @param startLineNumber The start line number
  1593. * @param endLineNumber The end line number
  1594. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1595. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1596. * @return An array with the decorations
  1597. */
  1598. getLinesDecorations(startLineNumber: number, endLineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1599. /**
  1600. * Gets all the deocorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering.
  1601. * So for now it returns all the decorations on the same line as `range`.
  1602. * @param range The range to search in
  1603. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1604. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1605. * @return An array with the decorations
  1606. */
  1607. getDecorationsInRange(range: IRange, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1608. /**
  1609. * Gets all the decorations as an array.
  1610. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1611. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1612. */
  1613. getAllDecorations(ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1614. /**
  1615. * Gets all the decorations that should be rendered in the overview ruler as an array.
  1616. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1617. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1618. */
  1619. getOverviewRulerDecorations(ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1620. /**
  1621. * Normalize a string containing whitespace according to indentation rules (converts to spaces or to tabs).
  1622. */
  1623. normalizeIndentation(str: string): string;
  1624. /**
  1625. * Get what is considered to be one indent (e.g. a tab character or 4 spaces, etc.).
  1626. */
  1627. getOneIndent(): string;
  1628. /**
  1629. * Change the options of this model.
  1630. */
  1631. updateOptions(newOpts: ITextModelUpdateOptions): void;
  1632. /**
  1633. * Detect the indentation options for this model from its content.
  1634. */
  1635. detectIndentation(defaultInsertSpaces: boolean, defaultTabSize: number): void;
  1636. /**
  1637. * Push a stack element onto the undo stack. This acts as an undo/redo point.
  1638. * The idea is to use `pushEditOperations` to edit the model and then to
  1639. * `pushStackElement` to create an undo/redo stop point.
  1640. */
  1641. pushStackElement(): void;
  1642. /**
  1643. * Push edit operations, basically editing the model. This is the preferred way
  1644. * of editing the model. The edit operations will land on the undo stack.
  1645. * @param beforeCursorState The cursor state before the edit operaions. This cursor state will be returned when `undo` or `redo` are invoked.
  1646. * @param editOperations The edit operations.
  1647. * @param cursorStateComputer A callback that can compute the resulting cursors state after the edit operations have been executed.
  1648. * @return The cursor state returned by the `cursorStateComputer`.
  1649. */
  1650. pushEditOperations(beforeCursorState: Selection[], editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[];
  1651. /**
  1652. * Change the end of line sequence. This is the preferred way of
  1653. * changing the eol sequence. This will land on the undo stack.
  1654. */
  1655. pushEOL(eol: EndOfLineSequence): void;
  1656. /**
  1657. * Edit the model without adding the edits to the undo stack.
  1658. * This can have dire consequences on the undo stack! See @pushEditOperations for the preferred way.
  1659. * @param operations The edit operations.
  1660. * @return The inverse edit operations, that, when applied, will bring the model back to the previous state.
  1661. */
  1662. applyEdits(operations: IIdentifiedSingleEditOperation[]): IIdentifiedSingleEditOperation[];
  1663. /**
  1664. * Change the end of line sequence without recording in the undo stack.
  1665. * This can have dire consequences on the undo stack! See @pushEOL for the preferred way.
  1666. */
  1667. setEOL(eol: EndOfLineSequence): void;
  1668. /**
  1669. * An event emitted when the contents of the model have changed.
  1670. * @event
  1671. */
  1672. onDidChangeContent(listener: (e: IModelContentChangedEvent) => void): IDisposable;
  1673. /**
  1674. * An event emitted when decorations of the model have changed.
  1675. * @event
  1676. */
  1677. onDidChangeDecorations(listener: (e: IModelDecorationsChangedEvent) => void): IDisposable;
  1678. /**
  1679. * An event emitted when the model options have changed.
  1680. * @event
  1681. */
  1682. onDidChangeOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable;
  1683. /**
  1684. * An event emitted when the language associated with the model has changed.
  1685. * @event
  1686. */
  1687. onDidChangeLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable;
  1688. /**
  1689. * An event emitted when the language configuration associated with the model has changed.
  1690. * @event
  1691. */
  1692. onDidChangeLanguageConfiguration(listener: (e: IModelLanguageConfigurationChangedEvent) => void): IDisposable;
  1693. /**
  1694. * An event emitted right before disposing the model.
  1695. * @event
  1696. */
  1697. onWillDispose(listener: () => void): IDisposable;
  1698. /**
  1699. * Destroy this model. This will unbind the model from the mode
  1700. * and make all necessary clean-up to release this object to the GC.
  1701. */
  1702. dispose(): void;
  1703. }
  1704. /**
  1705. * A builder and helper for edit operations for a command.
  1706. */
  1707. export interface IEditOperationBuilder {
  1708. /**
  1709. * Add a new edit operation (a replace operation).
  1710. * @param range The range to replace (delete). May be empty to represent a simple insert.
  1711. * @param text The text to replace with. May be null to represent a simple delete.
  1712. */
  1713. addEditOperation(range: Range, text: string): void;
  1714. /**
  1715. * Add a new edit operation (a replace operation).
  1716. * The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()`
  1717. * @param range The range to replace (delete). May be empty to represent a simple insert.
  1718. * @param text The text to replace with. May be null to represent a simple delete.
  1719. */
  1720. addTrackedEditOperation(range: Range, text: string): void;
  1721. /**
  1722. * Track `selection` when applying edit operations.
  1723. * A best effort will be made to not grow/expand the selection.
  1724. * An empty selection will clamp to a nearby character.
  1725. * @param selection The selection to track.
  1726. * @param trackPreviousOnEmpty If set, and the selection is empty, indicates whether the selection
  1727. * should clamp to the previous or the next character.
  1728. * @return A unique identifer.
  1729. */
  1730. trackSelection(selection: Selection, trackPreviousOnEmpty?: boolean): string;
  1731. }
  1732. /**
  1733. * A helper for computing cursor state after a command.
  1734. */
  1735. export interface ICursorStateComputerData {
  1736. /**
  1737. * Get the inverse edit operations of the added edit operations.
  1738. */
  1739. getInverseEditOperations(): IIdentifiedSingleEditOperation[];
  1740. /**
  1741. * Get a previously tracked selection.
  1742. * @param id The unique identifier returned by `trackSelection`.
  1743. * @return The selection.
  1744. */
  1745. getTrackedSelection(id: string): Selection;
  1746. }
  1747. /**
  1748. * A command that modifies text / cursor state on a model.
  1749. */
  1750. export interface ICommand {
  1751. /**
  1752. * Get the edit operations needed to execute this command.
  1753. * @param model The model the command will execute on.
  1754. * @param builder A helper to collect the needed edit operations and to track selections.
  1755. */
  1756. getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void;
  1757. /**
  1758. * Compute the cursor state after the edit operations were applied.
  1759. * @param model The model the commad has executed on.
  1760. * @param helper A helper to get inverse edit operations and to get previously tracked selections.
  1761. * @return The cursor state after the command executed.
  1762. */
  1763. computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection;
  1764. }
  1765. /**
  1766. * A model for the diff editor.
  1767. */
  1768. export interface IDiffEditorModel {
  1769. /**
  1770. * Original model.
  1771. */
  1772. original: ITextModel;
  1773. /**
  1774. * Modified model.
  1775. */
  1776. modified: ITextModel;
  1777. }
  1778. /**
  1779. * An event describing that an editor has had its model reset (i.e. `editor.setModel()`).
  1780. */
  1781. export interface IModelChangedEvent {
  1782. /**
  1783. * The `uri` of the previous model or null.
  1784. */
  1785. readonly oldModelUrl: Uri;
  1786. /**
  1787. * The `uri` of the new model or null.
  1788. */
  1789. readonly newModelUrl: Uri;
  1790. }
  1791. export interface IDimension {
  1792. width: number;
  1793. height: number;
  1794. }
  1795. /**
  1796. * A change
  1797. */
  1798. export interface IChange {
  1799. readonly originalStartLineNumber: number;
  1800. readonly originalEndLineNumber: number;
  1801. readonly modifiedStartLineNumber: number;
  1802. readonly modifiedEndLineNumber: number;
  1803. }
  1804. /**
  1805. * A character level change.
  1806. */
  1807. export interface ICharChange extends IChange {
  1808. readonly originalStartColumn: number;
  1809. readonly originalEndColumn: number;
  1810. readonly modifiedStartColumn: number;
  1811. readonly modifiedEndColumn: number;
  1812. }
  1813. /**
  1814. * A line change
  1815. */
  1816. export interface ILineChange extends IChange {
  1817. readonly charChanges: ICharChange[];
  1818. }
  1819. export interface INewScrollPosition {
  1820. scrollLeft?: number;
  1821. scrollTop?: number;
  1822. }
  1823. export interface IEditorAction {
  1824. readonly id: string;
  1825. readonly label: string;
  1826. readonly alias: string;
  1827. isSupported(): boolean;
  1828. run(): Promise<void>;
  1829. }
  1830. export type IEditorModel = ITextModel | IDiffEditorModel;
  1831. /**
  1832. * A (serializable) state of the cursors.
  1833. */
  1834. export interface ICursorState {
  1835. inSelectionMode: boolean;
  1836. selectionStart: IPosition;
  1837. position: IPosition;
  1838. }
  1839. /**
  1840. * A (serializable) state of the view.
  1841. */
  1842. export interface IViewState {
  1843. /** written by previous versions */
  1844. scrollTop?: number;
  1845. /** written by previous versions */
  1846. scrollTopWithoutViewZones?: number;
  1847. scrollLeft: number;
  1848. firstPosition: IPosition;
  1849. firstPositionDeltaTop: number;
  1850. }
  1851. /**
  1852. * A (serializable) state of the code editor.
  1853. */
  1854. export interface ICodeEditorViewState {
  1855. cursorState: ICursorState[];
  1856. viewState: IViewState;
  1857. contributionsState: {
  1858. [id: string]: any;
  1859. };
  1860. }
  1861. /**
  1862. * (Serializable) View state for the diff editor.
  1863. */
  1864. export interface IDiffEditorViewState {
  1865. original: ICodeEditorViewState;
  1866. modified: ICodeEditorViewState;
  1867. }
  1868. /**
  1869. * An editor view state.
  1870. */
  1871. export type IEditorViewState = ICodeEditorViewState | IDiffEditorViewState;
  1872. export const enum ScrollType {
  1873. Smooth = 0,
  1874. Immediate = 1
  1875. }
  1876. /**
  1877. * An editor.
  1878. */
  1879. export interface IEditor {
  1880. /**
  1881. * An event emitted when the editor has been disposed.
  1882. * @event
  1883. */
  1884. onDidDispose(listener: () => void): IDisposable;
  1885. /**
  1886. * Dispose the editor.
  1887. */
  1888. dispose(): void;
  1889. /**
  1890. * Get a unique id for this editor instance.
  1891. */
  1892. getId(): string;
  1893. /**
  1894. * Get the editor type. Please see `EditorType`.
  1895. * This is to avoid an instanceof check
  1896. */
  1897. getEditorType(): string;
  1898. /**
  1899. * Update the editor's options after the editor has been created.
  1900. */
  1901. updateOptions(newOptions: IEditorOptions): void;
  1902. /**
  1903. * Instructs the editor to remeasure its container. This method should
  1904. * be called when the container of the editor gets resized.
  1905. */
  1906. layout(dimension?: IDimension): void;
  1907. /**
  1908. * Brings browser focus to the editor text
  1909. */
  1910. focus(): void;
  1911. /**
  1912. * Returns true if the text inside this editor is focused (i.e. cursor is blinking).
  1913. */
  1914. hasTextFocus(): boolean;
  1915. /**
  1916. * Returns all actions associated with this editor.
  1917. */
  1918. getSupportedActions(): IEditorAction[];
  1919. /**
  1920. * Saves current view state of the editor in a serializable object.
  1921. */
  1922. saveViewState(): IEditorViewState;
  1923. /**
  1924. * Restores the view state of the editor from a serializable object generated by `saveViewState`.
  1925. */
  1926. restoreViewState(state: IEditorViewState): void;
  1927. /**
  1928. * Given a position, returns a column number that takes tab-widths into account.
  1929. */
  1930. getVisibleColumnFromPosition(position: IPosition): number;
  1931. /**
  1932. * Returns the primary position of the cursor.
  1933. */
  1934. getPosition(): Position;
  1935. /**
  1936. * Set the primary position of the cursor. This will remove any secondary cursors.
  1937. * @param position New primary cursor's position
  1938. */
  1939. setPosition(position: IPosition): void;
  1940. /**
  1941. * Scroll vertically as necessary and reveal a line.
  1942. */
  1943. revealLine(lineNumber: number, scrollType?: ScrollType): void;
  1944. /**
  1945. * Scroll vertically as necessary and reveal a line centered vertically.
  1946. */
  1947. revealLineInCenter(lineNumber: number, scrollType?: ScrollType): void;
  1948. /**
  1949. * Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport.
  1950. */
  1951. revealLineInCenterIfOutsideViewport(lineNumber: number, scrollType?: ScrollType): void;
  1952. /**
  1953. * Scroll vertically or horizontally as necessary and reveal a position.
  1954. */
  1955. revealPosition(position: IPosition, scrollType?: ScrollType): void;
  1956. /**
  1957. * Scroll vertically or horizontally as necessary and reveal a position centered vertically.
  1958. */
  1959. revealPositionInCenter(position: IPosition, scrollType?: ScrollType): void;
  1960. /**
  1961. * Scroll vertically or horizontally as necessary and reveal a position centered vertically only if it lies outside the viewport.
  1962. */
  1963. revealPositionInCenterIfOutsideViewport(position: IPosition, scrollType?: ScrollType): void;
  1964. /**
  1965. * Returns the primary selection of the editor.
  1966. */
  1967. getSelection(): Selection;
  1968. /**
  1969. * Returns all the selections of the editor.
  1970. */
  1971. getSelections(): Selection[];
  1972. /**
  1973. * Set the primary selection of the editor. This will remove any secondary cursors.
  1974. * @param selection The new selection
  1975. */
  1976. setSelection(selection: IRange): void;
  1977. /**
  1978. * Set the primary selection of the editor. This will remove any secondary cursors.
  1979. * @param selection The new selection
  1980. */
  1981. setSelection(selection: Range): void;
  1982. /**
  1983. * Set the primary selection of the editor. This will remove any secondary cursors.
  1984. * @param selection The new selection
  1985. */
  1986. setSelection(selection: ISelection): void;
  1987. /**
  1988. * Set the primary selection of the editor. This will remove any secondary cursors.
  1989. * @param selection The new selection
  1990. */
  1991. setSelection(selection: Selection): void;
  1992. /**
  1993. * Set the selections for all the cursors of the editor.
  1994. * Cursors will be removed or added, as necessary.
  1995. */
  1996. setSelections(selections: ISelection[]): void;
  1997. /**
  1998. * Scroll vertically as necessary and reveal lines.
  1999. */
  2000. revealLines(startLineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
  2001. /**
  2002. * Scroll vertically as necessary and reveal lines centered vertically.
  2003. */
  2004. revealLinesInCenter(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
  2005. /**
  2006. * Scroll vertically as necessary and reveal lines centered vertically only if it lies outside the viewport.
  2007. */
  2008. revealLinesInCenterIfOutsideViewport(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
  2009. /**
  2010. * Scroll vertically or horizontally as necessary and reveal a range.
  2011. */
  2012. revealRange(range: IRange, scrollType?: ScrollType): void;
  2013. /**
  2014. * Scroll vertically or horizontally as necessary and reveal a range centered vertically.
  2015. */
  2016. revealRangeInCenter(range: IRange, scrollType?: ScrollType): void;
  2017. /**
  2018. * Scroll vertically or horizontally as necessary and reveal a range at the top of the viewport.
  2019. */
  2020. revealRangeAtTop(range: IRange, scrollType?: ScrollType): void;
  2021. /**
  2022. * Scroll vertically or horizontally as necessary and reveal a range centered vertically only if it lies outside the viewport.
  2023. */
  2024. revealRangeInCenterIfOutsideViewport(range: IRange, scrollType?: ScrollType): void;
  2025. /**
  2026. * Directly trigger a handler or an editor action.
  2027. * @param source The source of the call.
  2028. * @param handlerId The id of the handler or the id of a contribution.
  2029. * @param payload Extra data to be sent to the handler.
  2030. */
  2031. trigger(source: string, handlerId: string, payload: any): void;
  2032. /**
  2033. * Gets the current model attached to this editor.
  2034. */
  2035. getModel(): IEditorModel | null;
  2036. /**
  2037. * Sets the current model attached to this editor.
  2038. * If the previous model was created by the editor via the value key in the options
  2039. * literal object, it will be destroyed. Otherwise, if the previous model was set
  2040. * via setModel, or the model key in the options literal object, the previous model
  2041. * will not be destroyed.
  2042. * It is safe to call setModel(null) to simply detach the current model from the editor.
  2043. */
  2044. setModel(model: IEditorModel | null): void;
  2045. }
  2046. /**
  2047. * An editor contribution that gets created every time a new editor gets created and gets disposed when the editor gets disposed.
  2048. */
  2049. export interface IEditorContribution {
  2050. /**
  2051. * Get a unique identifier for this contribution.
  2052. */
  2053. getId(): string;
  2054. /**
  2055. * Dispose this contribution.
  2056. */
  2057. dispose(): void;
  2058. /**
  2059. * Store view state.
  2060. */
  2061. saveViewState?(): any;
  2062. /**
  2063. * Restore view state.
  2064. */
  2065. restoreViewState?(state: any): void;
  2066. }
  2067. /**
  2068. * The type of the `IEditor`.
  2069. */
  2070. export const EditorType: {
  2071. ICodeEditor: string;
  2072. IDiffEditor: string;
  2073. };
  2074. /**
  2075. * An event describing that the current mode associated with a model has changed.
  2076. */
  2077. export interface IModelLanguageChangedEvent {
  2078. /**
  2079. * Previous language
  2080. */
  2081. readonly oldLanguage: string;
  2082. /**
  2083. * New language
  2084. */
  2085. readonly newLanguage: string;
  2086. }
  2087. /**
  2088. * An event describing that the language configuration associated with a model has changed.
  2089. */
  2090. export interface IModelLanguageConfigurationChangedEvent {
  2091. }
  2092. export interface IModelContentChange {
  2093. /**
  2094. * The range that got replaced.
  2095. */
  2096. readonly range: IRange;
  2097. /**
  2098. * The offset of the range that got replaced.
  2099. */
  2100. readonly rangeOffset: number;
  2101. /**
  2102. * The length of the range that got replaced.
  2103. */
  2104. readonly rangeLength: number;
  2105. /**
  2106. * The new text for the range.
  2107. */
  2108. readonly text: string;
  2109. }
  2110. /**
  2111. * An event describing a change in the text of a model.
  2112. */
  2113. export interface IModelContentChangedEvent {
  2114. readonly changes: IModelContentChange[];
  2115. /**
  2116. * The (new) end-of-line character.
  2117. */
  2118. readonly eol: string;
  2119. /**
  2120. * The new version id the model has transitioned to.
  2121. */
  2122. readonly versionId: number;
  2123. /**
  2124. * Flag that indicates that this event was generated while undoing.
  2125. */
  2126. readonly isUndoing: boolean;
  2127. /**
  2128. * Flag that indicates that this event was generated while redoing.
  2129. */
  2130. readonly isRedoing: boolean;
  2131. /**
  2132. * Flag that indicates that all decorations were lost with this edit.
  2133. * The model has been reset to a new value.
  2134. */
  2135. readonly isFlush: boolean;
  2136. }
  2137. /**
  2138. * An event describing that model decorations have changed.
  2139. */
  2140. export interface IModelDecorationsChangedEvent {
  2141. }
  2142. /**
  2143. * An event describing that some ranges of lines have been tokenized (their tokens have changed).
  2144. */
  2145. export interface IModelTokensChangedEvent {
  2146. readonly ranges: {
  2147. /**
  2148. * The start of the range (inclusive)
  2149. */
  2150. readonly fromLineNumber: number;
  2151. /**
  2152. * The end of the range (inclusive)
  2153. */
  2154. readonly toLineNumber: number;
  2155. }[];
  2156. }
  2157. export interface IModelOptionsChangedEvent {
  2158. readonly tabSize: boolean;
  2159. readonly insertSpaces: boolean;
  2160. readonly trimAutoWhitespace: boolean;
  2161. }
  2162. /**
  2163. * Describes the reason the cursor has changed its position.
  2164. */
  2165. export enum CursorChangeReason {
  2166. /**
  2167. * Unknown or not set.
  2168. */
  2169. NotSet = 0,
  2170. /**
  2171. * A `model.setValue()` was called.
  2172. */
  2173. ContentFlush = 1,
  2174. /**
  2175. * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers.
  2176. */
  2177. RecoverFromMarkers = 2,
  2178. /**
  2179. * There was an explicit user gesture.
  2180. */
  2181. Explicit = 3,
  2182. /**
  2183. * There was a Paste.
  2184. */
  2185. Paste = 4,
  2186. /**
  2187. * There was an Undo.
  2188. */
  2189. Undo = 5,
  2190. /**
  2191. * There was a Redo.
  2192. */
  2193. Redo = 6
  2194. }
  2195. /**
  2196. * An event describing that the cursor position has changed.
  2197. */
  2198. export interface ICursorPositionChangedEvent {
  2199. /**
  2200. * Primary cursor's position.
  2201. */
  2202. readonly position: Position;
  2203. /**
  2204. * Secondary cursors' position.
  2205. */
  2206. readonly secondaryPositions: Position[];
  2207. /**
  2208. * Reason.
  2209. */
  2210. readonly reason: CursorChangeReason;
  2211. /**
  2212. * Source of the call that caused the event.
  2213. */
  2214. readonly source: string;
  2215. }
  2216. /**
  2217. * An event describing that the cursor selection has changed.
  2218. */
  2219. export interface ICursorSelectionChangedEvent {
  2220. /**
  2221. * The primary selection.
  2222. */
  2223. readonly selection: Selection;
  2224. /**
  2225. * The secondary selections.
  2226. */
  2227. readonly secondarySelections: Selection[];
  2228. /**
  2229. * Source of the call that caused the event.
  2230. */
  2231. readonly source: string;
  2232. /**
  2233. * Reason.
  2234. */
  2235. readonly reason: CursorChangeReason;
  2236. }
  2237. /**
  2238. * Configuration options for editor scrollbars
  2239. */
  2240. export interface IEditorScrollbarOptions {
  2241. /**
  2242. * The size of arrows (if displayed).
  2243. * Defaults to 11.
  2244. */
  2245. arrowSize?: number;
  2246. /**
  2247. * Render vertical scrollbar.
  2248. * Accepted values: 'auto', 'visible', 'hidden'.
  2249. * Defaults to 'auto'.
  2250. */
  2251. vertical?: string;
  2252. /**
  2253. * Render horizontal scrollbar.
  2254. * Accepted values: 'auto', 'visible', 'hidden'.
  2255. * Defaults to 'auto'.
  2256. */
  2257. horizontal?: string;
  2258. /**
  2259. * Cast horizontal and vertical shadows when the content is scrolled.
  2260. * Defaults to true.
  2261. */
  2262. useShadows?: boolean;
  2263. /**
  2264. * Render arrows at the top and bottom of the vertical scrollbar.
  2265. * Defaults to false.
  2266. */
  2267. verticalHasArrows?: boolean;
  2268. /**
  2269. * Render arrows at the left and right of the horizontal scrollbar.
  2270. * Defaults to false.
  2271. */
  2272. horizontalHasArrows?: boolean;
  2273. /**
  2274. * Listen to mouse wheel events and react to them by scrolling.
  2275. * Defaults to true.
  2276. */
  2277. handleMouseWheel?: boolean;
  2278. /**
  2279. * Height in pixels for the horizontal scrollbar.
  2280. * Defaults to 10 (px).
  2281. */
  2282. horizontalScrollbarSize?: number;
  2283. /**
  2284. * Width in pixels for the vertical scrollbar.
  2285. * Defaults to 10 (px).
  2286. */
  2287. verticalScrollbarSize?: number;
  2288. /**
  2289. * Width in pixels for the vertical slider.
  2290. * Defaults to `verticalScrollbarSize`.
  2291. */
  2292. verticalSliderSize?: number;
  2293. /**
  2294. * Height in pixels for the horizontal slider.
  2295. * Defaults to `horizontalScrollbarSize`.
  2296. */
  2297. horizontalSliderSize?: number;
  2298. }
  2299. /**
  2300. * Configuration options for editor find widget
  2301. */
  2302. export interface IEditorFindOptions {
  2303. /**
  2304. * Controls if we seed search string in the Find Widget with editor selection.
  2305. */
  2306. seedSearchStringFromSelection?: boolean;
  2307. /**
  2308. * Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor.
  2309. */
  2310. autoFindInSelection: boolean;
  2311. }
  2312. /**
  2313. * Configuration options for editor minimap
  2314. */
  2315. export interface IEditorMinimapOptions {
  2316. /**
  2317. * Enable the rendering of the minimap.
  2318. * Defaults to false.
  2319. */
  2320. enabled?: boolean;
  2321. /**
  2322. * Control the side of the minimap in editor.
  2323. * Defaults to 'right'.
  2324. */
  2325. side?: 'right' | 'left';
  2326. /**
  2327. * Control the rendering of the minimap slider.
  2328. * Defaults to 'mouseover'.
  2329. */
  2330. showSlider?: 'always' | 'mouseover';
  2331. /**
  2332. * Render the actual text on a line (as opposed to color blocks).
  2333. * Defaults to true.
  2334. */
  2335. renderCharacters?: boolean;
  2336. /**
  2337. * Limit the width of the minimap to render at most a certain number of columns.
  2338. * Defaults to 120.
  2339. */
  2340. maxColumn?: number;
  2341. }
  2342. /**
  2343. * Configuration options for editor minimap
  2344. */
  2345. export interface IEditorLightbulbOptions {
  2346. /**
  2347. * Enable the lightbulb code action.
  2348. * Defaults to true.
  2349. */
  2350. enabled?: boolean;
  2351. }
  2352. /**
  2353. * Configuration options for editor hover
  2354. */
  2355. export interface IEditorHoverOptions {
  2356. /**
  2357. * Enable the hover.
  2358. * Defaults to true.
  2359. */
  2360. enabled?: boolean;
  2361. /**
  2362. * Delay for showing the hover.
  2363. * Defaults to 300.
  2364. */
  2365. delay?: number;
  2366. /**
  2367. * Is the hover sticky such that it can be clicked and its contents selected?
  2368. * Defaults to true.
  2369. */
  2370. sticky?: boolean;
  2371. }
  2372. export interface ISuggestOptions {
  2373. /**
  2374. * Enable graceful matching. Defaults to true.
  2375. */
  2376. filterGraceful?: boolean;
  2377. /**
  2378. * Prevent quick suggestions when a snippet is active. Defaults to true.
  2379. */
  2380. snippetsPreventQuickSuggestions?: boolean;
  2381. }
  2382. /**
  2383. * Configuration map for codeActionsOnSave
  2384. */
  2385. export interface ICodeActionsOnSaveOptions {
  2386. [kind: string]: boolean;
  2387. }
  2388. /**
  2389. * Configuration options for the editor.
  2390. */
  2391. export interface IEditorOptions {
  2392. /**
  2393. * The aria label for the editor's textarea (when it is focused).
  2394. */
  2395. ariaLabel?: string;
  2396. /**
  2397. * Render vertical lines at the specified columns.
  2398. * Defaults to empty array.
  2399. */
  2400. rulers?: number[];
  2401. /**
  2402. * A string containing the word separators used when doing word navigation.
  2403. * Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?
  2404. */
  2405. wordSeparators?: string;
  2406. /**
  2407. * Enable Linux primary clipboard.
  2408. * Defaults to true.
  2409. */
  2410. selectionClipboard?: boolean;
  2411. /**
  2412. * Control the rendering of line numbers.
  2413. * If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
  2414. * Otherwise, if it is a truey, line numbers will be rendered normally (equivalent of using an identity function).
  2415. * Otherwise, line numbers will not be rendered.
  2416. * Defaults to true.
  2417. */
  2418. lineNumbers?: 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
  2419. /**
  2420. * Should the corresponding line be selected when clicking on the line number?
  2421. * Defaults to true.
  2422. */
  2423. selectOnLineNumbers?: boolean;
  2424. /**
  2425. * Control the width of line numbers, by reserving horizontal space for rendering at least an amount of digits.
  2426. * Defaults to 5.
  2427. */
  2428. lineNumbersMinChars?: number;
  2429. /**
  2430. * Enable the rendering of the glyph margin.
  2431. * Defaults to true in vscode and to false in monaco-editor.
  2432. */
  2433. glyphMargin?: boolean;
  2434. /**
  2435. * The width reserved for line decorations (in px).
  2436. * Line decorations are placed between line numbers and the editor content.
  2437. * You can pass in a string in the format floating point followed by "ch". e.g. 1.3ch.
  2438. * Defaults to 10.
  2439. */
  2440. lineDecorationsWidth?: number | string;
  2441. /**
  2442. * When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle.
  2443. * This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport.
  2444. * Defaults to 30 (px).
  2445. */
  2446. revealHorizontalRightPadding?: number;
  2447. /**
  2448. * Render the editor selection with rounded borders.
  2449. * Defaults to true.
  2450. */
  2451. roundedSelection?: boolean;
  2452. /**
  2453. * Class name to be added to the editor.
  2454. */
  2455. extraEditorClassName?: string;
  2456. /**
  2457. * Should the editor be read only.
  2458. * Defaults to false.
  2459. */
  2460. readOnly?: boolean;
  2461. /**
  2462. * Control the behavior and rendering of the scrollbars.
  2463. */
  2464. scrollbar?: IEditorScrollbarOptions;
  2465. /**
  2466. * Control the behavior and rendering of the minimap.
  2467. */
  2468. minimap?: IEditorMinimapOptions;
  2469. /**
  2470. * Control the behavior of the find widget.
  2471. */
  2472. find?: IEditorFindOptions;
  2473. /**
  2474. * Display overflow widgets as `fixed`.
  2475. * Defaults to `false`.
  2476. */
  2477. fixedOverflowWidgets?: boolean;
  2478. /**
  2479. * The number of vertical lanes the overview ruler should render.
  2480. * Defaults to 2.
  2481. */
  2482. overviewRulerLanes?: number;
  2483. /**
  2484. * Controls if a border should be drawn around the overview ruler.
  2485. * Defaults to `true`.
  2486. */
  2487. overviewRulerBorder?: boolean;
  2488. /**
  2489. * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'.
  2490. * Defaults to 'blink'.
  2491. */
  2492. cursorBlinking?: string;
  2493. /**
  2494. * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl.
  2495. * Defaults to false.
  2496. */
  2497. mouseWheelZoom?: boolean;
  2498. /**
  2499. * Control the cursor style, either 'block' or 'line'.
  2500. * Defaults to 'line'.
  2501. */
  2502. cursorStyle?: string;
  2503. /**
  2504. * Control the width of the cursor when cursorStyle is set to 'line'
  2505. */
  2506. cursorWidth?: number;
  2507. /**
  2508. * Enable font ligatures.
  2509. * Defaults to false.
  2510. */
  2511. fontLigatures?: boolean;
  2512. /**
  2513. * Disable the use of `will-change` for the editor margin and lines layers.
  2514. * The usage of `will-change` acts as a hint for browsers to create an extra layer.
  2515. * Defaults to false.
  2516. */
  2517. disableLayerHinting?: boolean;
  2518. /**
  2519. * Disable the optimizations for monospace fonts.
  2520. * Defaults to false.
  2521. */
  2522. disableMonospaceOptimizations?: boolean;
  2523. /**
  2524. * Should the cursor be hidden in the overview ruler.
  2525. * Defaults to false.
  2526. */
  2527. hideCursorInOverviewRuler?: boolean;
  2528. /**
  2529. * Enable that scrolling can go one screen size after the last line.
  2530. * Defaults to true.
  2531. */
  2532. scrollBeyondLastLine?: boolean;
  2533. /**
  2534. * Enable that scrolling can go beyond the last column by a number of columns.
  2535. * Defaults to 5.
  2536. */
  2537. scrollBeyondLastColumn?: number;
  2538. /**
  2539. * Enable that the editor animates scrolling to a position.
  2540. * Defaults to false.
  2541. */
  2542. smoothScrolling?: boolean;
  2543. /**
  2544. * Enable that the editor will install an interval to check if its container dom node size has changed.
  2545. * Enabling this might have a severe performance impact.
  2546. * Defaults to false.
  2547. */
  2548. automaticLayout?: boolean;
  2549. /**
  2550. * Control the wrapping of the editor.
  2551. * When `wordWrap` = "off", the lines will never wrap.
  2552. * When `wordWrap` = "on", the lines will wrap at the viewport width.
  2553. * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
  2554. * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
  2555. * Defaults to "off".
  2556. */
  2557. wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
  2558. /**
  2559. * Control the wrapping of the editor.
  2560. * When `wordWrap` = "off", the lines will never wrap.
  2561. * When `wordWrap` = "on", the lines will wrap at the viewport width.
  2562. * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
  2563. * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
  2564. * Defaults to 80.
  2565. */
  2566. wordWrapColumn?: number;
  2567. /**
  2568. * Force word wrapping when the text appears to be of a minified/generated file.
  2569. * Defaults to true.
  2570. */
  2571. wordWrapMinified?: boolean;
  2572. /**
  2573. * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'.
  2574. * Defaults to 'same' in vscode and to 'none' in monaco-editor.
  2575. */
  2576. wrappingIndent?: string;
  2577. /**
  2578. * Configure word wrapping characters. A break will be introduced before these characters.
  2579. * Defaults to '{([+'.
  2580. */
  2581. wordWrapBreakBeforeCharacters?: string;
  2582. /**
  2583. * Configure word wrapping characters. A break will be introduced after these characters.
  2584. * Defaults to ' \t})]?|&,;'.
  2585. */
  2586. wordWrapBreakAfterCharacters?: string;
  2587. /**
  2588. * Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found.
  2589. * Defaults to '.'.
  2590. */
  2591. wordWrapBreakObtrusiveCharacters?: string;
  2592. /**
  2593. * Performance guard: Stop rendering a line after x characters.
  2594. * Defaults to 10000.
  2595. * Use -1 to never stop rendering
  2596. */
  2597. stopRenderingLineAfter?: number;
  2598. /**
  2599. * Configure the editor's hover.
  2600. */
  2601. hover?: IEditorHoverOptions;
  2602. /**
  2603. * Enable detecting links and making them clickable.
  2604. * Defaults to true.
  2605. */
  2606. links?: boolean;
  2607. /**
  2608. * Enable inline color decorators and color picker rendering.
  2609. */
  2610. colorDecorators?: boolean;
  2611. /**
  2612. * Enable custom contextmenu.
  2613. * Defaults to true.
  2614. */
  2615. contextmenu?: boolean;
  2616. /**
  2617. * A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
  2618. * Defaults to 1.
  2619. */
  2620. mouseWheelScrollSensitivity?: number;
  2621. /**
  2622. * The modifier to be used to add multiple cursors with the mouse.
  2623. * Defaults to 'alt'
  2624. */
  2625. multiCursorModifier?: 'ctrlCmd' | 'alt';
  2626. /**
  2627. * Merge overlapping selections.
  2628. * Defaults to true
  2629. */
  2630. multiCursorMergeOverlapping?: boolean;
  2631. /**
  2632. * Configure the editor's accessibility support.
  2633. * Defaults to 'auto'. It is best to leave this to 'auto'.
  2634. */
  2635. accessibilitySupport?: 'auto' | 'off' | 'on';
  2636. /**
  2637. * Suggest options.
  2638. */
  2639. suggest?: ISuggestOptions;
  2640. /**
  2641. * Enable quick suggestions (shadow suggestions)
  2642. * Defaults to true.
  2643. */
  2644. quickSuggestions?: boolean | {
  2645. other: boolean;
  2646. comments: boolean;
  2647. strings: boolean;
  2648. };
  2649. /**
  2650. * Quick suggestions show delay (in ms)
  2651. * Defaults to 500 (ms)
  2652. */
  2653. quickSuggestionsDelay?: number;
  2654. /**
  2655. * Enables parameter hints
  2656. */
  2657. parameterHints?: boolean;
  2658. /**
  2659. * Render icons in suggestions box.
  2660. * Defaults to true.
  2661. */
  2662. iconsInSuggestions?: boolean;
  2663. /**
  2664. * Enable auto closing brackets.
  2665. * Defaults to true.
  2666. */
  2667. autoClosingBrackets?: boolean;
  2668. /**
  2669. * Enable auto indentation adjustment.
  2670. * Defaults to false.
  2671. */
  2672. autoIndent?: boolean;
  2673. /**
  2674. * Enable format on type.
  2675. * Defaults to false.
  2676. */
  2677. formatOnType?: boolean;
  2678. /**
  2679. * Enable format on paste.
  2680. * Defaults to false.
  2681. */
  2682. formatOnPaste?: boolean;
  2683. /**
  2684. * Controls if the editor should allow to move selections via drag and drop.
  2685. * Defaults to false.
  2686. */
  2687. dragAndDrop?: boolean;
  2688. /**
  2689. * Enable the suggestion box to pop-up on trigger characters.
  2690. * Defaults to true.
  2691. */
  2692. suggestOnTriggerCharacters?: boolean;
  2693. /**
  2694. * Accept suggestions on ENTER.
  2695. * Defaults to 'on'.
  2696. */
  2697. acceptSuggestionOnEnter?: boolean | 'on' | 'smart' | 'off';
  2698. /**
  2699. * Accept suggestions on provider defined characters.
  2700. * Defaults to true.
  2701. */
  2702. acceptSuggestionOnCommitCharacter?: boolean;
  2703. /**
  2704. * Enable snippet suggestions. Default to 'true'.
  2705. */
  2706. snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none';
  2707. /**
  2708. * Copying without a selection copies the current line.
  2709. */
  2710. emptySelectionClipboard?: boolean;
  2711. /**
  2712. * Enable word based suggestions. Defaults to 'true'
  2713. */
  2714. wordBasedSuggestions?: boolean;
  2715. /**
  2716. * The history mode for suggestions.
  2717. */
  2718. suggestSelection?: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
  2719. /**
  2720. * The font size for the suggest widget.
  2721. * Defaults to the editor font size.
  2722. */
  2723. suggestFontSize?: number;
  2724. /**
  2725. * The line height for the suggest widget.
  2726. * Defaults to the editor line height.
  2727. */
  2728. suggestLineHeight?: number;
  2729. /**
  2730. * Enable selection highlight.
  2731. * Defaults to true.
  2732. */
  2733. selectionHighlight?: boolean;
  2734. /**
  2735. * Enable semantic occurrences highlight.
  2736. * Defaults to true.
  2737. */
  2738. occurrencesHighlight?: boolean;
  2739. /**
  2740. * Show code lens
  2741. * Defaults to true.
  2742. */
  2743. codeLens?: boolean;
  2744. /**
  2745. * Control the behavior and rendering of the code action lightbulb.
  2746. */
  2747. lightbulb?: IEditorLightbulbOptions;
  2748. /**
  2749. * Code action kinds to be run on save.
  2750. */
  2751. codeActionsOnSave?: ICodeActionsOnSaveOptions;
  2752. /**
  2753. * Timeout for running code actions on save.
  2754. */
  2755. codeActionsOnSaveTimeout?: number;
  2756. /**
  2757. * Enable code folding
  2758. * Defaults to true.
  2759. */
  2760. folding?: boolean;
  2761. /**
  2762. * Selects the folding strategy. 'auto' uses the strategies contributed for the current document, 'indentation' uses the indentation based folding strategy.
  2763. * Defaults to 'auto'.
  2764. */
  2765. foldingStrategy?: 'auto' | 'indentation';
  2766. /**
  2767. * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
  2768. * Defaults to 'mouseover'.
  2769. */
  2770. showFoldingControls?: 'always' | 'mouseover';
  2771. /**
  2772. * Enable highlighting of matching brackets.
  2773. * Defaults to true.
  2774. */
  2775. matchBrackets?: boolean;
  2776. /**
  2777. * Enable rendering of whitespace.
  2778. * Defaults to none.
  2779. */
  2780. renderWhitespace?: 'none' | 'boundary' | 'all';
  2781. /**
  2782. * Enable rendering of control characters.
  2783. * Defaults to false.
  2784. */
  2785. renderControlCharacters?: boolean;
  2786. /**
  2787. * Enable rendering of indent guides.
  2788. * Defaults to true.
  2789. */
  2790. renderIndentGuides?: boolean;
  2791. /**
  2792. * Enable highlighting of the active indent guide.
  2793. * Defaults to true.
  2794. */
  2795. highlightActiveIndentGuide?: boolean;
  2796. /**
  2797. * Enable rendering of current line highlight.
  2798. * Defaults to all.
  2799. */
  2800. renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all';
  2801. /**
  2802. * Inserting and deleting whitespace follows tab stops.
  2803. */
  2804. useTabStops?: boolean;
  2805. /**
  2806. * The font family
  2807. */
  2808. fontFamily?: string;
  2809. /**
  2810. * The font weight
  2811. */
  2812. fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | 'initial' | 'inherit' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
  2813. /**
  2814. * The font size
  2815. */
  2816. fontSize?: number;
  2817. /**
  2818. * The line height
  2819. */
  2820. lineHeight?: number;
  2821. /**
  2822. * The letter spacing
  2823. */
  2824. letterSpacing?: number;
  2825. /**
  2826. * Controls fading out of unused variables.
  2827. */
  2828. showUnused?: boolean;
  2829. }
  2830. /**
  2831. * Configuration options for the diff editor.
  2832. */
  2833. export interface IDiffEditorOptions extends IEditorOptions {
  2834. /**
  2835. * Allow the user to resize the diff editor split view.
  2836. * Defaults to true.
  2837. */
  2838. enableSplitViewResizing?: boolean;
  2839. /**
  2840. * Render the differences in two side-by-side editors.
  2841. * Defaults to true.
  2842. */
  2843. renderSideBySide?: boolean;
  2844. /**
  2845. * Compute the diff by ignoring leading/trailing whitespace
  2846. * Defaults to true.
  2847. */
  2848. ignoreTrimWhitespace?: boolean;
  2849. /**
  2850. * Render +/- indicators for added/deleted changes.
  2851. * Defaults to true.
  2852. */
  2853. renderIndicators?: boolean;
  2854. /**
  2855. * Original model should be editable?
  2856. * Defaults to false.
  2857. */
  2858. originalEditable?: boolean;
  2859. }
  2860. export enum RenderMinimap {
  2861. None = 0,
  2862. Small = 1,
  2863. Large = 2,
  2864. SmallBlocks = 3,
  2865. LargeBlocks = 4
  2866. }
  2867. /**
  2868. * Describes how to indent wrapped lines.
  2869. */
  2870. export enum WrappingIndent {
  2871. /**
  2872. * No indentation => wrapped lines begin at column 1.
  2873. */
  2874. None = 0,
  2875. /**
  2876. * Same => wrapped lines get the same indentation as the parent.
  2877. */
  2878. Same = 1,
  2879. /**
  2880. * Indent => wrapped lines get +1 indentation toward the parent.
  2881. */
  2882. Indent = 2,
  2883. /**
  2884. * DeepIndent => wrapped lines get +2 indentation toward the parent.
  2885. */
  2886. DeepIndent = 3
  2887. }
  2888. /**
  2889. * The kind of animation in which the editor's cursor should be rendered.
  2890. */
  2891. export enum TextEditorCursorBlinkingStyle {
  2892. /**
  2893. * Hidden
  2894. */
  2895. Hidden = 0,
  2896. /**
  2897. * Blinking
  2898. */
  2899. Blink = 1,
  2900. /**
  2901. * Blinking with smooth fading
  2902. */
  2903. Smooth = 2,
  2904. /**
  2905. * Blinking with prolonged filled state and smooth fading
  2906. */
  2907. Phase = 3,
  2908. /**
  2909. * Expand collapse animation on the y axis
  2910. */
  2911. Expand = 4,
  2912. /**
  2913. * No-Blinking
  2914. */
  2915. Solid = 5
  2916. }
  2917. /**
  2918. * The style in which the editor's cursor should be rendered.
  2919. */
  2920. export enum TextEditorCursorStyle {
  2921. /**
  2922. * As a vertical line (sitting between two characters).
  2923. */
  2924. Line = 1,
  2925. /**
  2926. * As a block (sitting on top of a character).
  2927. */
  2928. Block = 2,
  2929. /**
  2930. * As a horizontal line (sitting under a character).
  2931. */
  2932. Underline = 3,
  2933. /**
  2934. * As a thin vertical line (sitting between two characters).
  2935. */
  2936. LineThin = 4,
  2937. /**
  2938. * As an outlined block (sitting on top of a character).
  2939. */
  2940. BlockOutline = 5,
  2941. /**
  2942. * As a thin horizontal line (sitting under a character).
  2943. */
  2944. UnderlineThin = 6
  2945. }
  2946. export interface InternalEditorScrollbarOptions {
  2947. readonly arrowSize: number;
  2948. readonly vertical: ScrollbarVisibility;
  2949. readonly horizontal: ScrollbarVisibility;
  2950. readonly useShadows: boolean;
  2951. readonly verticalHasArrows: boolean;
  2952. readonly horizontalHasArrows: boolean;
  2953. readonly handleMouseWheel: boolean;
  2954. readonly horizontalScrollbarSize: number;
  2955. readonly horizontalSliderSize: number;
  2956. readonly verticalScrollbarSize: number;
  2957. readonly verticalSliderSize: number;
  2958. readonly mouseWheelScrollSensitivity: number;
  2959. }
  2960. export interface InternalEditorMinimapOptions {
  2961. readonly enabled: boolean;
  2962. readonly side: 'right' | 'left';
  2963. readonly showSlider: 'always' | 'mouseover';
  2964. readonly renderCharacters: boolean;
  2965. readonly maxColumn: number;
  2966. }
  2967. export interface InternalEditorFindOptions {
  2968. readonly seedSearchStringFromSelection: boolean;
  2969. readonly autoFindInSelection: boolean;
  2970. }
  2971. export interface InternalEditorHoverOptions {
  2972. readonly enabled: boolean;
  2973. readonly delay: number;
  2974. readonly sticky: boolean;
  2975. }
  2976. export interface InternalSuggestOptions {
  2977. readonly filterGraceful: boolean;
  2978. readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
  2979. readonly snippetsPreventQuickSuggestions: boolean;
  2980. }
  2981. export interface EditorWrappingInfo {
  2982. readonly inDiffEditor: boolean;
  2983. readonly isDominatedByLongLines: boolean;
  2984. readonly isWordWrapMinified: boolean;
  2985. readonly isViewportWrapping: boolean;
  2986. readonly wrappingColumn: number;
  2987. readonly wrappingIndent: WrappingIndent;
  2988. readonly wordWrapBreakBeforeCharacters: string;
  2989. readonly wordWrapBreakAfterCharacters: string;
  2990. readonly wordWrapBreakObtrusiveCharacters: string;
  2991. }
  2992. export const enum RenderLineNumbersType {
  2993. Off = 0,
  2994. On = 1,
  2995. Relative = 2,
  2996. Interval = 3,
  2997. Custom = 4
  2998. }
  2999. export interface InternalEditorViewOptions {
  3000. readonly extraEditorClassName: string;
  3001. readonly disableMonospaceOptimizations: boolean;
  3002. readonly rulers: number[];
  3003. readonly ariaLabel: string;
  3004. readonly renderLineNumbers: RenderLineNumbersType;
  3005. readonly renderCustomLineNumbers: (lineNumber: number) => string;
  3006. readonly selectOnLineNumbers: boolean;
  3007. readonly glyphMargin: boolean;
  3008. readonly revealHorizontalRightPadding: number;
  3009. readonly roundedSelection: boolean;
  3010. readonly overviewRulerLanes: number;
  3011. readonly overviewRulerBorder: boolean;
  3012. readonly cursorBlinking: TextEditorCursorBlinkingStyle;
  3013. readonly mouseWheelZoom: boolean;
  3014. readonly cursorStyle: TextEditorCursorStyle;
  3015. readonly cursorWidth: number;
  3016. readonly hideCursorInOverviewRuler: boolean;
  3017. readonly scrollBeyondLastLine: boolean;
  3018. readonly scrollBeyondLastColumn: number;
  3019. readonly smoothScrolling: boolean;
  3020. readonly stopRenderingLineAfter: number;
  3021. readonly renderWhitespace: 'none' | 'boundary' | 'all';
  3022. readonly renderControlCharacters: boolean;
  3023. readonly fontLigatures: boolean;
  3024. readonly renderIndentGuides: boolean;
  3025. readonly highlightActiveIndentGuide: boolean;
  3026. readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
  3027. readonly scrollbar: InternalEditorScrollbarOptions;
  3028. readonly minimap: InternalEditorMinimapOptions;
  3029. readonly fixedOverflowWidgets: boolean;
  3030. }
  3031. export interface EditorContribOptions {
  3032. readonly selectionClipboard: boolean;
  3033. readonly hover: InternalEditorHoverOptions;
  3034. readonly links: boolean;
  3035. readonly contextmenu: boolean;
  3036. readonly quickSuggestions: boolean | {
  3037. other: boolean;
  3038. comments: boolean;
  3039. strings: boolean;
  3040. };
  3041. readonly quickSuggestionsDelay: number;
  3042. readonly parameterHints: boolean;
  3043. readonly iconsInSuggestions: boolean;
  3044. readonly formatOnType: boolean;
  3045. readonly formatOnPaste: boolean;
  3046. readonly suggestOnTriggerCharacters: boolean;
  3047. readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off';
  3048. readonly acceptSuggestionOnCommitCharacter: boolean;
  3049. readonly wordBasedSuggestions: boolean;
  3050. readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
  3051. readonly suggestFontSize: number;
  3052. readonly suggestLineHeight: number;
  3053. readonly suggest: InternalSuggestOptions;
  3054. readonly selectionHighlight: boolean;
  3055. readonly occurrencesHighlight: boolean;
  3056. readonly codeLens: boolean;
  3057. readonly folding: boolean;
  3058. readonly foldingStrategy: 'auto' | 'indentation';
  3059. readonly showFoldingControls: 'always' | 'mouseover';
  3060. readonly matchBrackets: boolean;
  3061. readonly find: InternalEditorFindOptions;
  3062. readonly colorDecorators: boolean;
  3063. readonly lightbulbEnabled: boolean;
  3064. readonly codeActionsOnSave: ICodeActionsOnSaveOptions;
  3065. readonly codeActionsOnSaveTimeout: number;
  3066. }
  3067. /**
  3068. * Internal configuration options (transformed or computed) for the editor.
  3069. */
  3070. export class InternalEditorOptions {
  3071. readonly _internalEditorOptionsBrand: void;
  3072. readonly canUseLayerHinting: boolean;
  3073. readonly pixelRatio: number;
  3074. readonly editorClassName: string;
  3075. readonly lineHeight: number;
  3076. readonly readOnly: boolean;
  3077. readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
  3078. readonly multiCursorMergeOverlapping: boolean;
  3079. readonly showUnused: boolean;
  3080. readonly wordSeparators: string;
  3081. readonly autoClosingBrackets: boolean;
  3082. readonly autoIndent: boolean;
  3083. readonly useTabStops: boolean;
  3084. readonly tabFocusMode: boolean;
  3085. readonly dragAndDrop: boolean;
  3086. readonly emptySelectionClipboard: boolean;
  3087. readonly layoutInfo: EditorLayoutInfo;
  3088. readonly fontInfo: FontInfo;
  3089. readonly viewInfo: InternalEditorViewOptions;
  3090. readonly wrappingInfo: EditorWrappingInfo;
  3091. readonly contribInfo: EditorContribOptions;
  3092. }
  3093. /**
  3094. * A description for the overview ruler position.
  3095. */
  3096. export interface OverviewRulerPosition {
  3097. /**
  3098. * Width of the overview ruler
  3099. */
  3100. readonly width: number;
  3101. /**
  3102. * Height of the overview ruler
  3103. */
  3104. readonly height: number;
  3105. /**
  3106. * Top position for the overview ruler
  3107. */
  3108. readonly top: number;
  3109. /**
  3110. * Right position for the overview ruler
  3111. */
  3112. readonly right: number;
  3113. }
  3114. /**
  3115. * The internal layout details of the editor.
  3116. */
  3117. export interface EditorLayoutInfo {
  3118. /**
  3119. * Full editor width.
  3120. */
  3121. readonly width: number;
  3122. /**
  3123. * Full editor height.
  3124. */
  3125. readonly height: number;
  3126. /**
  3127. * Left position for the glyph margin.
  3128. */
  3129. readonly glyphMarginLeft: number;
  3130. /**
  3131. * The width of the glyph margin.
  3132. */
  3133. readonly glyphMarginWidth: number;
  3134. /**
  3135. * The height of the glyph margin.
  3136. */
  3137. readonly glyphMarginHeight: number;
  3138. /**
  3139. * Left position for the line numbers.
  3140. */
  3141. readonly lineNumbersLeft: number;
  3142. /**
  3143. * The width of the line numbers.
  3144. */
  3145. readonly lineNumbersWidth: number;
  3146. /**
  3147. * The height of the line numbers.
  3148. */
  3149. readonly lineNumbersHeight: number;
  3150. /**
  3151. * Left position for the line decorations.
  3152. */
  3153. readonly decorationsLeft: number;
  3154. /**
  3155. * The width of the line decorations.
  3156. */
  3157. readonly decorationsWidth: number;
  3158. /**
  3159. * The height of the line decorations.
  3160. */
  3161. readonly decorationsHeight: number;
  3162. /**
  3163. * Left position for the content (actual text)
  3164. */
  3165. readonly contentLeft: number;
  3166. /**
  3167. * The width of the content (actual text)
  3168. */
  3169. readonly contentWidth: number;
  3170. /**
  3171. * The height of the content (actual height)
  3172. */
  3173. readonly contentHeight: number;
  3174. /**
  3175. * The position for the minimap
  3176. */
  3177. readonly minimapLeft: number;
  3178. /**
  3179. * The width of the minimap
  3180. */
  3181. readonly minimapWidth: number;
  3182. /**
  3183. * Minimap render type
  3184. */
  3185. readonly renderMinimap: RenderMinimap;
  3186. /**
  3187. * The number of columns (of typical characters) fitting on a viewport line.
  3188. */
  3189. readonly viewportColumn: number;
  3190. /**
  3191. * The width of the vertical scrollbar.
  3192. */
  3193. readonly verticalScrollbarWidth: number;
  3194. /**
  3195. * The height of the horizontal scrollbar.
  3196. */
  3197. readonly horizontalScrollbarHeight: number;
  3198. /**
  3199. * The position of the overview ruler.
  3200. */
  3201. readonly overviewRuler: OverviewRulerPosition;
  3202. }
  3203. /**
  3204. * An event describing that the configuration of the editor has changed.
  3205. */
  3206. export interface IConfigurationChangedEvent {
  3207. readonly canUseLayerHinting: boolean;
  3208. readonly pixelRatio: boolean;
  3209. readonly editorClassName: boolean;
  3210. readonly lineHeight: boolean;
  3211. readonly readOnly: boolean;
  3212. readonly accessibilitySupport: boolean;
  3213. readonly multiCursorModifier: boolean;
  3214. readonly multiCursorMergeOverlapping: boolean;
  3215. readonly wordSeparators: boolean;
  3216. readonly autoClosingBrackets: boolean;
  3217. readonly autoIndent: boolean;
  3218. readonly useTabStops: boolean;
  3219. readonly tabFocusMode: boolean;
  3220. readonly dragAndDrop: boolean;
  3221. readonly emptySelectionClipboard: boolean;
  3222. readonly layoutInfo: boolean;
  3223. readonly fontInfo: boolean;
  3224. readonly viewInfo: boolean;
  3225. readonly wrappingInfo: boolean;
  3226. readonly contribInfo: boolean;
  3227. }
  3228. /**
  3229. * A view zone is a full horizontal rectangle that 'pushes' text down.
  3230. * The editor reserves space for view zones when rendering.
  3231. */
  3232. export interface IViewZone {
  3233. /**
  3234. * The line number after which this zone should appear.
  3235. * Use 0 to place a view zone before the first line number.
  3236. */
  3237. afterLineNumber: number;
  3238. /**
  3239. * The column after which this zone should appear.
  3240. * If not set, the maxLineColumn of `afterLineNumber` will be used.
  3241. */
  3242. afterColumn?: number;
  3243. /**
  3244. * Suppress mouse down events.
  3245. * If set, the editor will attach a mouse down listener to the view zone and .preventDefault on it.
  3246. * Defaults to false
  3247. */
  3248. suppressMouseDown?: boolean;
  3249. /**
  3250. * The height in lines of the view zone.
  3251. * If specified, `heightInPx` will be used instead of this.
  3252. * If neither `heightInPx` nor `heightInLines` is specified, a default of `heightInLines` = 1 will be chosen.
  3253. */
  3254. heightInLines?: number;
  3255. /**
  3256. * The height in px of the view zone.
  3257. * If this is set, the editor will give preference to it rather than `heightInLines` above.
  3258. * If neither `heightInPx` nor `heightInLines` is specified, a default of `heightInLines` = 1 will be chosen.
  3259. */
  3260. heightInPx?: number;
  3261. /**
  3262. * The minimum width in px of the view zone.
  3263. * If this is set, the editor will ensure that the scroll width is >= than this value.
  3264. */
  3265. minWidthInPx?: number;
  3266. /**
  3267. * The dom node of the view zone
  3268. */
  3269. domNode: HTMLElement;
  3270. /**
  3271. * An optional dom node for the view zone that will be placed in the margin area.
  3272. */
  3273. marginDomNode?: HTMLElement;
  3274. /**
  3275. * Callback which gives the relative top of the view zone as it appears (taking scrolling into account).
  3276. */
  3277. onDomNodeTop?: (top: number) => void;
  3278. /**
  3279. * Callback which gives the height in pixels of the view zone.
  3280. */
  3281. onComputedHeight?: (height: number) => void;
  3282. }
  3283. /**
  3284. * An accessor that allows for zones to be added or removed.
  3285. */
  3286. export interface IViewZoneChangeAccessor {
  3287. /**
  3288. * Create a new view zone.
  3289. * @param zone Zone to create
  3290. * @return A unique identifier to the view zone.
  3291. */
  3292. addZone(zone: IViewZone): number;
  3293. /**
  3294. * Remove a zone
  3295. * @param id A unique identifier to the view zone, as returned by the `addZone` call.
  3296. */
  3297. removeZone(id: number): void;
  3298. /**
  3299. * Change a zone's position.
  3300. * The editor will rescan the `afterLineNumber` and `afterColumn` properties of a view zone.
  3301. */
  3302. layoutZone(id: number): void;
  3303. }
  3304. /**
  3305. * A positioning preference for rendering content widgets.
  3306. */
  3307. export enum ContentWidgetPositionPreference {
  3308. /**
  3309. * Place the content widget exactly at a position
  3310. */
  3311. EXACT = 0,
  3312. /**
  3313. * Place the content widget above a position
  3314. */
  3315. ABOVE = 1,
  3316. /**
  3317. * Place the content widget below a position
  3318. */
  3319. BELOW = 2
  3320. }
  3321. /**
  3322. * A position for rendering content widgets.
  3323. */
  3324. export interface IContentWidgetPosition {
  3325. /**
  3326. * Desired position for the content widget.
  3327. * `preference` will also affect the placement.
  3328. */
  3329. position: IPosition;
  3330. /**
  3331. * Placement preference for position, in order of preference.
  3332. */
  3333. preference: ContentWidgetPositionPreference[];
  3334. }
  3335. /**
  3336. * A content widget renders inline with the text and can be easily placed 'near' an editor position.
  3337. */
  3338. export interface IContentWidget {
  3339. /**
  3340. * Render this content widget in a location where it could overflow the editor's view dom node.
  3341. */
  3342. allowEditorOverflow?: boolean;
  3343. suppressMouseDown?: boolean;
  3344. /**
  3345. * Get a unique identifier of the content widget.
  3346. */
  3347. getId(): string;
  3348. /**
  3349. * Get the dom node of the content widget.
  3350. */
  3351. getDomNode(): HTMLElement;
  3352. /**
  3353. * Get the placement of the content widget.
  3354. * If null is returned, the content widget will be placed off screen.
  3355. */
  3356. getPosition(): IContentWidgetPosition;
  3357. }
  3358. /**
  3359. * A positioning preference for rendering overlay widgets.
  3360. */
  3361. export enum OverlayWidgetPositionPreference {
  3362. /**
  3363. * Position the overlay widget in the top right corner
  3364. */
  3365. TOP_RIGHT_CORNER = 0,
  3366. /**
  3367. * Position the overlay widget in the bottom right corner
  3368. */
  3369. BOTTOM_RIGHT_CORNER = 1,
  3370. /**
  3371. * Position the overlay widget in the top center
  3372. */
  3373. TOP_CENTER = 2
  3374. }
  3375. /**
  3376. * A position for rendering overlay widgets.
  3377. */
  3378. export interface IOverlayWidgetPosition {
  3379. /**
  3380. * The position preference for the overlay widget.
  3381. */
  3382. preference: OverlayWidgetPositionPreference;
  3383. }
  3384. /**
  3385. * An overlay widgets renders on top of the text.
  3386. */
  3387. export interface IOverlayWidget {
  3388. /**
  3389. * Get a unique identifier of the overlay widget.
  3390. */
  3391. getId(): string;
  3392. /**
  3393. * Get the dom node of the overlay widget.
  3394. */
  3395. getDomNode(): HTMLElement;
  3396. /**
  3397. * Get the placement of the overlay widget.
  3398. * If null is returned, the overlay widget is responsible to place itself.
  3399. */
  3400. getPosition(): IOverlayWidgetPosition;
  3401. }
  3402. /**
  3403. * Type of hit element with the mouse in the editor.
  3404. */
  3405. export enum MouseTargetType {
  3406. /**
  3407. * Mouse is on top of an unknown element.
  3408. */
  3409. UNKNOWN = 0,
  3410. /**
  3411. * Mouse is on top of the textarea used for input.
  3412. */
  3413. TEXTAREA = 1,
  3414. /**
  3415. * Mouse is on top of the glyph margin
  3416. */
  3417. GUTTER_GLYPH_MARGIN = 2,
  3418. /**
  3419. * Mouse is on top of the line numbers
  3420. */
  3421. GUTTER_LINE_NUMBERS = 3,
  3422. /**
  3423. * Mouse is on top of the line decorations
  3424. */
  3425. GUTTER_LINE_DECORATIONS = 4,
  3426. /**
  3427. * Mouse is on top of the whitespace left in the gutter by a view zone.
  3428. */
  3429. GUTTER_VIEW_ZONE = 5,
  3430. /**
  3431. * Mouse is on top of text in the content.
  3432. */
  3433. CONTENT_TEXT = 6,
  3434. /**
  3435. * Mouse is on top of empty space in the content (e.g. after line text or below last line)
  3436. */
  3437. CONTENT_EMPTY = 7,
  3438. /**
  3439. * Mouse is on top of a view zone in the content.
  3440. */
  3441. CONTENT_VIEW_ZONE = 8,
  3442. /**
  3443. * Mouse is on top of a content widget.
  3444. */
  3445. CONTENT_WIDGET = 9,
  3446. /**
  3447. * Mouse is on top of the decorations overview ruler.
  3448. */
  3449. OVERVIEW_RULER = 10,
  3450. /**
  3451. * Mouse is on top of a scrollbar.
  3452. */
  3453. SCROLLBAR = 11,
  3454. /**
  3455. * Mouse is on top of an overlay widget.
  3456. */
  3457. OVERLAY_WIDGET = 12,
  3458. /**
  3459. * Mouse is outside of the editor.
  3460. */
  3461. OUTSIDE_EDITOR = 13
  3462. }
  3463. /**
  3464. * Target hit with the mouse in the editor.
  3465. */
  3466. export interface IMouseTarget {
  3467. /**
  3468. * The target element
  3469. */
  3470. readonly element: Element;
  3471. /**
  3472. * The target type
  3473. */
  3474. readonly type: MouseTargetType;
  3475. /**
  3476. * The 'approximate' editor position
  3477. */
  3478. readonly position: Position;
  3479. /**
  3480. * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line).
  3481. */
  3482. readonly mouseColumn: number;
  3483. /**
  3484. * The 'approximate' editor range
  3485. */
  3486. readonly range: Range;
  3487. /**
  3488. * Some extra detail.
  3489. */
  3490. readonly detail: any;
  3491. }
  3492. /**
  3493. * A mouse event originating from the editor.
  3494. */
  3495. export interface IEditorMouseEvent {
  3496. readonly event: IMouseEvent;
  3497. readonly target: IMouseTarget;
  3498. }
  3499. /**
  3500. * A rich code editor.
  3501. */
  3502. export interface ICodeEditor extends IEditor {
  3503. /**
  3504. * An event emitted when the content of the current model has changed.
  3505. * @event
  3506. */
  3507. onDidChangeModelContent(listener: (e: IModelContentChangedEvent) => void): IDisposable;
  3508. /**
  3509. * An event emitted when the language of the current model has changed.
  3510. * @event
  3511. */
  3512. onDidChangeModelLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable;
  3513. /**
  3514. * An event emitted when the language configuration of the current model has changed.
  3515. * @event
  3516. */
  3517. onDidChangeModelLanguageConfiguration(listener: (e: IModelLanguageConfigurationChangedEvent) => void): IDisposable;
  3518. /**
  3519. * An event emitted when the options of the current model has changed.
  3520. * @event
  3521. */
  3522. onDidChangeModelOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable;
  3523. /**
  3524. * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`)
  3525. * @event
  3526. */
  3527. onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable;
  3528. /**
  3529. * An event emitted when the cursor position has changed.
  3530. * @event
  3531. */
  3532. onDidChangeCursorPosition(listener: (e: ICursorPositionChangedEvent) => void): IDisposable;
  3533. /**
  3534. * An event emitted when the cursor selection has changed.
  3535. * @event
  3536. */
  3537. onDidChangeCursorSelection(listener: (e: ICursorSelectionChangedEvent) => void): IDisposable;
  3538. /**
  3539. * An event emitted when the model of this editor has changed (e.g. `editor.setModel()`).
  3540. * @event
  3541. */
  3542. onDidChangeModel(listener: (e: IModelChangedEvent) => void): IDisposable;
  3543. /**
  3544. * An event emitted when the decorations of the current model have changed.
  3545. * @event
  3546. */
  3547. onDidChangeModelDecorations(listener: (e: IModelDecorationsChangedEvent) => void): IDisposable;
  3548. /**
  3549. * An event emitted when the text inside this editor gained focus (i.e. cursor starts blinking).
  3550. * @event
  3551. */
  3552. onDidFocusEditorText(listener: () => void): IDisposable;
  3553. /**
  3554. * An event emitted when the text inside this editor lost focus (i.e. cursor stops blinking).
  3555. * @event
  3556. */
  3557. onDidBlurEditorText(listener: () => void): IDisposable;
  3558. /**
  3559. * An event emitted when the text inside this editor or an editor widget gained focus.
  3560. * @event
  3561. */
  3562. onDidFocusEditorWidget(listener: () => void): IDisposable;
  3563. /**
  3564. * An event emitted when the text inside this editor or an editor widget lost focus.
  3565. * @event
  3566. */
  3567. onDidBlurEditorWidget(listener: () => void): IDisposable;
  3568. /**
  3569. * An event emitted on a "mouseup".
  3570. * @event
  3571. */
  3572. onMouseUp(listener: (e: IEditorMouseEvent) => void): IDisposable;
  3573. /**
  3574. * An event emitted on a "mousedown".
  3575. * @event
  3576. */
  3577. onMouseDown(listener: (e: IEditorMouseEvent) => void): IDisposable;
  3578. /**
  3579. * An event emitted on a "contextmenu".
  3580. * @event
  3581. */
  3582. onContextMenu(listener: (e: IEditorMouseEvent) => void): IDisposable;
  3583. /**
  3584. * An event emitted on a "mousemove".
  3585. * @event
  3586. */
  3587. onMouseMove(listener: (e: IEditorMouseEvent) => void): IDisposable;
  3588. /**
  3589. * An event emitted on a "mouseleave".
  3590. * @event
  3591. */
  3592. onMouseLeave(listener: (e: IEditorMouseEvent) => void): IDisposable;
  3593. /**
  3594. * An event emitted on a "keyup".
  3595. * @event
  3596. */
  3597. onKeyUp(listener: (e: IKeyboardEvent) => void): IDisposable;
  3598. /**
  3599. * An event emitted on a "keydown".
  3600. * @event
  3601. */
  3602. onKeyDown(listener: (e: IKeyboardEvent) => void): IDisposable;
  3603. /**
  3604. * An event emitted when the layout of the editor has changed.
  3605. * @event
  3606. */
  3607. onDidLayoutChange(listener: (e: EditorLayoutInfo) => void): IDisposable;
  3608. /**
  3609. * An event emitted when the scroll in the editor has changed.
  3610. * @event
  3611. */
  3612. onDidScrollChange(listener: (e: IScrollEvent) => void): IDisposable;
  3613. /**
  3614. * Saves current view state of the editor in a serializable object.
  3615. */
  3616. saveViewState(): ICodeEditorViewState;
  3617. /**
  3618. * Restores the view state of the editor from a serializable object generated by `saveViewState`.
  3619. */
  3620. restoreViewState(state: ICodeEditorViewState): void;
  3621. /**
  3622. * Returns true if the text inside this editor or an editor widget has focus.
  3623. */
  3624. hasWidgetFocus(): boolean;
  3625. /**
  3626. * Get a contribution of this editor.
  3627. * @id Unique identifier of the contribution.
  3628. * @return The contribution or null if contribution not found.
  3629. */
  3630. getContribution<T extends IEditorContribution>(id: string): T;
  3631. /**
  3632. * Type the getModel() of IEditor.
  3633. */
  3634. getModel(): ITextModel;
  3635. /**
  3636. * Returns the current editor's configuration
  3637. */
  3638. getConfiguration(): InternalEditorOptions;
  3639. /**
  3640. * Get value of the current model attached to this editor.
  3641. * @see `ITextModel.getValue`
  3642. */
  3643. getValue(options?: {
  3644. preserveBOM: boolean;
  3645. lineEnding: string;
  3646. }): string;
  3647. /**
  3648. * Set the value of the current model attached to this editor.
  3649. * @see `ITextModel.setValue`
  3650. */
  3651. setValue(newValue: string): void;
  3652. /**
  3653. * Get the scrollWidth of the editor's viewport.
  3654. */
  3655. getScrollWidth(): number;
  3656. /**
  3657. * Get the scrollLeft of the editor's viewport.
  3658. */
  3659. getScrollLeft(): number;
  3660. /**
  3661. * Get the scrollHeight of the editor's viewport.
  3662. */
  3663. getScrollHeight(): number;
  3664. /**
  3665. * Get the scrollTop of the editor's viewport.
  3666. */
  3667. getScrollTop(): number;
  3668. /**
  3669. * Change the scrollLeft of the editor's viewport.
  3670. */
  3671. setScrollLeft(newScrollLeft: number): void;
  3672. /**
  3673. * Change the scrollTop of the editor's viewport.
  3674. */
  3675. setScrollTop(newScrollTop: number): void;
  3676. /**
  3677. * Change the scroll position of the editor's viewport.
  3678. */
  3679. setScrollPosition(position: INewScrollPosition): void;
  3680. /**
  3681. * Get an action that is a contribution to this editor.
  3682. * @id Unique identifier of the contribution.
  3683. * @return The action or null if action not found.
  3684. */
  3685. getAction(id: string): IEditorAction;
  3686. /**
  3687. * Execute a command on the editor.
  3688. * The edits will land on the undo-redo stack, but no "undo stop" will be pushed.
  3689. * @param source The source of the call.
  3690. * @param command The command to execute
  3691. */
  3692. executeCommand(source: string, command: ICommand): void;
  3693. /**
  3694. * Push an "undo stop" in the undo-redo stack.
  3695. */
  3696. pushUndoStop(): boolean;
  3697. /**
  3698. * Execute edits on the editor.
  3699. * The edits will land on the undo-redo stack, but no "undo stop" will be pushed.
  3700. * @param source The source of the call.
  3701. * @param edits The edits to execute.
  3702. * @param endCursorState Cursor state after the edits were applied.
  3703. */
  3704. executeEdits(source: string, edits: IIdentifiedSingleEditOperation[], endCursorState?: Selection[]): boolean;
  3705. /**
  3706. * Execute multiple (concommitent) commands on the editor.
  3707. * @param source The source of the call.
  3708. * @param command The commands to execute
  3709. */
  3710. executeCommands(source: string, commands: ICommand[]): void;
  3711. /**
  3712. * Get all the decorations on a line (filtering out decorations from other editors).
  3713. */
  3714. getLineDecorations(lineNumber: number): IModelDecoration[];
  3715. /**
  3716. * All decorations added through this call will get the ownerId of this editor.
  3717. * @see `ITextModel.deltaDecorations`
  3718. */
  3719. deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[]): string[];
  3720. /**
  3721. * Get the layout info for the editor.
  3722. */
  3723. getLayoutInfo(): EditorLayoutInfo;
  3724. /**
  3725. * Returns the ranges that are currently visible.
  3726. * Does not account for horizontal scrolling.
  3727. */
  3728. getVisibleRanges(): Range[];
  3729. /**
  3730. * Get the vertical position (top offset) for the line w.r.t. to the first line.
  3731. */
  3732. getTopForLineNumber(lineNumber: number): number;
  3733. /**
  3734. * Get the vertical position (top offset) for the position w.r.t. to the first line.
  3735. */
  3736. getTopForPosition(lineNumber: number, column: number): number;
  3737. /**
  3738. * Returns the editor's dom node
  3739. */
  3740. getDomNode(): HTMLElement;
  3741. /**
  3742. * Add a content widget. Widgets must have unique ids, otherwise they will be overwritten.
  3743. */
  3744. addContentWidget(widget: IContentWidget): void;
  3745. /**
  3746. * Layout/Reposition a content widget. This is a ping to the editor to call widget.getPosition()
  3747. * and update appropiately.
  3748. */
  3749. layoutContentWidget(widget: IContentWidget): void;
  3750. /**
  3751. * Remove a content widget.
  3752. */
  3753. removeContentWidget(widget: IContentWidget): void;
  3754. /**
  3755. * Add an overlay widget. Widgets must have unique ids, otherwise they will be overwritten.
  3756. */
  3757. addOverlayWidget(widget: IOverlayWidget): void;
  3758. /**
  3759. * Layout/Reposition an overlay widget. This is a ping to the editor to call widget.getPosition()
  3760. * and update appropiately.
  3761. */
  3762. layoutOverlayWidget(widget: IOverlayWidget): void;
  3763. /**
  3764. * Remove an overlay widget.
  3765. */
  3766. removeOverlayWidget(widget: IOverlayWidget): void;
  3767. /**
  3768. * Change the view zones. View zones are lost when a new model is attached to the editor.
  3769. */
  3770. changeViewZones(callback: (accessor: IViewZoneChangeAccessor) => void): void;
  3771. /**
  3772. * Get the horizontal position (left offset) for the column w.r.t to the beginning of the line.
  3773. * This method works only if the line `lineNumber` is currently rendered (in the editor's viewport).
  3774. * Use this method with caution.
  3775. */
  3776. getOffsetForColumn(lineNumber: number, column: number): number;
  3777. /**
  3778. * Force an editor render now.
  3779. */
  3780. render(): void;
  3781. /**
  3782. * Get the hit test target at coordinates `clientX` and `clientY`.
  3783. * The coordinates are relative to the top-left of the viewport.
  3784. *
  3785. * @returns Hit test target or null if the coordinates fall outside the editor or the editor has no model.
  3786. */
  3787. getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget;
  3788. /**
  3789. * Get the visible position for `position`.
  3790. * The result position takes scrolling into account and is relative to the top left corner of the editor.
  3791. * Explanation 1: the results of this method will change for the same `position` if the user scrolls the editor.
  3792. * Explanation 2: the results of this method will not change if the container of the editor gets repositioned.
  3793. * Warning: the results of this method are innacurate for positions that are outside the current editor viewport.
  3794. */
  3795. getScrolledVisiblePosition(position: IPosition): {
  3796. top: number;
  3797. left: number;
  3798. height: number;
  3799. };
  3800. /**
  3801. * Apply the same font settings as the editor to `target`.
  3802. */
  3803. applyFontInfo(target: HTMLElement): void;
  3804. }
  3805. /**
  3806. * Information about a line in the diff editor
  3807. */
  3808. export interface IDiffLineInformation {
  3809. readonly equivalentLineNumber: number;
  3810. }
  3811. /**
  3812. * A rich diff editor.
  3813. */
  3814. export interface IDiffEditor extends IEditor {
  3815. /**
  3816. * @see ICodeEditor.getDomNode
  3817. */
  3818. getDomNode(): HTMLElement;
  3819. /**
  3820. * An event emitted when the diff information computed by this diff editor has been updated.
  3821. * @event
  3822. */
  3823. onDidUpdateDiff(listener: () => void): IDisposable;
  3824. /**
  3825. * Saves current view state of the editor in a serializable object.
  3826. */
  3827. saveViewState(): IDiffEditorViewState;
  3828. /**
  3829. * Restores the view state of the editor from a serializable object generated by `saveViewState`.
  3830. */
  3831. restoreViewState(state: IDiffEditorViewState): void;
  3832. /**
  3833. * Type the getModel() of IEditor.
  3834. */
  3835. getModel(): IDiffEditorModel;
  3836. /**
  3837. * Get the `original` editor.
  3838. */
  3839. getOriginalEditor(): ICodeEditor;
  3840. /**
  3841. * Get the `modified` editor.
  3842. */
  3843. getModifiedEditor(): ICodeEditor;
  3844. /**
  3845. * Get the computed diff information.
  3846. */
  3847. getLineChanges(): ILineChange[];
  3848. /**
  3849. * Get information based on computed diff about a line number from the original model.
  3850. * If the diff computation is not finished or the model is missing, will return null.
  3851. */
  3852. getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation;
  3853. /**
  3854. * Get information based on computed diff about a line number from the modified model.
  3855. * If the diff computation is not finished or the model is missing, will return null.
  3856. */
  3857. getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation;
  3858. }
  3859. export class FontInfo extends BareFontInfo {
  3860. readonly _editorStylingBrand: void;
  3861. readonly isTrusted: boolean;
  3862. readonly isMonospace: boolean;
  3863. readonly typicalHalfwidthCharacterWidth: number;
  3864. readonly typicalFullwidthCharacterWidth: number;
  3865. readonly spaceWidth: number;
  3866. readonly maxDigitWidth: number;
  3867. }
  3868. export class BareFontInfo {
  3869. readonly _bareFontInfoBrand: void;
  3870. readonly zoomLevel: number;
  3871. readonly fontFamily: string;
  3872. readonly fontWeight: string;
  3873. readonly fontSize: number;
  3874. readonly lineHeight: number;
  3875. readonly letterSpacing: number;
  3876. }
  3877. //compatibility:
  3878. export type IReadOnlyModel = ITextModel;
  3879. export type IModel = ITextModel;
  3880. }
  3881. declare namespace monaco.languages {
  3882. /**
  3883. * Register information about a new language.
  3884. */
  3885. export function register(language: ILanguageExtensionPoint): void;
  3886. /**
  3887. * Get the information of all the registered languages.
  3888. */
  3889. export function getLanguages(): ILanguageExtensionPoint[];
  3890. export function getEncodedLanguageId(languageId: string): number;
  3891. /**
  3892. * An event emitted when a language is first time needed (e.g. a model has it set).
  3893. * @event
  3894. */
  3895. export function onLanguage(languageId: string, callback: () => void): IDisposable;
  3896. /**
  3897. * Set the editing configuration for a language.
  3898. */
  3899. export function setLanguageConfiguration(languageId: string, configuration: LanguageConfiguration): IDisposable;
  3900. /**
  3901. * A token.
  3902. */
  3903. export interface IToken {
  3904. startIndex: number;
  3905. scopes: string;
  3906. }
  3907. /**
  3908. * The result of a line tokenization.
  3909. */
  3910. export interface ILineTokens {
  3911. /**
  3912. * The list of tokens on the line.
  3913. */
  3914. tokens: IToken[];
  3915. /**
  3916. * The tokenization end state.
  3917. * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned.
  3918. */
  3919. endState: IState;
  3920. }
  3921. /**
  3922. * The result of a line tokenization.
  3923. */
  3924. export interface IEncodedLineTokens {
  3925. /**
  3926. * The tokens on the line in a binary, encoded format. Each token occupies two array indices. For token i:
  3927. * - at offset 2*i => startIndex
  3928. * - at offset 2*i + 1 => metadata
  3929. * Meta data is in binary format:
  3930. * - -------------------------------------------
  3931. * 3322 2222 2222 1111 1111 1100 0000 0000
  3932. * 1098 7654 3210 9876 5432 1098 7654 3210
  3933. * - -------------------------------------------
  3934. * bbbb bbbb bfff ffff ffFF FTTT LLLL LLLL
  3935. * - -------------------------------------------
  3936. * - L = EncodedLanguageId (8 bits): Use `getEncodedLanguageId` to get the encoded ID of a language.
  3937. * - T = StandardTokenType (3 bits): Other = 0, Comment = 1, String = 2, RegEx = 4.
  3938. * - F = FontStyle (3 bits): None = 0, Italic = 1, Bold = 2, Underline = 4.
  3939. * - f = foreground ColorId (9 bits)
  3940. * - b = background ColorId (9 bits)
  3941. * - The color value for each colorId is defined in IStandaloneThemeData.customTokenColors:
  3942. * e.g colorId = 1 is stored in IStandaloneThemeData.customTokenColors[1]. Color id = 0 means no color,
  3943. * id = 1 is for the default foreground color, id = 2 for the default background.
  3944. */
  3945. tokens: Uint32Array;
  3946. /**
  3947. * The tokenization end state.
  3948. * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned.
  3949. */
  3950. endState: IState;
  3951. }
  3952. /**
  3953. * A "manual" provider of tokens.
  3954. */
  3955. export interface TokensProvider {
  3956. /**
  3957. * The initial state of a language. Will be the state passed in to tokenize the first line.
  3958. */
  3959. getInitialState(): IState;
  3960. /**
  3961. * Tokenize a line given the state at the beginning of the line.
  3962. */
  3963. tokenize(line: string, state: IState): ILineTokens;
  3964. }
  3965. /**
  3966. * A "manual" provider of tokens, returning tokens in a binary form.
  3967. */
  3968. export interface EncodedTokensProvider {
  3969. /**
  3970. * The initial state of a language. Will be the state passed in to tokenize the first line.
  3971. */
  3972. getInitialState(): IState;
  3973. /**
  3974. * Tokenize a line given the state at the beginning of the line.
  3975. */
  3976. tokenizeEncoded(line: string, state: IState): IEncodedLineTokens;
  3977. }
  3978. /**
  3979. * Set the tokens provider for a language (manual implementation).
  3980. */
  3981. export function setTokensProvider(languageId: string, provider: TokensProvider | EncodedTokensProvider): IDisposable;
  3982. /**
  3983. * Set the tokens provider for a language (monarch implementation).
  3984. */
  3985. export function setMonarchTokensProvider(languageId: string, languageDef: IMonarchLanguage): IDisposable;
  3986. /**
  3987. * Register a reference provider (used by e.g. reference search).
  3988. */
  3989. export function registerReferenceProvider(languageId: string, provider: ReferenceProvider): IDisposable;
  3990. /**
  3991. * Register a rename provider (used by e.g. rename symbol).
  3992. */
  3993. export function registerRenameProvider(languageId: string, provider: RenameProvider): IDisposable;
  3994. /**
  3995. * Register a signature help provider (used by e.g. paremeter hints).
  3996. */
  3997. export function registerSignatureHelpProvider(languageId: string, provider: SignatureHelpProvider): IDisposable;
  3998. /**
  3999. * Register a hover provider (used by e.g. editor hover).
  4000. */
  4001. export function registerHoverProvider(languageId: string, provider: HoverProvider): IDisposable;
  4002. /**
  4003. * Register a document symbol provider (used by e.g. outline).
  4004. */
  4005. export function registerDocumentSymbolProvider(languageId: string, provider: DocumentSymbolProvider): IDisposable;
  4006. /**
  4007. * Register a document highlight provider (used by e.g. highlight occurrences).
  4008. */
  4009. export function registerDocumentHighlightProvider(languageId: string, provider: DocumentHighlightProvider): IDisposable;
  4010. /**
  4011. * Register a definition provider (used by e.g. go to definition).
  4012. */
  4013. export function registerDefinitionProvider(languageId: string, provider: DefinitionProvider): IDisposable;
  4014. /**
  4015. * Register a implementation provider (used by e.g. go to implementation).
  4016. */
  4017. export function registerImplementationProvider(languageId: string, provider: ImplementationProvider): IDisposable;
  4018. /**
  4019. * Register a type definition provider (used by e.g. go to type definition).
  4020. */
  4021. export function registerTypeDefinitionProvider(languageId: string, provider: TypeDefinitionProvider): IDisposable;
  4022. /**
  4023. * Register a code lens provider (used by e.g. inline code lenses).
  4024. */
  4025. export function registerCodeLensProvider(languageId: string, provider: CodeLensProvider): IDisposable;
  4026. /**
  4027. * Register a code action provider (used by e.g. quick fix).
  4028. */
  4029. export function registerCodeActionProvider(languageId: string, provider: CodeActionProvider): IDisposable;
  4030. /**
  4031. * Register a formatter that can handle only entire models.
  4032. */
  4033. export function registerDocumentFormattingEditProvider(languageId: string, provider: DocumentFormattingEditProvider): IDisposable;
  4034. /**
  4035. * Register a formatter that can handle a range inside a model.
  4036. */
  4037. export function registerDocumentRangeFormattingEditProvider(languageId: string, provider: DocumentRangeFormattingEditProvider): IDisposable;
  4038. /**
  4039. * Register a formatter than can do formatting as the user types.
  4040. */
  4041. export function registerOnTypeFormattingEditProvider(languageId: string, provider: OnTypeFormattingEditProvider): IDisposable;
  4042. /**
  4043. * Register a link provider that can find links in text.
  4044. */
  4045. export function registerLinkProvider(languageId: string, provider: LinkProvider): IDisposable;
  4046. /**
  4047. * Register a completion item provider (use by e.g. suggestions).
  4048. */
  4049. export function registerCompletionItemProvider(languageId: string, provider: CompletionItemProvider): IDisposable;
  4050. /**
  4051. * Register a document color provider (used by Color Picker, Color Decorator).
  4052. */
  4053. export function registerColorProvider(languageId: string, provider: DocumentColorProvider): IDisposable;
  4054. /**
  4055. * Register a folding range provider
  4056. */
  4057. export function registerFoldingRangeProvider(languageId: string, provider: FoldingRangeProvider): IDisposable;
  4058. /**
  4059. * Contains additional diagnostic information about the context in which
  4060. * a [code action](#CodeActionProvider.provideCodeActions) is run.
  4061. */
  4062. export interface CodeActionContext {
  4063. /**
  4064. * An array of diagnostics.
  4065. *
  4066. * @readonly
  4067. */
  4068. readonly markers: editor.IMarkerData[];
  4069. /**
  4070. * Requested kind of actions to return.
  4071. */
  4072. readonly only?: string;
  4073. }
  4074. /**
  4075. * The code action interface defines the contract between extensions and
  4076. * the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
  4077. */
  4078. export interface CodeActionProvider {
  4079. /**
  4080. * Provide commands for the given document and range.
  4081. */
  4082. provideCodeActions(model: editor.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): (Command | CodeAction)[] | Thenable<(Command | CodeAction)[]>;
  4083. }
  4084. /**
  4085. * Completion item kinds.
  4086. */
  4087. export enum CompletionItemKind {
  4088. Text = 0,
  4089. Method = 1,
  4090. Function = 2,
  4091. Constructor = 3,
  4092. Field = 4,
  4093. Variable = 5,
  4094. Class = 6,
  4095. Interface = 7,
  4096. Module = 8,
  4097. Property = 9,
  4098. Unit = 10,
  4099. Value = 11,
  4100. Enum = 12,
  4101. Keyword = 13,
  4102. Snippet = 14,
  4103. Color = 15,
  4104. File = 16,
  4105. Reference = 17,
  4106. Folder = 18
  4107. }
  4108. /**
  4109. * A snippet string is a template which allows to insert text
  4110. * and to control the editor cursor when insertion happens.
  4111. *
  4112. * A snippet can define tab stops and placeholders with `$1`, `$2`
  4113. * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
  4114. * the end of the snippet. Variables are defined with `$name` and
  4115. * `${name:default value}`. The full snippet syntax is documented
  4116. * [here](http://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets).
  4117. */
  4118. export interface SnippetString {
  4119. /**
  4120. * The snippet string.
  4121. */
  4122. value: string;
  4123. }
  4124. /**
  4125. * A completion item represents a text snippet that is
  4126. * proposed to complete text that is being typed.
  4127. */
  4128. export interface CompletionItem {
  4129. /**
  4130. * The label of this completion item. By default
  4131. * this is also the text that is inserted when selecting
  4132. * this completion.
  4133. */
  4134. label: string;
  4135. /**
  4136. * The kind of this completion item. Based on the kind
  4137. * an icon is chosen by the editor.
  4138. */
  4139. kind: CompletionItemKind;
  4140. /**
  4141. * A human-readable string with additional information
  4142. * about this item, like type or symbol information.
  4143. */
  4144. detail?: string;
  4145. /**
  4146. * A human-readable string that represents a doc-comment.
  4147. */
  4148. documentation?: string | IMarkdownString;
  4149. /**
  4150. * A command that should be run upon acceptance of this item.
  4151. */
  4152. command?: Command;
  4153. /**
  4154. * A string that should be used when comparing this item
  4155. * with other items. When `falsy` the [label](#CompletionItem.label)
  4156. * is used.
  4157. */
  4158. sortText?: string;
  4159. /**
  4160. * A string that should be used when filtering a set of
  4161. * completion items. When `falsy` the [label](#CompletionItem.label)
  4162. * is used.
  4163. */
  4164. filterText?: string;
  4165. /**
  4166. * A string or snippet that should be inserted in a document when selecting
  4167. * this completion. When `falsy` the [label](#CompletionItem.label)
  4168. * is used.
  4169. */
  4170. insertText?: string | SnippetString;
  4171. /**
  4172. * A range of text that should be replaced by this completion item.
  4173. *
  4174. * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
  4175. * current position.
  4176. *
  4177. * *Note:* The range must be a [single line](#Range.isSingleLine) and it must
  4178. * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems).
  4179. */
  4180. range?: Range;
  4181. /**
  4182. * An optional set of characters that when pressed while this completion is active will accept it first and
  4183. * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
  4184. * characters will be ignored.
  4185. */
  4186. commitCharacters?: string[];
  4187. /**
  4188. * @deprecated **Deprecated** in favor of `CompletionItem.insertText` and `CompletionItem.range`.
  4189. *
  4190. * ~~An [edit](#TextEdit) which is applied to a document when selecting
  4191. * this completion. When an edit is provided the value of
  4192. * [insertText](#CompletionItem.insertText) is ignored.~~
  4193. *
  4194. * ~~The [range](#Range) of the edit must be single-line and on the same
  4195. * line completions were [requested](#CompletionItemProvider.provideCompletionItems) at.~~
  4196. */
  4197. textEdit?: editor.ISingleEditOperation;
  4198. /**
  4199. * An optional array of additional text edits that are applied when
  4200. * selecting this completion. Edits must not overlap with the main edit
  4201. * nor with themselves.
  4202. */
  4203. additionalTextEdits?: editor.ISingleEditOperation[];
  4204. }
  4205. /**
  4206. * Represents a collection of [completion items](#CompletionItem) to be presented
  4207. * in the editor.
  4208. */
  4209. export interface CompletionList {
  4210. /**
  4211. * This list it not complete. Further typing should result in recomputing
  4212. * this list.
  4213. */
  4214. isIncomplete?: boolean;
  4215. /**
  4216. * The completion items.
  4217. */
  4218. items: CompletionItem[];
  4219. }
  4220. /**
  4221. * Contains additional information about the context in which
  4222. * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered.
  4223. */
  4224. export interface CompletionContext {
  4225. /**
  4226. * How the completion was triggered.
  4227. */
  4228. triggerKind: SuggestTriggerKind;
  4229. /**
  4230. * Character that triggered the completion item provider.
  4231. *
  4232. * `undefined` if provider was not triggered by a character.
  4233. */
  4234. triggerCharacter?: string;
  4235. }
  4236. /**
  4237. * The completion item provider interface defines the contract between extensions and
  4238. * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
  4239. *
  4240. * When computing *complete* completion items is expensive, providers can optionally implement
  4241. * the `resolveCompletionItem`-function. In that case it is enough to return completion
  4242. * items with a [label](#CompletionItem.label) from the
  4243. * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently,
  4244. * when a completion item is shown in the UI and gains focus this provider is asked to resolve
  4245. * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail).
  4246. */
  4247. export interface CompletionItemProvider {
  4248. triggerCharacters?: string[];
  4249. /**
  4250. * Provide completion items for the given position and document.
  4251. */
  4252. provideCompletionItems(document: editor.ITextModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable<CompletionItem[]> | CompletionList | Thenable<CompletionList>;
  4253. /**
  4254. * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation)
  4255. * or [details](#CompletionItem.detail).
  4256. *
  4257. * The editor will only resolve a completion item once.
  4258. */
  4259. resolveCompletionItem?(item: CompletionItem, token: CancellationToken): CompletionItem | Thenable<CompletionItem>;
  4260. }
  4261. /**
  4262. * Describes how comments for a language work.
  4263. */
  4264. export interface CommentRule {
  4265. /**
  4266. * The line comment token, like `// this is a comment`
  4267. */
  4268. lineComment?: string;
  4269. /**
  4270. * The block comment character pair, like `/* block comment *&#47;`
  4271. */
  4272. blockComment?: CharacterPair;
  4273. }
  4274. /**
  4275. * The language configuration interface defines the contract between extensions and
  4276. * various editor features, like automatic bracket insertion, automatic indentation etc.
  4277. */
  4278. export interface LanguageConfiguration {
  4279. /**
  4280. * The language's comment settings.
  4281. */
  4282. comments?: CommentRule;
  4283. /**
  4284. * The language's brackets.
  4285. * This configuration implicitly affects pressing Enter around these brackets.
  4286. */
  4287. brackets?: CharacterPair[];
  4288. /**
  4289. * The language's word definition.
  4290. * If the language supports Unicode identifiers (e.g. JavaScript), it is preferable
  4291. * to provide a word definition that uses exclusion of known separators.
  4292. * e.g.: A regex that matches anything except known separators (and dot is allowed to occur in a floating point number):
  4293. * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
  4294. */
  4295. wordPattern?: RegExp;
  4296. /**
  4297. * The language's indentation settings.
  4298. */
  4299. indentationRules?: IndentationRule;
  4300. /**
  4301. * The language's rules to be evaluated when pressing Enter.
  4302. */
  4303. onEnterRules?: OnEnterRule[];
  4304. /**
  4305. * The language's auto closing pairs. The 'close' character is automatically inserted with the
  4306. * 'open' character is typed. If not set, the configured brackets will be used.
  4307. */
  4308. autoClosingPairs?: IAutoClosingPairConditional[];
  4309. /**
  4310. * The language's surrounding pairs. When the 'open' character is typed on a selection, the
  4311. * selected string is surrounded by the open and close characters. If not set, the autoclosing pairs
  4312. * settings will be used.
  4313. */
  4314. surroundingPairs?: IAutoClosingPair[];
  4315. /**
  4316. * The language's folding rules.
  4317. */
  4318. folding?: FoldingRules;
  4319. /**
  4320. * **Deprecated** Do not use.
  4321. *
  4322. * @deprecated Will be replaced by a better API soon.
  4323. */
  4324. __electricCharacterSupport?: IBracketElectricCharacterContribution;
  4325. }
  4326. /**
  4327. * Describes indentation rules for a language.
  4328. */
  4329. export interface IndentationRule {
  4330. /**
  4331. * If a line matches this pattern, then all the lines after it should be unindendented once (until another rule matches).
  4332. */
  4333. decreaseIndentPattern: RegExp;
  4334. /**
  4335. * If a line matches this pattern, then all the lines after it should be indented once (until another rule matches).
  4336. */
  4337. increaseIndentPattern: RegExp;
  4338. /**
  4339. * If a line matches this pattern, then **only the next line** after it should be indented once.
  4340. */
  4341. indentNextLinePattern?: RegExp;
  4342. /**
  4343. * If a line matches this pattern, then its indentation should not be changed and it should not be evaluated against the other rules.
  4344. */
  4345. unIndentedLinePattern?: RegExp;
  4346. }
  4347. /**
  4348. * Describes language specific folding markers such as '#region' and '#endregion'.
  4349. * The start and end regexes will be tested against the contents of all lines and must be designed efficiently:
  4350. * - the regex should start with '^'
  4351. * - regexp flags (i, g) are ignored
  4352. */
  4353. export interface FoldingMarkers {
  4354. start: RegExp;
  4355. end: RegExp;
  4356. }
  4357. /**
  4358. * Describes folding rules for a language.
  4359. */
  4360. export interface FoldingRules {
  4361. /**
  4362. * Used by the indentation based strategy to decide wheter empty lines belong to the previous or the next block.
  4363. * A language adheres to the off-side rule if blocks in that language are expressed by their indentation.
  4364. * See [wikipedia](https://en.wikipedia.org/wiki/Off-side_rule) for more information.
  4365. * If not set, `false` is used and empty lines belong to the previous block.
  4366. */
  4367. offSide?: boolean;
  4368. /**
  4369. * Region markers used by the language.
  4370. */
  4371. markers?: FoldingMarkers;
  4372. }
  4373. /**
  4374. * Describes a rule to be evaluated when pressing Enter.
  4375. */
  4376. export interface OnEnterRule {
  4377. /**
  4378. * This rule will only execute if the text before the cursor matches this regular expression.
  4379. */
  4380. beforeText: RegExp;
  4381. /**
  4382. * This rule will only execute if the text after the cursor matches this regular expression.
  4383. */
  4384. afterText?: RegExp;
  4385. /**
  4386. * The action to execute.
  4387. */
  4388. action: EnterAction;
  4389. }
  4390. export interface IBracketElectricCharacterContribution {
  4391. docComment?: IDocComment;
  4392. }
  4393. /**
  4394. * Definition of documentation comments (e.g. Javadoc/JSdoc)
  4395. */
  4396. export interface IDocComment {
  4397. /**
  4398. * The string that starts a doc comment (e.g. '/**')
  4399. */
  4400. open: string;
  4401. /**
  4402. * The string that appears on the last line and closes the doc comment (e.g. ' * /').
  4403. */
  4404. close: string;
  4405. }
  4406. /**
  4407. * A tuple of two characters, like a pair of
  4408. * opening and closing brackets.
  4409. */
  4410. export type CharacterPair = [string, string];
  4411. export interface IAutoClosingPair {
  4412. open: string;
  4413. close: string;
  4414. }
  4415. export interface IAutoClosingPairConditional extends IAutoClosingPair {
  4416. notIn?: string[];
  4417. }
  4418. /**
  4419. * Describes what to do with the indentation when pressing Enter.
  4420. */
  4421. export enum IndentAction {
  4422. /**
  4423. * Insert new line and copy the previous line's indentation.
  4424. */
  4425. None = 0,
  4426. /**
  4427. * Insert new line and indent once (relative to the previous line's indentation).
  4428. */
  4429. Indent = 1,
  4430. /**
  4431. * Insert two new lines:
  4432. * - the first one indented which will hold the cursor
  4433. * - the second one at the same indentation level
  4434. */
  4435. IndentOutdent = 2,
  4436. /**
  4437. * Insert new line and outdent once (relative to the previous line's indentation).
  4438. */
  4439. Outdent = 3
  4440. }
  4441. /**
  4442. * Describes what to do when pressing Enter.
  4443. */
  4444. export interface EnterAction {
  4445. /**
  4446. * Describe what to do with the indentation.
  4447. */
  4448. indentAction: IndentAction;
  4449. /**
  4450. * Describe whether to outdent current line.
  4451. */
  4452. outdentCurrentLine?: boolean;
  4453. /**
  4454. * Describes text to be appended after the new line and after the indentation.
  4455. */
  4456. appendText?: string;
  4457. /**
  4458. * Describes the number of characters to remove from the new line's indentation.
  4459. */
  4460. removeText?: number;
  4461. }
  4462. /**
  4463. * The state of the tokenizer between two lines.
  4464. * It is useful to store flags such as in multiline comment, etc.
  4465. * The model will clone the previous line's state and pass it in to tokenize the next line.
  4466. */
  4467. export interface IState {
  4468. clone(): IState;
  4469. equals(other: IState): boolean;
  4470. }
  4471. /**
  4472. * A hover represents additional information for a symbol or word. Hovers are
  4473. * rendered in a tooltip-like widget.
  4474. */
  4475. export interface Hover {
  4476. /**
  4477. * The contents of this hover.
  4478. */
  4479. contents: IMarkdownString[];
  4480. /**
  4481. * The range to which this hover applies. When missing, the
  4482. * editor will use the range at the current position or the
  4483. * current position itself.
  4484. */
  4485. range?: IRange;
  4486. }
  4487. /**
  4488. * The hover provider interface defines the contract between extensions and
  4489. * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
  4490. */
  4491. export interface HoverProvider {
  4492. /**
  4493. * Provide a hover for the given position and document. Multiple hovers at the same
  4494. * position will be merged by the editor. A hover can have a range which defaults
  4495. * to the word range at the position when omitted.
  4496. */
  4497. provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): Hover | Thenable<Hover>;
  4498. }
  4499. /**
  4500. * How a suggest provider was triggered.
  4501. */
  4502. export enum SuggestTriggerKind {
  4503. Invoke = 0,
  4504. TriggerCharacter = 1,
  4505. TriggerForIncompleteCompletions = 2
  4506. }
  4507. export interface CodeAction {
  4508. title: string;
  4509. command?: Command;
  4510. edit?: WorkspaceEdit;
  4511. diagnostics?: editor.IMarkerData[];
  4512. kind?: string;
  4513. }
  4514. /**
  4515. * Represents a parameter of a callable-signature. A parameter can
  4516. * have a label and a doc-comment.
  4517. */
  4518. export interface ParameterInformation {
  4519. /**
  4520. * The label of this signature. Will be shown in
  4521. * the UI.
  4522. */
  4523. label: string;
  4524. /**
  4525. * The human-readable doc-comment of this signature. Will be shown
  4526. * in the UI but can be omitted.
  4527. */
  4528. documentation?: string | IMarkdownString;
  4529. }
  4530. /**
  4531. * Represents the signature of something callable. A signature
  4532. * can have a label, like a function-name, a doc-comment, and
  4533. * a set of parameters.
  4534. */
  4535. export interface SignatureInformation {
  4536. /**
  4537. * The label of this signature. Will be shown in
  4538. * the UI.
  4539. */
  4540. label: string;
  4541. /**
  4542. * The human-readable doc-comment of this signature. Will be shown
  4543. * in the UI but can be omitted.
  4544. */
  4545. documentation?: string | IMarkdownString;
  4546. /**
  4547. * The parameters of this signature.
  4548. */
  4549. parameters: ParameterInformation[];
  4550. }
  4551. /**
  4552. * Signature help represents the signature of something
  4553. * callable. There can be multiple signatures but only one
  4554. * active and only one active parameter.
  4555. */
  4556. export interface SignatureHelp {
  4557. /**
  4558. * One or more signatures.
  4559. */
  4560. signatures: SignatureInformation[];
  4561. /**
  4562. * The active signature.
  4563. */
  4564. activeSignature: number;
  4565. /**
  4566. * The active parameter of the active signature.
  4567. */
  4568. activeParameter: number;
  4569. }
  4570. /**
  4571. * The signature help provider interface defines the contract between extensions and
  4572. * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
  4573. */
  4574. export interface SignatureHelpProvider {
  4575. signatureHelpTriggerCharacters: string[];
  4576. /**
  4577. * Provide help for the signature at the given position and document.
  4578. */
  4579. provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken): SignatureHelp | Thenable<SignatureHelp>;
  4580. }
  4581. /**
  4582. * A document highlight kind.
  4583. */
  4584. export enum DocumentHighlightKind {
  4585. /**
  4586. * A textual occurrence.
  4587. */
  4588. Text = 0,
  4589. /**
  4590. * Read-access of a symbol, like reading a variable.
  4591. */
  4592. Read = 1,
  4593. /**
  4594. * Write-access of a symbol, like writing to a variable.
  4595. */
  4596. Write = 2
  4597. }
  4598. /**
  4599. * A document highlight is a range inside a text document which deserves
  4600. * special attention. Usually a document highlight is visualized by changing
  4601. * the background color of its range.
  4602. */
  4603. export interface DocumentHighlight {
  4604. /**
  4605. * The range this highlight applies to.
  4606. */
  4607. range: IRange;
  4608. /**
  4609. * The highlight kind, default is [text](#DocumentHighlightKind.Text).
  4610. */
  4611. kind: DocumentHighlightKind;
  4612. }
  4613. /**
  4614. * The document highlight provider interface defines the contract between extensions and
  4615. * the word-highlight-feature.
  4616. */
  4617. export interface DocumentHighlightProvider {
  4618. /**
  4619. * Provide a set of document highlights, like all occurrences of a variable or
  4620. * all exit-points of a function.
  4621. */
  4622. provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable<DocumentHighlight[]>;
  4623. }
  4624. /**
  4625. * Value-object that contains additional information when
  4626. * requesting references.
  4627. */
  4628. export interface ReferenceContext {
  4629. /**
  4630. * Include the declaration of the current symbol.
  4631. */
  4632. includeDeclaration: boolean;
  4633. }
  4634. /**
  4635. * The reference provider interface defines the contract between extensions and
  4636. * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
  4637. */
  4638. export interface ReferenceProvider {
  4639. /**
  4640. * Provide a set of project-wide references for the given position and document.
  4641. */
  4642. provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable<Location[]>;
  4643. }
  4644. /**
  4645. * Represents a location inside a resource, such as a line
  4646. * inside a text file.
  4647. */
  4648. export interface Location {
  4649. /**
  4650. * The resource identifier of this location.
  4651. */
  4652. uri: Uri;
  4653. /**
  4654. * The document range of this locations.
  4655. */
  4656. range: IRange;
  4657. }
  4658. /**
  4659. * The definition of a symbol represented as one or many [locations](#Location).
  4660. * For most programming languages there is only one location at which a symbol is
  4661. * defined.
  4662. */
  4663. export type Definition = Location | Location[];
  4664. export interface DefinitionLink {
  4665. origin?: IRange;
  4666. uri: Uri;
  4667. range: IRange;
  4668. selectionRange?: IRange;
  4669. }
  4670. /**
  4671. * The definition provider interface defines the contract between extensions and
  4672. * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
  4673. * and peek definition features.
  4674. */
  4675. export interface DefinitionProvider {
  4676. /**
  4677. * Provide the definition of the symbol at the given position and document.
  4678. */
  4679. provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable<Definition | DefinitionLink[]>;
  4680. }
  4681. /**
  4682. * The implementation provider interface defines the contract between extensions and
  4683. * the go to implementation feature.
  4684. */
  4685. export interface ImplementationProvider {
  4686. /**
  4687. * Provide the implementation of the symbol at the given position and document.
  4688. */
  4689. provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable<Definition | DefinitionLink[]>;
  4690. }
  4691. /**
  4692. * The type definition provider interface defines the contract between extensions and
  4693. * the go to type definition feature.
  4694. */
  4695. export interface TypeDefinitionProvider {
  4696. /**
  4697. * Provide the type definition of the symbol at the given position and document.
  4698. */
  4699. provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable<Definition | DefinitionLink[]>;
  4700. }
  4701. /**
  4702. * A symbol kind.
  4703. */
  4704. export enum SymbolKind {
  4705. File = 0,
  4706. Module = 1,
  4707. Namespace = 2,
  4708. Package = 3,
  4709. Class = 4,
  4710. Method = 5,
  4711. Property = 6,
  4712. Field = 7,
  4713. Constructor = 8,
  4714. Enum = 9,
  4715. Interface = 10,
  4716. Function = 11,
  4717. Variable = 12,
  4718. Constant = 13,
  4719. String = 14,
  4720. Number = 15,
  4721. Boolean = 16,
  4722. Array = 17,
  4723. Object = 18,
  4724. Key = 19,
  4725. Null = 20,
  4726. EnumMember = 21,
  4727. Struct = 22,
  4728. Event = 23,
  4729. Operator = 24,
  4730. TypeParameter = 25
  4731. }
  4732. export interface DocumentSymbol {
  4733. name: string;
  4734. detail: string;
  4735. kind: SymbolKind;
  4736. containerName?: string;
  4737. range: IRange;
  4738. selectionRange: IRange;
  4739. children?: DocumentSymbol[];
  4740. }
  4741. /**
  4742. * The document symbol provider interface defines the contract between extensions and
  4743. * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_goto-symbol)-feature.
  4744. */
  4745. export interface DocumentSymbolProvider {
  4746. displayName?: string;
  4747. /**
  4748. * Provide symbol information for the given document.
  4749. */
  4750. provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): DocumentSymbol[] | Thenable<DocumentSymbol[]>;
  4751. }
  4752. export interface TextEdit {
  4753. range: IRange;
  4754. text: string;
  4755. eol?: editor.EndOfLineSequence;
  4756. }
  4757. /**
  4758. * Interface used to format a model
  4759. */
  4760. export interface FormattingOptions {
  4761. /**
  4762. * Size of a tab in spaces.
  4763. */
  4764. tabSize: number;
  4765. /**
  4766. * Prefer spaces over tabs.
  4767. */
  4768. insertSpaces: boolean;
  4769. }
  4770. /**
  4771. * The document formatting provider interface defines the contract between extensions and
  4772. * the formatting-feature.
  4773. */
  4774. export interface DocumentFormattingEditProvider {
  4775. /**
  4776. * Provide formatting edits for a whole document.
  4777. */
  4778. provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable<TextEdit[]>;
  4779. }
  4780. /**
  4781. * The document formatting provider interface defines the contract between extensions and
  4782. * the formatting-feature.
  4783. */
  4784. export interface DocumentRangeFormattingEditProvider {
  4785. /**
  4786. * Provide formatting edits for a range in a document.
  4787. *
  4788. * The given range is a hint and providers can decide to format a smaller
  4789. * or larger range. Often this is done by adjusting the start and end
  4790. * of the range to full syntax nodes.
  4791. */
  4792. provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable<TextEdit[]>;
  4793. }
  4794. /**
  4795. * The document formatting provider interface defines the contract between extensions and
  4796. * the formatting-feature.
  4797. */
  4798. export interface OnTypeFormattingEditProvider {
  4799. autoFormatTriggerCharacters: string[];
  4800. /**
  4801. * Provide formatting edits after a character has been typed.
  4802. *
  4803. * The given position and character should hint to the provider
  4804. * what range the position to expand to, like find the matching `{`
  4805. * when `}` has been entered.
  4806. */
  4807. provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable<TextEdit[]>;
  4808. }
  4809. /**
  4810. * A link inside the editor.
  4811. */
  4812. export interface ILink {
  4813. range: IRange;
  4814. url?: string;
  4815. }
  4816. /**
  4817. * A provider of links.
  4818. */
  4819. export interface LinkProvider {
  4820. provideLinks(model: editor.ITextModel, token: CancellationToken): ILink[] | Thenable<ILink[]>;
  4821. resolveLink?: (link: ILink, token: CancellationToken) => ILink | Thenable<ILink>;
  4822. }
  4823. /**
  4824. * A color in RGBA format.
  4825. */
  4826. export interface IColor {
  4827. /**
  4828. * The red component in the range [0-1].
  4829. */
  4830. readonly red: number;
  4831. /**
  4832. * The green component in the range [0-1].
  4833. */
  4834. readonly green: number;
  4835. /**
  4836. * The blue component in the range [0-1].
  4837. */
  4838. readonly blue: number;
  4839. /**
  4840. * The alpha component in the range [0-1].
  4841. */
  4842. readonly alpha: number;
  4843. }
  4844. /**
  4845. * String representations for a color
  4846. */
  4847. export interface IColorPresentation {
  4848. /**
  4849. * The label of this color presentation. It will be shown on the color
  4850. * picker header. By default this is also the text that is inserted when selecting
  4851. * this color presentation.
  4852. */
  4853. label: string;
  4854. /**
  4855. * An [edit](#TextEdit) which is applied to a document when selecting
  4856. * this presentation for the color.
  4857. */
  4858. textEdit?: TextEdit;
  4859. /**
  4860. * An optional array of additional [text edits](#TextEdit) that are applied when
  4861. * selecting this color presentation.
  4862. */
  4863. additionalTextEdits?: TextEdit[];
  4864. }
  4865. /**
  4866. * A color range is a range in a text model which represents a color.
  4867. */
  4868. export interface IColorInformation {
  4869. /**
  4870. * The range within the model.
  4871. */
  4872. range: IRange;
  4873. /**
  4874. * The color represented in this range.
  4875. */
  4876. color: IColor;
  4877. }
  4878. /**
  4879. * A provider of colors for editor models.
  4880. */
  4881. export interface DocumentColorProvider {
  4882. /**
  4883. * Provides the color ranges for a specific model.
  4884. */
  4885. provideDocumentColors(model: editor.ITextModel, token: CancellationToken): IColorInformation[] | Thenable<IColorInformation[]>;
  4886. /**
  4887. * Provide the string representations for a color.
  4888. */
  4889. provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable<IColorPresentation[]>;
  4890. }
  4891. export interface FoldingContext {
  4892. }
  4893. /**
  4894. * A provider of colors for editor models.
  4895. */
  4896. export interface FoldingRangeProvider {
  4897. /**
  4898. * Provides the color ranges for a specific model.
  4899. */
  4900. provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): FoldingRange[] | Thenable<FoldingRange[]>;
  4901. }
  4902. export interface FoldingRange {
  4903. /**
  4904. * The one-based start line of the range to fold. The folded area starts after the line's last character.
  4905. */
  4906. start: number;
  4907. /**
  4908. * The one-based end line of the range to fold. The folded area ends with the line's last character.
  4909. */
  4910. end: number;
  4911. /**
  4912. * Describes the [Kind](#FoldingRangeKind) of the folding range such as [Comment](#FoldingRangeKind.Comment) or
  4913. * [Region](#FoldingRangeKind.Region). The kind is used to categorize folding ranges and used by commands
  4914. * like 'Fold all comments'. See
  4915. * [FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds.
  4916. */
  4917. kind?: FoldingRangeKind;
  4918. }
  4919. export class FoldingRangeKind {
  4920. value: string;
  4921. /**
  4922. * Kind for folding range representing a comment. The value of the kind is 'comment'.
  4923. */
  4924. static readonly Comment: FoldingRangeKind;
  4925. /**
  4926. * Kind for folding range representing a import. The value of the kind is 'imports'.
  4927. */
  4928. static readonly Imports: FoldingRangeKind;
  4929. /**
  4930. * Kind for folding range representing regions (for example marked by `#region`, `#endregion`).
  4931. * The value of the kind is 'region'.
  4932. */
  4933. static readonly Region: FoldingRangeKind;
  4934. /**
  4935. * Creates a new [FoldingRangeKind](#FoldingRangeKind).
  4936. *
  4937. * @param value of the kind.
  4938. */
  4939. constructor(value: string);
  4940. }
  4941. export interface ResourceFileEdit {
  4942. oldUri: Uri;
  4943. newUri: Uri;
  4944. options: {
  4945. overwrite?: boolean;
  4946. ignoreIfNotExists?: boolean;
  4947. ignoreIfExists?: boolean;
  4948. recursive?: boolean;
  4949. };
  4950. }
  4951. export interface ResourceTextEdit {
  4952. resource: Uri;
  4953. modelVersionId?: number;
  4954. edits: TextEdit[];
  4955. }
  4956. export interface WorkspaceEdit {
  4957. edits: Array<ResourceTextEdit | ResourceFileEdit>;
  4958. rejectReason?: string;
  4959. }
  4960. export interface RenameLocation {
  4961. range: IRange;
  4962. text: string;
  4963. }
  4964. export interface RenameProvider {
  4965. provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable<WorkspaceEdit>;
  4966. resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): RenameLocation | Thenable<RenameLocation>;
  4967. }
  4968. export interface Command {
  4969. id: string;
  4970. title: string;
  4971. tooltip?: string;
  4972. arguments?: any[];
  4973. }
  4974. export interface ICodeLensSymbol {
  4975. range: IRange;
  4976. id?: string;
  4977. command?: Command;
  4978. }
  4979. export interface CodeLensProvider {
  4980. onDidChange?: IEvent<this>;
  4981. provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ICodeLensSymbol[] | Thenable<ICodeLensSymbol[]>;
  4982. resolveCodeLens?(model: editor.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable<ICodeLensSymbol>;
  4983. }
  4984. export interface ILanguageExtensionPoint {
  4985. id: string;
  4986. extensions?: string[];
  4987. filenames?: string[];
  4988. filenamePatterns?: string[];
  4989. firstLine?: string;
  4990. aliases?: string[];
  4991. mimetypes?: string[];
  4992. configuration?: Uri;
  4993. }
  4994. /**
  4995. * A Monarch language definition
  4996. */
  4997. export interface IMonarchLanguage {
  4998. /**
  4999. * map from string to ILanguageRule[]
  5000. */
  5001. tokenizer: {
  5002. [name: string]: IMonarchLanguageRule[];
  5003. };
  5004. /**
  5005. * is the language case insensitive?
  5006. */
  5007. ignoreCase?: boolean;
  5008. /**
  5009. * if no match in the tokenizer assign this token class (default 'source')
  5010. */
  5011. defaultToken?: string;
  5012. /**
  5013. * for example [['{','}','delimiter.curly']]
  5014. */
  5015. brackets?: IMonarchLanguageBracket[];
  5016. /**
  5017. * start symbol in the tokenizer (by default the first entry is used)
  5018. */
  5019. start?: string;
  5020. /**
  5021. * attach this to every token class (by default '.' + name)
  5022. */
  5023. tokenPostfix?: string;
  5024. }
  5025. export type IShortMonarchLanguageRule1 = [RegExp, string | IMonarchLanguageAction];
  5026. export type IShortMonarchLanguageRule2 = [RegExp, string | IMonarchLanguageAction, string];
  5027. /**
  5028. * A rule is either a regular expression and an action
  5029. * shorthands: [reg,act] == { regex: reg, action: act}
  5030. * and : [reg,act,nxt] == { regex: reg, action: act{ next: nxt }}
  5031. */
  5032. export interface IExpandedMonarchLanguageRule {
  5033. /**
  5034. * match tokens
  5035. */
  5036. regex?: string | RegExp;
  5037. /**
  5038. * action to take on match
  5039. */
  5040. action?: IMonarchLanguageAction;
  5041. /**
  5042. * or an include rule. include all rules from the included state
  5043. */
  5044. include?: string;
  5045. }
  5046. export type IMonarchLanguageRule = IShortMonarchLanguageRule1 | IShortMonarchLanguageRule2 | IExpandedMonarchLanguageRule;
  5047. /**
  5048. * An action is either an array of actions...
  5049. * ... or a case statement with guards...
  5050. * ... or a basic action with a token value.
  5051. */
  5052. export interface IMonarchLanguageAction {
  5053. /**
  5054. * array of actions for each parenthesized match group
  5055. */
  5056. group?: IMonarchLanguageAction[];
  5057. /**
  5058. * map from string to ILanguageAction
  5059. */
  5060. cases?: Object;
  5061. /**
  5062. * token class (ie. css class) (or "@brackets" or "@rematch")
  5063. */
  5064. token?: string;
  5065. /**
  5066. * the next state to push, or "@push", "@pop", "@popall"
  5067. */
  5068. next?: string;
  5069. /**
  5070. * switch to this state
  5071. */
  5072. switchTo?: string;
  5073. /**
  5074. * go back n characters in the stream
  5075. */
  5076. goBack?: number;
  5077. /**
  5078. * @open or @close
  5079. */
  5080. bracket?: string;
  5081. /**
  5082. * switch to embedded language (useing the mimetype) or get out using "@pop"
  5083. */
  5084. nextEmbedded?: string;
  5085. /**
  5086. * log a message to the browser console window
  5087. */
  5088. log?: string;
  5089. }
  5090. /**
  5091. * This interface can be shortened as an array, ie. ['{','}','delimiter.curly']
  5092. */
  5093. export interface IMonarchLanguageBracket {
  5094. /**
  5095. * open bracket
  5096. */
  5097. open: string;
  5098. /**
  5099. * closeing bracket
  5100. */
  5101. close: string;
  5102. /**
  5103. * token class
  5104. */
  5105. token: string;
  5106. }
  5107. }
  5108. declare namespace monaco.worker {
  5109. export interface IMirrorModel {
  5110. readonly uri: Uri;
  5111. readonly version: number;
  5112. getValue(): string;
  5113. }
  5114. export interface IWorkerContext {
  5115. /**
  5116. * Get all available mirror models in this worker.
  5117. */
  5118. getMirrorModels(): IMirrorModel[];
  5119. }
  5120. }
  5121. declare namespace monaco.languages.typescript {
  5122. enum ModuleKind {
  5123. None = 0,
  5124. CommonJS = 1,
  5125. AMD = 2,
  5126. UMD = 3,
  5127. System = 4,
  5128. ES2015 = 5,
  5129. ESNext = 6
  5130. }
  5131. enum JsxEmit {
  5132. None = 0,
  5133. Preserve = 1,
  5134. React = 2,
  5135. ReactNative = 3
  5136. }
  5137. enum NewLineKind {
  5138. CarriageReturnLineFeed = 0,
  5139. LineFeed = 1
  5140. }
  5141. enum ScriptTarget {
  5142. ES3 = 0,
  5143. ES5 = 1,
  5144. ES2015 = 2,
  5145. ES2016 = 3,
  5146. ES2017 = 4,
  5147. ES2018 = 5,
  5148. ESNext = 6,
  5149. JSON = 100,
  5150. Latest = 6
  5151. }
  5152. export enum ModuleResolutionKind {
  5153. Classic = 1,
  5154. NodeJs = 2
  5155. }
  5156. interface MapLike<T> {
  5157. [index: string]: T;
  5158. }
  5159. type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | null | undefined;
  5160. interface CompilerOptions {
  5161. allowJs?: boolean;
  5162. allowSyntheticDefaultImports?: boolean;
  5163. allowUnreachableCode?: boolean;
  5164. allowUnusedLabels?: boolean;
  5165. alwaysStrict?: boolean;
  5166. baseUrl?: string;
  5167. charset?: string;
  5168. checkJs?: boolean;
  5169. declaration?: boolean;
  5170. declarationMap?: boolean;
  5171. emitDeclarationOnly?: boolean;
  5172. declarationDir?: string;
  5173. disableSizeLimit?: boolean;
  5174. downlevelIteration?: boolean;
  5175. emitBOM?: boolean;
  5176. emitDecoratorMetadata?: boolean;
  5177. experimentalDecorators?: boolean;
  5178. forceConsistentCasingInFileNames?: boolean;
  5179. importHelpers?: boolean;
  5180. inlineSourceMap?: boolean;
  5181. inlineSources?: boolean;
  5182. isolatedModules?: boolean;
  5183. jsx?: JsxEmit;
  5184. keyofStringsOnly?: boolean;
  5185. lib?: string[];
  5186. locale?: string;
  5187. mapRoot?: string;
  5188. maxNodeModuleJsDepth?: number;
  5189. module?: ModuleKind;
  5190. moduleResolution?: ModuleResolutionKind;
  5191. newLine?: NewLineKind;
  5192. noEmit?: boolean;
  5193. noEmitHelpers?: boolean;
  5194. noEmitOnError?: boolean;
  5195. noErrorTruncation?: boolean;
  5196. noFallthroughCasesInSwitch?: boolean;
  5197. noImplicitAny?: boolean;
  5198. noImplicitReturns?: boolean;
  5199. noImplicitThis?: boolean;
  5200. noStrictGenericChecks?: boolean;
  5201. noUnusedLocals?: boolean;
  5202. noUnusedParameters?: boolean;
  5203. noImplicitUseStrict?: boolean;
  5204. noLib?: boolean;
  5205. noResolve?: boolean;
  5206. out?: string;
  5207. outDir?: string;
  5208. outFile?: string;
  5209. paths?: MapLike<string[]>;
  5210. preserveConstEnums?: boolean;
  5211. preserveSymlinks?: boolean;
  5212. project?: string;
  5213. reactNamespace?: string;
  5214. jsxFactory?: string;
  5215. composite?: boolean;
  5216. removeComments?: boolean;
  5217. rootDir?: string;
  5218. rootDirs?: string[];
  5219. skipLibCheck?: boolean;
  5220. skipDefaultLibCheck?: boolean;
  5221. sourceMap?: boolean;
  5222. sourceRoot?: string;
  5223. strict?: boolean;
  5224. strictFunctionTypes?: boolean;
  5225. strictNullChecks?: boolean;
  5226. strictPropertyInitialization?: boolean;
  5227. suppressExcessPropertyErrors?: boolean;
  5228. suppressImplicitAnyIndexErrors?: boolean;
  5229. target?: ScriptTarget;
  5230. traceResolution?: boolean;
  5231. resolveJsonModule?: boolean;
  5232. types?: string[];
  5233. /** Paths used to compute primary types search locations */
  5234. typeRoots?: string[];
  5235. esModuleInterop?: boolean;
  5236. [option: string]: CompilerOptionsValue | undefined;
  5237. }
  5238. export interface DiagnosticsOptions {
  5239. noSemanticValidation?: boolean;
  5240. noSyntaxValidation?: boolean;
  5241. }
  5242. export interface LanguageServiceDefaults {
  5243. /**
  5244. * Add an additional source file to the language service. Use this
  5245. * for typescript (definition) files that won't be loaded as editor
  5246. * document, like `jquery.d.ts`.
  5247. *
  5248. * @param content The file content
  5249. * @param filePath An optional file path
  5250. * @returns A disposabled which will remove the file from the
  5251. * language service upon disposal.
  5252. */
  5253. addExtraLib(content: string, filePath?: string): IDisposable;
  5254. /**
  5255. * Set TypeScript compiler options.
  5256. */
  5257. setCompilerOptions(options: CompilerOptions): void;
  5258. /**
  5259. * Configure whether syntactic and/or semantic validation should
  5260. * be performed
  5261. */
  5262. setDiagnosticsOptions(options: DiagnosticsOptions): void;
  5263. /**
  5264. * Configure when the worker shuts down. By default that is 2mins.
  5265. *
  5266. * @param value The maximum idle time in milliseconds. Values less than one
  5267. * mean never shut down.
  5268. */
  5269. setMaximumWorkerIdleTime(value: number): void;
  5270. /**
  5271. * Configure if all existing models should be eagerly sync'd
  5272. * to the worker on start or restart.
  5273. */
  5274. setEagerModelSync(value: boolean): void;
  5275. }
  5276. export var typescriptDefaults: LanguageServiceDefaults;
  5277. export var javascriptDefaults: LanguageServiceDefaults;
  5278. export var getTypeScriptWorker: () => Promise<any>;
  5279. export var getJavaScriptWorker: () => Promise<any>;
  5280. }
  5281. /*---------------------------------------------------------------------------------------------
  5282. * Copyright (c) Microsoft Corporation. All rights reserved.
  5283. * Licensed under the MIT License. See License.txt in the project root for license information.
  5284. *--------------------------------------------------------------------------------------------*/
  5285. declare namespace monaco.languages.css {
  5286. export interface DiagnosticsOptions {
  5287. readonly validate?: boolean;
  5288. readonly lint?: {
  5289. readonly compatibleVendorPrefixes?: 'ignore' | 'warning' | 'error',
  5290. readonly vendorPrefix?: 'ignore' | 'warning' | 'error',
  5291. readonly duplicateProperties?: 'ignore' | 'warning' | 'error',
  5292. readonly emptyRules?: 'ignore' | 'warning' | 'error',
  5293. readonly importStatement?: 'ignore' | 'warning' | 'error',
  5294. readonly boxModel?: 'ignore' | 'warning' | 'error',
  5295. readonly universalSelector?: 'ignore' | 'warning' | 'error',
  5296. readonly zeroUnits?: 'ignore' | 'warning' | 'error',
  5297. readonly fontFaceProperties?: 'ignore' | 'warning' | 'error',
  5298. readonly hexColorLength?: 'ignore' | 'warning' | 'error',
  5299. readonly argumentsInColorFunction?: 'ignore' | 'warning' | 'error',
  5300. readonly unknownProperties?: 'ignore' | 'warning' | 'error',
  5301. readonly ieHack?: 'ignore' | 'warning' | 'error',
  5302. readonly unknownVendorSpecificProperties?: 'ignore' | 'warning' | 'error',
  5303. readonly propertyIgnoredDueToDisplay?: 'ignore' | 'warning' | 'error',
  5304. readonly important?: 'ignore' | 'warning' | 'error',
  5305. readonly float?: 'ignore' | 'warning' | 'error',
  5306. readonly idSelector?: 'ignore' | 'warning' | 'error'
  5307. }
  5308. }
  5309. export interface LanguageServiceDefaults {
  5310. readonly onDidChange: IEvent<LanguageServiceDefaults>;
  5311. readonly diagnosticsOptions: DiagnosticsOptions;
  5312. setDiagnosticsOptions(options: DiagnosticsOptions): void;
  5313. }
  5314. export var cssDefaults: LanguageServiceDefaults;
  5315. export var lessDefaults: LanguageServiceDefaults;
  5316. export var scssDefaults: LanguageServiceDefaults;
  5317. }
  5318. /*---------------------------------------------------------------------------------------------
  5319. * Copyright (c) Microsoft Corporation. All rights reserved.
  5320. * Licensed under the MIT License. See License.txt in the project root for license information.
  5321. *--------------------------------------------------------------------------------------------*/
  5322. declare namespace monaco.languages.json {
  5323. export interface DiagnosticsOptions {
  5324. /**
  5325. * If set, the validator will be enabled and perform syntax validation as well as schema based validation.
  5326. */
  5327. readonly validate?: boolean;
  5328. /**
  5329. * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments.
  5330. */
  5331. readonly allowComments?: boolean;
  5332. /**
  5333. * A list of known schemas and/or associations of schemas to file names.
  5334. */
  5335. readonly schemas?: {
  5336. /**
  5337. * The URI of the schema, which is also the identifier of the schema.
  5338. */
  5339. readonly uri: string;
  5340. /**
  5341. * A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json'
  5342. */
  5343. readonly fileMatch?: string[];
  5344. /**
  5345. * The schema for the given URI.
  5346. */
  5347. readonly schema?: any;
  5348. }[];
  5349. }
  5350. export interface LanguageServiceDefaults {
  5351. readonly onDidChange: IEvent<LanguageServiceDefaults>;
  5352. readonly diagnosticsOptions: DiagnosticsOptions;
  5353. setDiagnosticsOptions(options: DiagnosticsOptions): void;
  5354. }
  5355. export var jsonDefaults: LanguageServiceDefaults;
  5356. }
  5357. /*---------------------------------------------------------------------------------------------
  5358. * Copyright (c) Microsoft Corporation. All rights reserved.
  5359. * Licensed under the MIT License. See License.txt in the project root for license information.
  5360. *--------------------------------------------------------------------------------------------*/
  5361. declare namespace monaco.languages.html {
  5362. export interface HTMLFormatConfiguration {
  5363. readonly tabSize: number;
  5364. readonly insertSpaces: boolean;
  5365. readonly wrapLineLength: number;
  5366. readonly unformatted: string;
  5367. readonly contentUnformatted: string;
  5368. readonly indentInnerHtml: boolean;
  5369. readonly preserveNewLines: boolean;
  5370. readonly maxPreserveNewLines: number;
  5371. readonly indentHandlebars: boolean;
  5372. readonly endWithNewline: boolean;
  5373. readonly extraLiners: string;
  5374. readonly wrapAttributes: 'auto' | 'force' | 'force-aligned' | 'force-expand-multiline';
  5375. }
  5376. export interface CompletionConfiguration {
  5377. [provider: string]: boolean;
  5378. }
  5379. export interface Options {
  5380. /**
  5381. * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments.
  5382. */
  5383. readonly format?: HTMLFormatConfiguration;
  5384. /**
  5385. * A list of known schemas and/or associations of schemas to file names.
  5386. */
  5387. readonly suggest?: CompletionConfiguration;
  5388. }
  5389. export interface LanguageServiceDefaults {
  5390. readonly onDidChange: IEvent<LanguageServiceDefaults>;
  5391. readonly options: Options;
  5392. setOptions(options: Options): void;
  5393. }
  5394. export var htmlDefaults: LanguageServiceDefaults;
  5395. export var handlebarDefaults: LanguageServiceDefaults;
  5396. export var razorDefaults: LanguageServiceDefaults;
  5397. }