<commit_before>/* wim -- modal text editor */

/* Testing -- write a string to the canvas */
const read_one=(e,context)=>{
    if(!e.target.files[0]){console.log('no file found');return;}
    const rat=(e)=>{
        let r=new FileReader();
        r.onload=(e)=>render(context,e.target.result);
        r.readAsText(e.target.files[0]);
    };
    rat(e);
};
document.getElementById('file-input').addEventListener('change',(e)=>read_one(e,ctx),false);

/* render : context -> String -> ()*/
const render=(c,lines)=>{
    c.clearRect(0,0,c.canvas.width,c.canvas.height);
    let la=lines.split('\n'),pos=0;
    la.map(l=>{
        pos+=20;
        c.fillText(l,20,pos);
    });
};

/* update : AnyEvent -> Action */
const update=(perf_now,input)=>{
    //console.table(SM.decode(input.KS[0].slice(-1)[0]));
    console.log(SM.handle_evt(SM.decode(input.KS[0].slice(-1)[0])));
    //console.log(Array.from(input.KC));// chords
};


/* Model -- inputs */
const IN={KC:new Set(),/* {Chord} */ KS:[[],[],[],[]],/* [Key] */};

/* Model -- state machine */
const SM={
    multiplier:1,
    multiplier_str:'1',
    current_state:'mult0',
    initial_state:'mult0',

    SEQS:{/* {Type:[Char]} */
        mult0:'123456789',
        multN:'0123456789',
        verb:'cdvy',
        modifier:'ai',
        text_object:'0^${}()[]<>`"\'bBeEwWG',
        motion:'hjkl',
        search_char:'fFtT',
        edit:'aAiIoOpPrxX',
        undo:'u',
        repeat:',.',
    },

    /* SEQS is an object with Type keys and [Char] values.
       SEQS_INV is an object with Char keys and [Type] values.
       Computed and cached at first use. */
    get SEQS_INV(){/* {Char:[Type]} */
        delete this.SEQS_INV;/* (lazy-cache) */
        let i_table={};
        for(let s in this.SEQS){
            [...this.SEQS[s]].forEach(x=>{<commit_msg>use `let` instead of `const` for things that vary<commit_after>/* wim -- modal text editor */

/* Testing -- write a string to the canvas */
const read_one=(e,context)=>{
    if(!e.target.files[0]){console.log('no file found');return;}
    const rat=(e)=>{
        let r=new FileReader();
        r.onload=(e)=>render(context,e.target.result);
        r.readAsText(e.target.files[0]);
    };
    rat(e);
};
document.getElementById('file-input').addEventListener('change',(e)=>read_one(e,ctx),false);

/* render : context -> String -> ()*/
const render=(c,lines)=>{
    c.clearRect(0,0,c.canvas.width,c.canvas.height);
    let la=lines.split('\n'),pos=0;
    la.map(l=>{
        pos+=20;
        c.fillText(l,20,pos);
    });
};

/* update : AnyEvent -> Action */
const update=(perf_now,input)=>{
    //console.table(SM.decode(input.KS[0].slice(-1)[0]));
    console.log(SM.handle_evt(SM.decode(input.KS[0].slice(-1)[0])));
    //console.log(Array.from(input.KC));// chords
};


/* Model -- inputs */
let IN={KC:new Set(),/* {Chord} */ KS:[[],[],[],[]],/* [Key] */};

/* Model -- state machine */
let SM={
    multiplier:1,
    multiplier_str:'1',
    current_state:'mult0',
    initial_state:'mult0',

    SEQS:{/* {Type:[Char]} */
        mult0:'123456789',
        multN:'0123456789',
        verb:'cdvy',
        modifier:'ai',
        text_object:'0^${}()[]<>`"\'bBeEwWG',
        motion:'hjkl',
        search_char:'fFtT',
        edit:'aAiIoOpPrxX',
        undo:'u',
        repeat:',.',
    },

    /* SEQS is an object with Type keys and [Char] values.
       SEQS_INV is an object with Char keys and [Type] values.
       Computed and cached at first use. */
    get SEQS_INV(){/* {Char:[Type]} */
        delete this.SEQS_INV;/* (lazy-cache) */
        let i_table={};
        for(let s in this.SEQS){
            [...this.SEQS[s]].forEach(x=>{
{'fraction_non_alphanumeric': 0.2207721587819467, 'fraction_numerical': 0.021750951604132682, 'mean_word_length': 2.727456940222898, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '559214', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1324, 'n_words': 235}