Mercurial > repos > tabletprog
view src/editor.tp @ 72:ab6f24d6945d
Fix determination of whether a method call has an implicit self argument or not. Cleanup C warnings in output.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 14 Jul 2012 21:00:21 -0700 |
parents | 668f533e5284 |
children | 648659961e0e |
line wrap: on
line source
#{ //mquery functions q <- foreign: :query {} qall <- foreign: :query {} each <- foreign: :iterable fun {} addClass <- foreign: :node className {} removeClass <- foreign: :node className {} get <- foreign: :url onSuccess onFail onOther {} newEl <- foreign: :tagname props {} //TP Parser parser <- foreign: #{ parse <- foreign: :str {} } isLambda <- foreign: :astnode {} //js builtins console <- foreign: #{ log <- foreign: :val {} } window <- foreign: #{} Object <- foreign: #{ keys <- foreign: :object {} } //kernel definitions import: kernel //editor code editFile <- :path { get: path :request { addClass: (q: "body") "editorMode" src <- request responseText ast <- parser parse: src ast populateSymbols: (foreign: null) ast toHTML: (q: "#src") } } selectNode <- :node { each: (qall: ".selected") :idx el { removeClass: el "selected" } addClass: node "selected" } selectQuery <- :selector { selectQuery: selector in: (foreign: undefined) } selectQuery:in <- :selector :context { each: (qall: ".selected") :idx el { removeClass: el "selected" } each: (qall: selector context) :idx el { addClass: el "selected" } } selectParent <- :node { each: (qall: ".selectParent") :idx el { removeClass: el "selected" } addClass: (node parentNode) "selectParent" } popInscope:onClick <- :syms :handler { inscope <- q: "#inscope" inscope innerHTML!: "" each: syms :idx key { inscope appendChild: (newEl: "li" #{ textContent <- key onclick <- { handler: key } }) } } symbolClick <- :domnode astnode event { console log: astnode selectNode: domnode popInscope: ((astnode symbols) allSymbols) onClick: :key { domnode textContent!: key astnode name!: key } event stopPropagation } funClick <- :domnode astnode event { selectParent: domnode selectQuery: ".selectParent > .funpart" in: (domnode parentNode) symtable <- astnode symbols syms <- filter: (symtable allSymbols) :sym { isLambda: ((symtable find: sym) def) } popInscope: syms onClick: {} event stopPropagation } lambdaClick <- :domnode astnode event { symbolClick: domnode astnode event } main <- { get: "/src/" :data { fakeEl <- newEl: "div" #{ innerHTML <- data response } each: (qall: "a" fakeEl) :idx el { if: ((el textContent) = "../") {} else: { nel <- newEl: "a" #{ href <- "/edit/src/" + (el textContent) textContent <- el textContent } nel onclick!: :event { link <- foreign: this path <- link href path <- path substr: (path indexOf: "/edit/") + 5 editFile: path foreign: false } li <- newEl: "li" li appendChild: nel (q: "#browser ul") appendChild: li } } } //bind handlers for editor buttons each: (qall: ".controls li") :idx el { el onclick!: :event { srcel <- (q: "#src") srcel textContent!: (srcel textContent) + (el textContent) } } (q: "#ops_button") onclick!: :event { each: (qall: ".controls") :idx el { addClass: el "showops" } } path <- (window location) pathname if: (path indexOf: "/edit/") = 0 { editFile: (path substr: 5) } else: {} } }