summary refs log tree commit diff stats
path: root/compiler/nimeval.nim
Commit message (Collapse)AuthorAgeFilesLines
* Added nimscript support to repl (#10834)sealmove2019-03-131-2/+7
| | | | | * added nimscript support to repl * added bool parameter to runRepl en/disabling nimscript support
* Fixed order of output in repl and added a proc for opening a custom repl ↵sealmove2019-03-101-1/+23
| | | | (#10802)
* test case for #9180 and re-enables the disabled tcompilerapi test (#9181)Timothee Cour2018-10-111-0/+7
| | | | | | * add findNimStdLibCompileTime and un-disable tcompilerapi test; add test case for #9180 * address comments
* compiler refactoring; use typesafe path handing; docgen: render symbols ↵Andreas Rumpf2018-09-071-3/+3
| | | | between modules
* make tests green againAndreas Rumpf2018-06-111-2/+2
|
* incremental compilation: implemented basic replay logicAndreas Rumpf2018-06-021-0/+1
|
* compiler API: final cleanups; improve security by diabling 'gorge' and friendsAndreas Rumpf2018-05-291-3/+6
|
* rewrote nimeval.nim; added tcompilerapi example to show how the compiler can ↵Andreas Rumpf2018-05-291-23/+104
| | | | be used as an API
* rename 'nimrodVM' to 'nimVM'Andreas Rumpf2018-05-281-1/+1
|
* fixes #7522Araq2018-04-061-0/+1
|
* removed compiler internal list implementation (#5371)Arne Döring2017-02-221-2/+2
|
* Fix compilation error in nimeval.Aditya Siram2016-11-271-5/+6
|
* compiler: Trim .nim files trailing whitespaceAdam Strzelecki2015-09-041-1/+1
| | | | via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
* Make nimeval compiledef2015-01-121-1/+1
|
* Nimrod renamed to NimAraq2014-08-281-2/+2
|
* xmltree.`<>` macro works againAraq2014-02-271-4/+4
|
* first steps to a new evaluation engineAraq2013-07-241-0/+33
ef3726e3ad6657f5f41c9462c'>^
71087546 ^

















d7cb6d7d ^
ab963e4e ^
5dfffae9 ^
da1f2491 ^
b94597a6 ^
5dfffae9 ^



71087546 ^
5dfffae9 ^

b94597a6 ^
71087546 ^
5dfffae9 ^
71087546 ^

e3a2ad47 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78


                 
              
               
 
                  
                
              
                    
 
                                    
                                           
                                       



                                          


                                           



                                         
                  
                    

                                              
       
                                 


                        



                                                
              
                                 
                               
                     

















                                                                       
                                                             
                         
                                   
                                         
                                



                           
                                                                              

               
                                                                
                                                           
                    

            
      
import httpClient
import uri
import os
import streams
import terminal

import html/parser
import io/buffer
import io/term
import config/config

let clientInstance = newHttpClient()
proc loadRemotePage*(url: string): string =
  return clientInstance.getContent(url)

proc loadLocalPage*(url: string): string =
  return readFile(url)

proc getRemotePage*(url: string): Stream =
  return clientInstance.get(url).bodyStream

proc getLocalPage*(url: string): Stream =
  return newFileStream(url, fmRead)

proc getPageUri(uri: Uri): Stream =
  var moduri = uri
  moduri.anchor = ""
  if uri.scheme == "" or uri.scheme == "file":
    return getLocalPage($moduri)
  else:
    return getRemotePage($moduri)

var buffers: seq[Buffer]

proc die() =
  eprint "Invalid parameters. Usage:\ntwt <url>"
  quit(1)

proc main*() =
  let attrs = getTermAttributes()
  let buffer = newBuffer(attrs)
  buffers.add(buffer)

  var lastUri: Uri
  if paramCount() < 1:
    if not isatty(stdin):
      try:
        while true:
          buffer.source &= stdin.readChar()
      except EOFError:
        #TODO handle failure (also, is this even portable at all?)
        discard reopen(stdin, "/dev/tty", fmReadWrite);
    else:
      die()
    buffer.setLocation(lastUri)
  else: 
    lastUri = parseUri(paramStr(1))
    buffer.source = getPageUri(lastUri).readAll() #TODO get rid of this

  buffer.setLocation(lastUri)
  buffer.document = parseHtml(newStringStream(buffer.source))
  buffer.renderDocument()
  while displayPage(attrs, buffer):
    buffer.setStatusMessage("Loading...")
    var newUri = buffer.location
    lastUri.anchor = ""
    newUri.anchor = ""
    if $lastUri != $newUri:
      buffer.clearBuffer()
      if lastUri.scheme == "" and lastUri.path == "" and lastUri.anchor != "":
        discard
      else:
        buffer.document = parseHtml(getPageUri(buffer.location))
      buffer.renderPlainText(getPageUri(lastUri).readAll())
    lastUri = newUri

readConfig()
main()