You can search for identifiers within the package.
in-package search v0.2.0
Source file Turbo_menus.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130(* Claude Code
*
* Copyright (C) 2026 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* (LGPL) as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*)(* See Turbo_menus.mli *)openTurbo_modelletitemlabelhotshortcutaction={label;hot;shortcut;action}letmenus:(string*itemlist)list=[("File",[item"Open..."'O'"F3"Open;item"New"'N'""New;item"Save"'S'"F2"Save;item"Save as..."'a'""Save_as;item"Exit"'x'"Alt+X"Exit]);("Search",[item"Find..."'F'""Find;item"Search again"'S'"Ctrl+L"Find_again;item"Go to line number..."'G'""Goto_line]);("Run",[item"Run"'R'"Ctrl+F9"Run;item"Step over"'S'"F8"Step_over;item"Trace into"'T'"F7"Trace_into;item"Go to cursor"'G'"F4"Go_to_cursor;item"Program reset"'P'"Ctrl+F2"Reset;item"User screen"'U'"Alt+F5"User_screen]);("Compile",[item"Compile"'C'"Alt+F9"Compile;item"Make"'M'"F9"Compile;item"P-code"'P'""Pcode_listing]);("Debug",[item"Call stack"'C'"Ctrl+F3"Call_stack;item"Add watch..."'W'"Ctrl+F7"Add_watch;item"Toggle breakpoint"'B'"Ctrl+F8"Toggle_breakpoint;item"Remove all watches"'R'""Clear_watches]);("Help",[item"Keys"'K'"F1"Keys;item"About..."'A'""About])](*****************************************************************************)(* Menus and dialogs *)(*****************************************************************************)letfiles(m:model):stringlist=List.sortcompare(List.mapfstm.disk)letwrite(m:model)(file:string):model={mwithdisk=(file,Turbo_edit.textm)::List.remove_assocfilem.disk;file;modified=false}letact(m:model)(a:action):model=letm={mwithmode=Editing}inmatchawith|Open->{mwithmode=Open_dialog0}|New->{(Turbo_edit.loadm"")withlines=[|""|];file=Turbo_edit.noname}|Save->ifm.file=Turbo_edit.nonamethen{mwithmode=Input{title="Save File As";label="Save file as";text="";purpose=Saving_as}}elsewritemm.file|Save_as->{mwithmode=Input{title="Save File As";label="Save file as";text="";purpose=Saving_as}}|Exit->{mwithquit=true}|Find->{mwithmode=Input{title="Find";label="Text to find";text=m.search;purpose=Finding}}|Find_again->Turbo_edit.findmm.search|Goto_line->{mwithmode=Input{title="Go to Line Number";label="Enter new line number";text="";purpose=Going_to}}|Run->Turbo_debug.gom(Continuem.breakpoints)|Trace_into->Turbo_debug.gomTrace_into|Step_over->Turbo_debug.gomStep_over|Go_to_cursor->Turbo_debug.gom(To_line(m.row+1))|Reset->{mwithsession=None}|User_screen->(match(m.session,m.last_screen)with|Somes,_->{mwithmode=Showings.user}|None,Somevt->{mwithmode=Showingvt}|None,None->{mwithmode=Showing(Vt.create~rows:24~cols:80)})|Call_stack->ifm.session=Nonethen{mwithmode=Info("Call Stack",["No program is running:";"F7 or F8 starts one."])}else{mwithmode=Stack}|Add_watch->{mwithmode=Input{title="Add Watch";label="Watch expression";text=Turbo_debug.word_atm;purpose=Watching}}|Toggle_breakpoint->letl=m.row+1in{mwithbreakpoints=(ifList.memlm.breakpointsthenList.filter((<>)l)m.breakpointselsel::m.breakpoints)}|Clear_watches->{mwithwatches=[]}|Compile->(matchTurbo_debug.compilemwithOk(p,m)->Turbo_debug.compiled_boxmp|Errorm->m)|Pcode_listing->(matchTurbo_debug.compilemwith|Errorm->m|Ok(p,m)->(* from the first instruction of the cursor's line *)letfirst=ref0in(tryArray.iteri(funil->ifl>=m.row+1then(first:=i;raiseExit))p.lineswithExit->());{mwithmode=Listing(max0(!first-3))})|Keys->{mwithmode=Info("Keys",["F9 Make Alt+F9 Compile Ctrl+F9 Run";"Alt+F5 User screen F2 Save F3 Open";"F10 or Alt+letter: the menus Alt+X Exit";"";"F7 Trace into F8 Step over F4 Go to cursor";"Ctrl+F8 Breakpoint Ctrl+F7 Watch Ctrl+F3 Calls";"Ctrl+F2 Reset Ctrl+C Break";"";"Arrows, or Ctrl+E X S D Ctrl+A F words";"Ctrl+Y delete a line Insert: overwrite";"Ctrl+L search again";"";"No F keys? Esc then 1 to 0 (or Alt+1 to Alt+0): F1 to F10,";"Ctrl+1 to Ctrl+0: Ctrl+F1 to Ctrl+F10 (Ctrl+9 Run)"])}|About->{mwithmode=Info("About",["Tiny Turbo Pascal";"";"after Turbo Pascal 7.0";"Anders Hejlsberg, Borland, 1983-1992";"";"compiled to P-code, as Wirth's Pascal-P";"and UCSD Pascal did"])}(* Alt and a letter, as xterm sends it: Escape then the letter *)letalt_letter(k:string):charoption=ifString.lengthk=2&&k.[0]='\x1b'thenSome(Char.lowercase_asciik.[1])elseNoneletmenu_of_letter(c:char):intoption=letrecgoi=function[]->None|(title,_)::rest->ifChar.lowercase_asciititle.[0]=cthenSomeielsego(i+1)restingo0menusletmenu_key(m:model)(bar:int)(sel:int)(k:string):model=letitems=snd(List.nthmenusbar)inletn=List.lengthitemsandnbar=List.lengthmenusinmatchkwith|"\x1b"->{mwithmode=Editing}|"\x1b[D"->{mwithmode=Menu((bar+nbar-1)modnbar,0)}|"\x1b[C"->{mwithmode=Menu((bar+1)modnbar,0)}|"\x1b[A"->{mwithmode=Menu(bar,(sel+n-1)modn)}|"\x1b[B"->{mwithmode=Menu(bar,(sel+1)modn)}|"\r"->actm(List.nthitemssel).action|_->(matchalt_letterkwith|Somec->(matchmenu_of_lettercwithSomeb->{mwithmode=Menu(b,0)}|None->m)|None->(letc=ifString.lengthk=1thenSome(Char.lowercase_asciik.[0])elseNoneinmatchList.find_opt(funit->Some(Char.lowercase_asciiit.hot)=c)itemswithSomeit->actmit.action|None->m))letinput_key(m:model)(title,label,text,purpose)(k:string):model=letagaintext={mwithmode=Input{title;label;text;purpose}}inmatchkwith|"\x1b"->{mwithmode=Editing}|"\r"->(letm={mwithmode=Editing}inmatchpurposewith|Saving_as->iftext=""thenmelsewritem(String.uppercase_asciitext)|Finding->Turbo_edit.findmtext|Going_to->(matchint_of_string_opt(String.trimtext)withSomen->{mwithrow=n-1;col=0}|None->m)|Watching->ifString.trimtext=""thenmelse{mwithwatches=m.watches@[String.trimtext]})|"\x7f"|"\b"->again(iftext=""then""elseString.subtext0(String.lengthtext-1))|_whenString.lengthk=1&&k.[0]>=' '->again(text^k)|_->m