From daff481233c65e9ddbc059831b82c3111bf6a44e Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Thu, 29 Apr 2021 08:42:59 +0200 Subject: [PATCH] examples/text_editor: use mathutil for min/max functions (#9911) --- examples/term.ui/text_editor.v | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/examples/term.ui/text_editor.v b/examples/term.ui/text_editor.v index 0db552baa8..11bf4b0a7a 100644 --- a/examples/term.ui/text_editor.v +++ b/examples/term.ui/text_editor.v @@ -3,6 +3,7 @@ // Don't use this editor for any serious work. // A lot of funtionality is missing compared to your favourite editor :) import strings +import math.mathutil as mu import os import term.ui as tui @@ -329,11 +330,11 @@ fn (mut b Buffer) move_cursor(amount int, movement Movement) { } } .page_up { - dlines := imin(b.cursor.pos_y, amount) + dlines := mu.min(b.cursor.pos_y, amount) b.move_updown(-dlines) } .page_down { - dlines := imin(b.lines.len - 1, b.cursor.pos_y + amount) - b.cursor.pos_y + dlines := mu.min(b.lines.len - 1, b.cursor.pos_y + amount) - b.cursor.pos_y b.move_updown(dlines) } .left { @@ -392,14 +393,6 @@ fn (mut b Buffer) move_to_word(movement Movement) { b.cursor.set(x, y) } -fn imax(x int, y int) int { - return if x < y { y } else { x } -} - -fn imin(x int, y int) int { - return if x < y { x } else { y } -} - struct Cursor { pub mut: pos_x int