repl: fix BSDs

pull/5188/head
Mike 'Fuzzy' Partin 2020-06-02 22:44:44 -07:00 committed by GitHub
parent d0ff9a7c4a
commit ac0fee8e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 293 additions and 0 deletions

View File

@ -0,0 +1,71 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// Mac version
// Need to be implemented
// Will serve as more advanced input method
// Based on the work of https://github.com/AmokHuginnsson/replxx
module readline
import os
#include <termios.h>
// Only use standard os.get_line
// Need implementation for readline capabilities
pub fn (mut r Readline) read_line_utf8(prompt string) ?ustring {
r.current = ''.ustring()
r.cursor = 0
r.prompt = prompt
r.search_index = 0
if r.previous_lines.len <= 1 {
r.previous_lines << ''.ustring()
r.previous_lines << ''.ustring()
}
else {
r.previous_lines[0] = ''.ustring()
}
print(r.prompt)
line := os.get_raw_line()
if line.len >= 0 {
r.current = line.ustring()
}
r.previous_lines[0] = ''.ustring()
r.search_index = 0
if r.current.s == '' {
return error('empty line')
}
return r.current
}
// Returns the string from the utf8 ustring
pub fn (mut r Readline) read_line(prompt string) ?string {
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s.s
}
// Standalone function without persistent functionnalities (eg: history)
// Returns utf8 based ustring
pub fn read_line_utf8(prompt string) ?ustring {
mut r := Readline{}
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s
}
// Standalone function without persistent functionnalities (eg: history)
// Return string from utf8 ustring
pub fn read_line(prompt string) ?string {
mut r := Readline{}
s := r.read_line(prompt) or {
return error(err)
}
return s
}

View File

@ -0,0 +1,71 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// Mac version
// Need to be implemented
// Will serve as more advanced input method
// Based on the work of https://github.com/AmokHuginnsson/replxx
module readline
import os
#include <sys/termios.h>
// Only use standard os.get_line
// Need implementation for readline capabilities
pub fn (mut r Readline) read_line_utf8(prompt string) ?ustring {
r.current = ''.ustring()
r.cursor = 0
r.prompt = prompt
r.search_index = 0
if r.previous_lines.len <= 1 {
r.previous_lines << ''.ustring()
r.previous_lines << ''.ustring()
}
else {
r.previous_lines[0] = ''.ustring()
}
print(r.prompt)
line := os.get_raw_line()
if line.len >= 0 {
r.current = line.ustring()
}
r.previous_lines[0] = ''.ustring()
r.search_index = 0
if r.current.s == '' {
return error('empty line')
}
return r.current
}
// Returns the string from the utf8 ustring
pub fn (mut r Readline) read_line(prompt string) ?string {
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s.s
}
// Standalone function without persistent functionnalities (eg: history)
// Returns utf8 based ustring
pub fn read_line_utf8(prompt string) ?ustring {
mut r := Readline{}
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s
}
// Standalone function without persistent functionnalities (eg: history)
// Return string from utf8 ustring
pub fn read_line(prompt string) ?string {
mut r := Readline{}
s := r.read_line(prompt) or {
return error(err)
}
return s
}

View File

@ -0,0 +1,71 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// Mac version
// Need to be implemented
// Will serve as more advanced input method
// Based on the work of https://github.com/AmokHuginnsson/replxx
module readline
import os
#include <sys/termios.h>
// Only use standard os.get_line
// Need implementation for readline capabilities
pub fn (mut r Readline) read_line_utf8(prompt string) ?ustring {
r.current = ''.ustring()
r.cursor = 0
r.prompt = prompt
r.search_index = 0
if r.previous_lines.len <= 1 {
r.previous_lines << ''.ustring()
r.previous_lines << ''.ustring()
}
else {
r.previous_lines[0] = ''.ustring()
}
print(r.prompt)
line := os.get_raw_line()
if line.len >= 0 {
r.current = line.ustring()
}
r.previous_lines[0] = ''.ustring()
r.search_index = 0
if r.current.s == '' {
return error('empty line')
}
return r.current
}
// Returns the string from the utf8 ustring
pub fn (mut r Readline) read_line(prompt string) ?string {
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s.s
}
// Standalone function without persistent functionnalities (eg: history)
// Returns utf8 based ustring
pub fn read_line_utf8(prompt string) ?ustring {
mut r := Readline{}
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s
}
// Standalone function without persistent functionnalities (eg: history)
// Return string from utf8 ustring
pub fn read_line(prompt string) ?string {
mut r := Readline{}
s := r.read_line(prompt) or {
return error(err)
}
return s
}

View File

@ -0,0 +1,71 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// Mac version
// Need to be implemented
// Will serve as more advanced input method
// Based on the work of https://github.com/AmokHuginnsson/replxx
module readline
import os
#include <sys/termios.h>
// Only use standard os.get_line
// Need implementation for readline capabilities
pub fn (mut r Readline) read_line_utf8(prompt string) ?ustring {
r.current = ''.ustring()
r.cursor = 0
r.prompt = prompt
r.search_index = 0
if r.previous_lines.len <= 1 {
r.previous_lines << ''.ustring()
r.previous_lines << ''.ustring()
}
else {
r.previous_lines[0] = ''.ustring()
}
print(r.prompt)
line := os.get_raw_line()
if line.len >= 0 {
r.current = line.ustring()
}
r.previous_lines[0] = ''.ustring()
r.search_index = 0
if r.current.s == '' {
return error('empty line')
}
return r.current
}
// Returns the string from the utf8 ustring
pub fn (mut r Readline) read_line(prompt string) ?string {
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s.s
}
// Standalone function without persistent functionnalities (eg: history)
// Returns utf8 based ustring
pub fn read_line_utf8(prompt string) ?ustring {
mut r := Readline{}
s := r.read_line_utf8(prompt) or {
return error(err)
}
return s
}
// Standalone function without persistent functionnalities (eg: history)
// Return string from utf8 ustring
pub fn read_line(prompt string) ?string {
mut r := Readline{}
s := r.read_line(prompt) or {
return error(err)
}
return s
}

View File

@ -60,6 +60,15 @@ pub fn (prefs &Preferences) should_compile_c(file string) bool {
if file.ends_with('_freebsd.c.v') && prefs.os != .freebsd {
return false
}
if file.ends_with('_openbsd.c.v') && prefs.os != .openbsd {
return false
}
if file.ends_with('_netbsd.c.v') && prefs.os != .netbsd {
return false
}
if file.ends_with('_dragonfly.c.v') && prefs.os != .dragonfly {
return false
}
if file.ends_with('_solaris.c.v') && prefs.os != .solaris {
return false
}