<commit_before>///<reference path='refs.ts'/>

module TDev
{
    export class SizeDesc
    {
        public elt:HTMLElement;
        public top:number;

        constructor(public stmt:AST.Stmt) {
            this.elt = this.stmt.renderedAs;
            this.top = Util.offsetIn(this.elt, TheEditor.codeInner).y;
        }
    }

    export class Selector
        extends SideTab
    {
        public codeButtons:HTMLElement[] = [];
        private topButtonRow:HTMLElement;
        private topLeftButtonRow:HTMLElement;
        private extractedName:HTMLInputElement;
        private bottomButtonRow:HTMLElement;
        private bottomLeftButtonRow:HTMLElement;
        private buttonsAround:HTMLElement;
        private selectionBlock:AST.Block;
        private selectionBegin = 0;
        private selectionEnd = 0;
        private tops:SizeDesc[] = [];
        private scrollCont:HTMLElement;
        private directAdd = false;
        private useCodeButtons = false;
        private displayDoubleTapHint = false;
        public codeView:HTMLElement;
        public selectedStmt:AST.Stmt;
        private selectionActive = false;
        private multiStmtSelectionActive = false;
        private dragMode = false;
        private sideKeyFocus = false;
        private topDrag:DragMarker;
        private bottomDrag: DragMarker;
        private breakpointBtn: HTMLElement;

        constructor() {
            super()
        }
        public somethingSelected() { return this.selectionActive; }
        public nonActionSelected() { return this.selectionActive && !(this.selectedStmt instanceof AST.ActionHeader); }
        public phoneNarrow() { return true }

        static insertionButtons(): { name: string; desc: string; tick: Ticks; node: string; widget?: string; }[] {
            return [
                <{ name: string; desc: string; tick: Ticks; node: string; widget?: string; }>{
                    name: "if", desc: lf("conditional"), tick: Ticks.codeIf,
                    node: "if \\u0001need_Boolean\\u003Acondition then { }"
                },
                {
                    name: "for", desc: lf("repeat code"), tick: Ticks.codeFor,
                    node: "for 0 <= i < \\u0001need_Number do { }"
                },
                {
                    name: "while", desc: lf("simple loop"), tick: Ticks.codeWhile,
                    node: "while \\u0001need_Boolean\\u003Aloop_condition do { }"
                },
                {
                    name: "for each", desc: lf("repeat on collection"), tick: Ticks.codeForEach,
                    node: "foreach e in \\u0001need_Collection\\u005bString\\u005d\\u003Acollection do { }", widget: "foreach"
                },
                {
                    name: "boxed", desc: lf("UI widget"), tick: Ticks.codeBoxed,
                    node: "do box { }", widget: "boxed"
                },
            ].filter(btn => !btn.widget || TheEditor.widgetEnabled(btn.widget));
        }

        public init(e:Editor)
        {
            super.init(e);
            this.codeView = e.codeInner;
        }

        private isSelected(n:AST.Stmt)
        {
            for (var i = this.selectionBegin; i <= this.selectionEnd; ++i)
                if (this.selectionBlock.stmts[i] == n) return true;
            return false;
        }

        public edit(n:AST.AstNode) {
            return TheEditor.editNode(n, false); // TODO XXX - why did we set refreshIds=true here previously?
        }

        private addAt(j:number, bl:AST.Block)
        {<commit_msg>don't use optional argument in inline type arguments<commit_after>///<reference path='refs.ts'/>

module TDev
{
    export class SizeDesc
    {
        public elt:HTMLElement;
        public top:number;

        constructor(public stmt:AST.Stmt) {
            this.elt = this.stmt.renderedAs;
            this.top = Util.offsetIn(this.elt, TheEditor.codeInner).y;
        }
    }

    export class Selector
        extends SideTab
    {
        public codeButtons:HTMLElement[] = [];
        private topButtonRow:HTMLElement;
        private topLeftButtonRow:HTMLElement;
        private extractedName:HTMLInputElement;
        private bottomButtonRow:HTMLElement;
        private bottomLeftButtonRow:HTMLElement;
        private buttonsAround:HTMLElement;
        private selectionBlock:AST.Block;
        private selectionBegin = 0;
        private selectionEnd = 0;
        private tops:SizeDesc[] = [];
        private scrollCont:HTMLElement;
        private directAdd = false;
        private useCodeButtons = false;
        private displayDoubleTapHint = false;
        public codeView:HTMLElement;
        public selectedStmt:AST.Stmt;
        private selectionActive = false;
        private multiStmtSelectionActive = false;
        private dragMode = false;
        private sideKeyFocus = false;
        private topDrag:DragMarker;
        private bottomDrag: DragMarker;
        private breakpointBtn: HTMLElement;

        constructor() {
            super()
        }
        public somethingSelected() { return this.selectionActive; }
        public nonActionSelected() { return this.selectionActive && !(this.selectedStmt instanceof AST.ActionHeader); }
        public phoneNarrow() { return true }

        static insertionButtons(): { name: string; desc: string; tick: Ticks; node: string; widget: string; }[] {
            return [{
                    name: "if", desc: lf("conditional"), tick: Ticks.codeIf,
                    node: "if \\u0001need_Boolean\\u003Acondition then { }",
                    widget:''
                },
                {
                    name: "for", desc: lf("repeat code"), tick: Ticks.codeFor,
                    node: "for 0 <= i < \\u0001need_Number do { }",
                    widget: ''
                },
                {
                    name: "while", desc: lf("simple loop"), tick: Ticks.codeWhile,
                    node: "while \\u0001need_Boolean\\u003Aloop_condition do { }",
                    widget: ''
                },
                {
                    name: "for each", desc: lf("repeat on collection"), tick: Ticks.codeForEach,
                    node: "foreach e in \\u0001need_Collection\\u005bString\\u005d\\u003Acollection do { }",
                    widget: "foreach",
                },
                {
                    name: "boxed", desc: lf("UI widget"), tick: Ticks.codeBoxed,
                    node: "do box { }",
                    widget: "boxed"
                },
            ].filter(btn => !btn.widget || TheEditor.widgetEnabled(btn.widget));
        }

        public init(e:Editor)
        {
            super.init(e);
            this.codeView = e.codeInner;
        }

        private isSelected(n:AST.Stmt)
        {
            for (var i = this.selectionBegin; i <= this.selectionEnd; ++i)
                if (this.selectionBlock.stmts[i] == n) return true;
            return false;
        }

        public edit(n:AST.AstNode) {
            return TheEditor.editNode(n, false); // TODO XXX - why did we set refreshIds=true here previously?
        }

        private addAt(j:number, bl:AST.Block)
        {
{'fraction_non_alphanumeric': 0.10520456443083774, 'fraction_numerical': 0.009462844419704982, 'mean_word_length': 1.7759752800308999, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, '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': '3348107', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1908, 'n_words': 452}