Initial stuff
This commit is contained in:
commit
85ac6a1d55
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build/**
|
||||
*.exe
|
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug",
|
||||
"program": "${workspaceFolder}/<executable file>",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
BIN
Debug.rdbg
Normal file
BIN
Debug.rdbg
Normal file
Binary file not shown.
BIN
assets/RecMonoSemicasual-Regular-1.084.ttf
Normal file
BIN
assets/RecMonoSemicasual-Regular-1.084.ttf
Normal file
Binary file not shown.
154
code/launch.odin
Normal file
154
code/launch.odin
Normal file
@ -0,0 +1,154 @@
|
||||
package sectr
|
||||
|
||||
import "core:io"
|
||||
import "core:fmt"
|
||||
import "core:mem"
|
||||
import "core:mem/virtual"
|
||||
import "core:strings"
|
||||
import "core:unicode/utf8"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
kilobytes :: proc ( kb : $integer_type ) -> integer_type {
|
||||
return kb * 1024
|
||||
}
|
||||
megabytes :: proc ( kb : $integer_type ) -> integer_type {
|
||||
return kb * 1024 * 1024
|
||||
}
|
||||
|
||||
Frame :: struct {
|
||||
bounds : rl.Rectangle
|
||||
// collision_bounds : rl.Rectangle, // Interaction space
|
||||
// nav_bounds : rl.Rectangle // Navigation space
|
||||
}
|
||||
|
||||
TextLine :: [dynamic]u8
|
||||
TextBox :: struct {
|
||||
using frame : Frame,
|
||||
text : strings.Builder,
|
||||
|
||||
// TODO(Ed) : Make use of the lines view, this will tell use when a line begins or ends
|
||||
lines : [dynamic]TextLine,
|
||||
cursor_pos : i32
|
||||
}
|
||||
|
||||
// TextBlob :: struct {
|
||||
// buffer : string
|
||||
// }
|
||||
|
||||
Null_Rune : rune = 0
|
||||
|
||||
Color_BG :: rl.Color { 41, 41, 45, 255 }
|
||||
Color_BG_TextBox :: rl.Color { 32, 32, 32, 255 }
|
||||
Color_Frame_Hover :: rl.Color { 122, 122, 125, 255 }
|
||||
Color_Frame_Select :: rl.Color { 188, 188, 188, 255 }
|
||||
|
||||
Path_Assets :: "../assets/"
|
||||
|
||||
main :: proc()
|
||||
{
|
||||
// Rough setup of window with rl stuff
|
||||
screen_width : i32 = 1280
|
||||
screen_height : i32 = 1000
|
||||
win_title : cstring = "Sectr Prototype"
|
||||
rl.InitWindow( screen_width, screen_height, win_title )
|
||||
defer {
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
||||
monitor_id := rl.GetCurrentMonitor()
|
||||
monitor_refresh_rate := rl.GetMonitorRefreshRate( monitor_id )
|
||||
rl.SetTargetFPS( monitor_refresh_rate )
|
||||
|
||||
font_rec_mono_semicasual_reg : rl.Font; {
|
||||
path_rec_mono_semicasual_reg := strings.concatenate( { Path_Assets, "RecMonoSemicasual-Regular-1.084.ttf" } )
|
||||
cstr := strings.clone_to_cstring(path_rec_mono_semicasual_reg)
|
||||
font_rec_mono_semicasual_reg = rl.LoadFontEx( cstr, 24, nil, 0 )
|
||||
delete( cstr )
|
||||
}
|
||||
|
||||
hovered_frame : ^Frame = nil
|
||||
focused_frame : ^Frame = nil
|
||||
text_box : TextBox
|
||||
{
|
||||
builder, err := strings.builder_make_len_cap( 0, megabytes( cast(int) 1 ) / 4 )
|
||||
if err != mem.Allocator_Error.None {
|
||||
fmt.println( "Failed to allocate text arena!" )
|
||||
return
|
||||
}
|
||||
text_box.text = builder
|
||||
}
|
||||
|
||||
for ; ! rl.WindowShouldClose() ;
|
||||
{
|
||||
mouse_pos := rl.GetMousePosition()
|
||||
|
||||
// Logic Update
|
||||
{
|
||||
rect := &text_box.bounds
|
||||
rect.width = 900
|
||||
rect.height = 400
|
||||
rect.x = cast(f32) (screen_width / 2) - rect.width / 2.0
|
||||
rect.y = cast(f32) (screen_height / 2) - rect.height
|
||||
|
||||
if rl.CheckCollisionPointRec( mouse_pos, rect^ ) {
|
||||
hovered_frame = & text_box
|
||||
}
|
||||
else {
|
||||
hovered_frame = nil
|
||||
}
|
||||
|
||||
if rl.IsMouseButtonPressed( rl.MouseButton.LEFT )
|
||||
{
|
||||
if hovered_frame != nil {
|
||||
focused_frame = hovered_frame
|
||||
}
|
||||
else {
|
||||
focused_frame = nil
|
||||
}
|
||||
}
|
||||
|
||||
if focused_frame != nil {
|
||||
for code_point := rl.GetCharPressed();
|
||||
code_point != Null_Rune;
|
||||
{
|
||||
strings.write_rune( & text_box.text, code_point );
|
||||
code_point = rl.GetCharPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rendering
|
||||
{
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground( Color_BG )
|
||||
|
||||
// Text Box
|
||||
{
|
||||
rl.DrawRectangleRec( text_box.bounds, Color_BG_TextBox )
|
||||
|
||||
if focused_frame != nil {
|
||||
rl.DrawRectangleLinesEx( focused_frame.bounds, 2, Color_Frame_Select )
|
||||
}
|
||||
else if hovered_frame != nil {
|
||||
rl.DrawRectangleLinesEx( hovered_frame.bounds, 2, Color_Frame_Hover )
|
||||
}
|
||||
|
||||
txt_str := strings.to_string( text_box.text )
|
||||
runes := utf8.string_to_runes(txt_str)
|
||||
|
||||
rl.GuiSetFont( font_rec_mono_semicasual_reg )
|
||||
if len(txt_str) > 0 {
|
||||
rl.DrawTextCodepoints( font_rec_mono_semicasual_reg, raw_data( runes ),
|
||||
cast(i32) len(runes),
|
||||
rl.Vector2 { text_box.bounds.x + 10, text_box.bounds.y + 10 },
|
||||
24.0, // font size
|
||||
0.0, // font spacing
|
||||
rl.WHITE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
}
|
||||
}
|
3
code/sectr.odin
Normal file
3
code/sectr.odin
Normal file
@ -0,0 +1,3 @@
|
||||
package sectr
|
||||
|
||||
|
9
examples/arithmetic.sectr
Normal file
9
examples/arithmetic.sectr
Normal file
@ -0,0 +1,9 @@
|
||||
2 + 2
|
||||
4 - 2
|
||||
6 * 3
|
||||
4 / 2
|
||||
|
||||
+ 2 2
|
||||
- 4 2
|
||||
* 6 3
|
||||
/ 4 2
|
13
ols.json
Normal file
13
ols.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json",
|
||||
"collections": [
|
||||
{
|
||||
"name": "core",
|
||||
"path": "C:\\apps\\Microsoft VS Code\\core"
|
||||
}
|
||||
],
|
||||
"enable_document_symbols": true,
|
||||
"enable_semantic_tokens": true,
|
||||
"enable_hover": true,
|
||||
"enable_snippets": true
|
||||
}
|
78
scripts/build.ps1
Normal file
78
scripts/build.ps1
Normal file
@ -0,0 +1,78 @@
|
||||
cls
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_code = join-path $path_root 'code'
|
||||
$path_build = join-path $path_root 'build'
|
||||
|
||||
# Odin Compiler Flags
|
||||
|
||||
$flag_build = 'build'
|
||||
$flag_run = 'run'
|
||||
$flag_check = 'check'
|
||||
$flag_query = 'query'
|
||||
$flag_report = 'report'
|
||||
$flag_debug = '-debug'
|
||||
$flag_output_path = '-out='
|
||||
$flag_optimization_level = '-opt:'
|
||||
$flag_optimize_none = '-o:none'
|
||||
$flag_optimize_minimal = '-o:minimal'
|
||||
$flag_optimize_size = '-o:size'
|
||||
$flag_optimize_speed = '-o:speed'
|
||||
$falg_optimize_aggressive = '-o:aggressive'
|
||||
$flag_show_timings = '-show-timings'
|
||||
$flag_show_more_timings = '-show-more-timings'
|
||||
$flag_thread_count = '-thread-count:'
|
||||
$flag_collection = '-collection:'
|
||||
$flag_build_mode = '-build-mode:'
|
||||
$flag_no_bounds_check = '-no-bounds-check'
|
||||
$flag_disable_assert = '-disable-assert'
|
||||
$flag_no_thread_local = '-no-thread-local'
|
||||
$flag_no_thread_checker = '-no-thread-checker'
|
||||
$flag_vet_all = '-vet'
|
||||
$flag_vet_unused_entities = '-vet-unused'
|
||||
$flag_vet_semicolon = '-vet-semicolon'
|
||||
$flag_vet_shadow_vars = '-vet-shadowing'
|
||||
$flag_vet_using_stmt = '-vet-using-stmt'
|
||||
$flag_use_separate_modules = '-use-separate-modules'
|
||||
$flag_define = '-define:'
|
||||
|
||||
$flag_extra_assembler_flags = '-extra_assembler-flags:'
|
||||
$flag_extra_linker_flags = '-extra-linker-flags:'
|
||||
$flag_ignore_unknown_attributes = '-ignore-unknown-attributes'
|
||||
$flag_keep_temp_files = '-keep-temp-files'
|
||||
$flag_no_crt = '-no-crt'
|
||||
$flag_no_entrypoint = '-no-entry-point'
|
||||
$flag_pdb_name = '-pdb-name:'
|
||||
$flag_sanitize = '-sanitize:'
|
||||
$flag_subsystem = '-subsystem:'
|
||||
$flag_target = '-target:'
|
||||
$flag_use_lld = '-lld'
|
||||
|
||||
push-location $path_root
|
||||
|
||||
if ( -not( test-path 'build') ) {
|
||||
new-item -ItemType Directory -Path 'build'
|
||||
}
|
||||
function build-prototype
|
||||
{
|
||||
push-location $path_code
|
||||
|
||||
$project_name = 'sectr'
|
||||
$executable = join-path $path_build ($project_name + '.exe')
|
||||
$pdb = join-path $path_build ($project_name + '.pdb')
|
||||
|
||||
$build_args = @()
|
||||
$build_args += $flag_build
|
||||
$build_args += '.'
|
||||
$build_args += $flag_output_path + $executable
|
||||
$build_args += $flag_optimize_none
|
||||
$build_args += $flag_debug
|
||||
$build_args += $flag_pdb_name + $pdb
|
||||
$build_args += $flag_subsystem + 'windows'
|
||||
|
||||
& odin $build_args
|
||||
|
||||
Pop-Location
|
||||
}
|
||||
build-prototype
|
||||
pop-location
|
9
scripts/clean.ps1
Normal file
9
scripts/clean.ps1
Normal file
@ -0,0 +1,9 @@
|
||||
cls
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_code = join-path $path_root 'code'
|
||||
$path_build = join-path $path_root 'build'
|
||||
|
||||
if ( test-path $path_build ) {
|
||||
Remove-Item $path_build -Verbose -Force -Recurse
|
||||
}
|
Loading…
Reference in New Issue
Block a user