Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file lTerm_read_line_base.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137(*
* lTerm_read_line_base.ml
* ------------
* Copyright : (c) 2020, ZAN DoYe <zandoye@gmail.com>
* Licence : BSD3
*
* This file is a part of Lambda-Term.
*)(* +-----------------------------------------------------------------+
| Actions |
+-----------------------------------------------------------------+ *)letpervasives_compare=compareexceptionInterrupttypeaction=|EditofLTerm_edit.action|Interrupt_or_delete_next_char|Complete|Complete_bar_next|Complete_bar_prev|Complete_bar_first|Complete_bar_last|Complete_bar|History_prev|History_next|History_search_prev|History_search_next|Accept|Clear_screen|Prev_search|Next_search|Cancel_search|Break|Suspend|Edit_with_external_editorletdoc_of_action=function|Editaction->LTerm_edit.doc_of_actionaction|Interrupt_or_delete_next_char->"interrupt if at the beginning of an empty line, or delete the next character."|Complete->"complete current input."|Complete_bar_next->"go to the next possible completion in the completion bar."|Complete_bar_prev->"go to the previous possible completion in the completion bar."|Complete_bar_first->"go to the beginning of the completion bar."|Complete_bar_last->"go to the end of the completion bar."|Complete_bar->"complete current input using the completion bar."|History_prev->"go to the previous entry of the history."|History_next->"go to the next entry of the history."|History_search_prev->"go to the previous entry of the history that matches the start of the current line."|History_search_next->"go to the next entry of the history that matches the start of the current line."|Accept->"accept the current input."|Clear_screen->"clear the screen."|Prev_search->"search backward in the history."|Next_search->"search forward in the history."|Cancel_search->"cancel search mode."|Break->"cancel edition."|Suspend->"suspend edition."|Edit_with_external_editor->"edit input with external editor command."letactions=[Interrupt_or_delete_next_char,"interrupt-or-delete-next-char";Complete,"complete";Complete_bar_next,"complete-bar-next";Complete_bar_prev,"complete-bar-prev";Complete_bar_first,"complete-bar-first";Complete_bar_last,"complete-bar-last";Complete_bar,"complete-bar";History_prev,"history-prev";History_next,"history-next";History_search_prev,"history-search-prev";History_search_next,"history-search-next";Accept,"accept";Clear_screen,"clear-screen";Prev_search,"prev-search";Next_search,"next-search";Cancel_search,"cancel-search";Break,"break";Suspend,"suspend";Edit_with_external_editor,"edit-with-external-editor";]letactions_to_names=Array.of_list(List.sort(fun(a1,_)(a2,_)->pervasives_comparea1a2)actions)letnames_to_actions=Array.of_list(List.sort(fun(_,n1)(_,n2)->pervasives_comparen1n2)actions)letaction_of_namex=letrecloopab=ifa=bthenEdit(LTerm_edit.action_of_namex)elseletc=(a+b)/2inletaction,name=Array.unsafe_getnames_to_actionscinmatchpervasives_comparexnamewith|dwhend<0->loopac|dwhend>0->loop(c+1)b|_->actioninloop0(Array.lengthnames_to_actions)letname_of_actionx=letrecloopab=ifa=bthenraiseNot_foundelseletc=(a+b)/2inletaction,name=Array.unsafe_getactions_to_namescinmatchpervasives_comparexactionwith|dwhend<0->loopac|dwhend>0->loop(c+1)b|_->nameinmatchxwith|Editx->LTerm_edit.name_of_actionx|_->loop0(Array.lengthactions_to_names)(* +-----------------------------------------------------------------+
| Event loop |
+-----------------------------------------------------------------+ *)type'aloop_result=|Resultof'a|ContinueLoopofLTerm_key.tlisttype'aloop_status=|EvofLTerm_event.t|Loop_resultof'a|Interruptedofexn