mirror of
https://github.com/bloeys/gopad.git
synced 2025-12-29 06:58:21 +00:00
Update to nmage v0.23.1
This commit is contained in:
28
editor.go
28
editor.go
@ -5,8 +5,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
imgui "github.com/AllenDang/cimgui-go"
|
||||
"github.com/bloeys/gopad/settings"
|
||||
"github.com/inkyblackness/imgui-go/v4"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -87,7 +87,7 @@ func (e *Editor) RefreshFontSettings() {
|
||||
//
|
||||
//That's why instead of getting width of one char, we get the average width from the width of a sentence, which helps us position
|
||||
//cursors properly for now
|
||||
e.CharWidth = imgui.CalcTextSize("abcdefghijklmnopqrstuvwxyz", false, 1000).X / 26
|
||||
e.CharWidth = imgui.CalcTextSizeV("abcdefghijklmnopqrstuvwxyz", false, 1000).X / 26
|
||||
}
|
||||
|
||||
func (e *Editor) RoundToGridX(x float32) float32 {
|
||||
@ -105,11 +105,11 @@ func (e *Editor) UpdateAndDraw(drawStartPos, winSize *imgui.Vec2, newRunes []run
|
||||
imgui.SetNextWindowSize(*winSize)
|
||||
imgui.BeginV("editorText", nil, imgui.WindowFlagsNoCollapse|imgui.WindowFlagsNoDecoration|imgui.WindowFlagsNoMove)
|
||||
|
||||
imgui.PushStyleColor(imgui.StyleColorFrameBg, settings.EditorBgColor)
|
||||
imgui.PushStyleColor(imgui.StyleColorTextSelectedBg, settings.TextSelectionColor)
|
||||
imgui.PushStyleColorVec4(imgui.ColFrameBg, settings.EditorBgColor)
|
||||
imgui.PushStyleColorVec4(imgui.ColTextSelectedBg, settings.TextSelectionColor)
|
||||
|
||||
imgui.SetNextItemWidth(winSize.X)
|
||||
if imgui.InputTextMultilineV("", &e.FileContents, imgui.Vec2{X: winSize.X - winSize.X*0.02, Y: winSize.Y - winSize.Y*0.02}, imgui.InputTextFlagsNone, nil) {
|
||||
if imgui.InputTextMultiline("", &e.FileContents, imgui.Vec2{X: winSize.X - winSize.X*0.02, Y: winSize.Y - winSize.Y*0.02}, imgui.InputTextFlagsNone, nil) {
|
||||
e.IsModified = true
|
||||
}
|
||||
|
||||
@ -131,19 +131,19 @@ func (e *Editor) UpdateAndDraw(drawStartPos, winSize *imgui.Vec2, newRunes []run
|
||||
// posInfo := e.getPositions(&paddedDrawStartPos)
|
||||
// e.Insert(&posInfo, newRunes)
|
||||
|
||||
// if input.KeyClicked(sdl.K_LEFT) {
|
||||
// if input.KeyClickedCaptured(sdl.K_LEFT) {
|
||||
// e.MoveMouseXByChars(-1, &posInfo)
|
||||
// } else if input.KeyClicked(sdl.K_RIGHT) {
|
||||
// } else if input.KeyClickedCaptured(sdl.K_RIGHT) {
|
||||
// e.MoveMouseXByChars(1, &posInfo)
|
||||
// }
|
||||
|
||||
// if input.KeyClicked(sdl.K_UP) {
|
||||
// if input.KeyClickedCaptured(sdl.K_UP) {
|
||||
// e.MoveMouseYByLines(-1, &posInfo)
|
||||
// } else if input.KeyClicked(sdl.K_DOWN) {
|
||||
// } else if input.KeyClickedCaptured(sdl.K_DOWN) {
|
||||
// e.MoveMouseYByLines(1, &posInfo)
|
||||
// }
|
||||
|
||||
// if input.KeyClicked(sdl.K_BACKSPACE) {
|
||||
// if input.KeyClickedCaptured(sdl.K_BACKSPACE) {
|
||||
// e.Delete(&posInfo, 1)
|
||||
// }
|
||||
|
||||
@ -496,9 +496,9 @@ func roundF32(x float32) float32 {
|
||||
return float32(math.Round(float64(x)))
|
||||
}
|
||||
|
||||
func NewScratchEditor() *Editor {
|
||||
func NewScratchEditor() Editor {
|
||||
|
||||
e := &Editor{
|
||||
e := Editor{
|
||||
FileName: "**scratch**",
|
||||
LinesHead: NewLineNode(),
|
||||
}
|
||||
@ -506,14 +506,14 @@ func NewScratchEditor() *Editor {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewEditor(fPath string) *Editor {
|
||||
func NewEditor(fPath string) Editor {
|
||||
|
||||
b, err := os.ReadFile(fPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
e := &Editor{
|
||||
e := Editor{
|
||||
FileName: filepath.Base(fPath),
|
||||
FilePath: fPath,
|
||||
FileContents: string(b),
|
||||
|
||||
Reference in New Issue
Block a user