Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Dec 7, 2024
1 parent 443bada commit 7977821
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
12 changes: 6 additions & 6 deletions cmd.v
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ fn (mut ved Ved) build_app(extra string) {
building_cmd := 'sh ${build_file}'
eprintln('building with `${building_cmd}` ...')

mut last_view := ved.get_last_view()
last_view_idx := ved.last_view_idx()

os.write_file(out_file, 'Building...') or { panic(err) }
last_view.open_file(out_file, 0)
ved.views[last_view_idx].open_file(out_file, 0)

out := os.execute(building_cmd)
if out.exit_code == -1 {
return
}

os.write_file(out_file, filter_ascii_colors(out.output)) or { panic(err) }
last_view.open_file(out_file, 0)
ved.views[last_view_idx].open_file(out_file, 0)

last_view.shift_g()
ved.views[last_view_idx].shift_g()
// error line
alines := out.output.split_into_lines()
lines := alines.filter(it.contains('.v:') || it.contains('.go:'))
Expand Down Expand Up @@ -77,8 +77,8 @@ fn (mut ved Ved) build_app(extra string) {
ved.is_building = false
// Move to the first line of the output in the last view, so that it's
// always visible
last_view.from = 0
last_view.set_y(0)
ved.views[last_view_idx].from = 0
ved.views[last_view_idx].set_y(0)
/*
// Reopen files (they were formatted)
for _view in ved.views {
Expand Down
26 changes: 20 additions & 6 deletions ved.v
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ fn main() {
if size.width == 0 || size.height == 0 {
size = $if small_window ? { gg.Size{770, 480} } $else { gg.Size{2560, 1440} }
}
if size.height % 20 != 0 {
size.height -= size.height % 20
// Fix macbook notch crap
$if macos {
if size.height % 20 != 0 {
// size.height -= size.height % 20 + ved.cfg.line_height
size.height -= 32 // ved.cfg.line_height
}
}
println('size=${size}')
mut ved := &Ved{
Expand Down Expand Up @@ -266,16 +270,22 @@ fn main() {
}

fn (mut ved Ved) on_event(e &gg.Event) {
println('on even ${ved.win_width}')
// println('on_event ${ved.win_width}')
ved.refresh = true
/*
// TODO change win height/width only on cmd + enter (exit full screen etc)
mut size := gg.screen_size()
if size.height % 20 != 0 {
size.height -= size.height % 20 + ved.cfg.line_height
// Fix macbook notch crap
$if macos {
if size.height % 20 != 0 {
// size.height -= size.height % 20 + ved.cfg.line_height
size.height -= 32 // ved.cfg.line_height
}
}
println(size)
ved.win_height = size.height
ved.win_width = size.width
*/

if e.typ == .mouse_scroll {
if e.scroll_y < -0.2 {
Expand Down Expand Up @@ -1901,6 +1911,10 @@ fn (ved &Ved) get_last_view() &View {
}
}

fn (ved &Ved) last_view_idx() int {
return (ved.workspace_idx + 1) * ved.nr_splits - 1
}

fn (mut ved Ved) save_changed_files() {
for i, view in ved.views {
if view.changed {
Expand Down

0 comments on commit 7977821

Please sign in to comment.