Current state of editor
This commit is contained in:
parent
51475279dd
commit
890eb3f802
8
go.mod
8
go.mod
|
@ -23,12 +23,12 @@ require (
|
||||||
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 // indirect
|
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 // indirect
|
||||||
github.com/stretchr/testify v1.7.2 // indirect
|
github.com/stretchr/testify v1.7.2 // indirect
|
||||||
github.com/tevino/abool v1.2.0 // indirect
|
github.com/tevino/abool v1.2.0 // indirect
|
||||||
github.com/yuin/goldmark v1.4.0 // indirect
|
github.com/yuin/goldmark v1.4.13 // indirect
|
||||||
golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect
|
golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect
|
||||||
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect
|
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
|
golang.org/x/net v0.5.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
|
golang.org/x/sys v0.4.0 // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.6.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
|
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
|
||||||
)
|
)
|
||||||
|
|
13
go.sum
13
go.sum
|
@ -279,8 +279,9 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
github.com/yuin/goldmark v1.4.0 h1:OtISOGfH6sOWa1/qXqqAiOIAO6Z5J3AEAE18WAq6BiQ=
|
|
||||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
|
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||||
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
||||||
|
@ -379,8 +380,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
|
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
|
@ -451,8 +452,9 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
|
|
||||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||||
|
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
@ -462,8 +464,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||||
|
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
|
|
@ -10,7 +10,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
|
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
|
||||||
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
|
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
|
||||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
|
golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098 h1:YuekqPskqwCCPM79F1X5Dhv4ezTCj+Ki1oNwiafxkA0=
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
|
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
|
|
@ -3,8 +3,6 @@ package app
|
||||||
import (
|
import (
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
"fyne.io/fyne/v2/container"
|
|
||||||
|
|
||||||
"gitea.mmo.to/ProtocolPacketForger/ppf/internal/ui"
|
"gitea.mmo.to/ProtocolPacketForger/ppf/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,18 +20,6 @@ func Appmain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateApp() *fyne.Container {
|
func CreateApp() *fyne.Container {
|
||||||
ui.PPF.Toolbar = ui.CreateToolbar(fyneApp)
|
ppf := ui.NewPPF(fyneApp, w)
|
||||||
ui.PPF.Workarea = ui.CreateWorkarea()
|
return ppf.GetContainer()
|
||||||
ui.PPF.Extensions = container.NewCenter()
|
|
||||||
ui.PPF.ProtocolMeta = ui.CreateMetadataProtocol()
|
|
||||||
ui.PPF.Metadata = &ui.PPF.ProtocolMeta.Metadata
|
|
||||||
ui.PPF.ContextBar = container.NewCenter()
|
|
||||||
|
|
||||||
return container.NewBorder(
|
|
||||||
ui.PPF.Toolbar,
|
|
||||||
ui.PPF.ContextBar,
|
|
||||||
ui.PPF.Metadata.Representation,
|
|
||||||
ui.PPF.Extensions,
|
|
||||||
container.NewVScroll(ui.PPF.Workarea),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/dialog"
|
||||||
"fyne.io/fyne/v2/theme"
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
|
"gitea.mmo.to/ProtocolPacketForger/ppf/protocol"
|
||||||
|
"gitea.mmo.to/ProtocolPacketForger/ppf/protocolctl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ppfApp struct {
|
type ppfApp struct {
|
||||||
|
App fyne.App
|
||||||
|
Window fyne.Window
|
||||||
// Container for the borderlayout
|
// Container for the borderlayout
|
||||||
Toolbar fyne.CanvasObject
|
Toolbar fyne.CanvasObject
|
||||||
Metadata *Metadata
|
Metadata *Metadata
|
||||||
Extensions *fyne.Container
|
Extensions *fyne.Container
|
||||||
ContextBar *fyne.Container
|
ContextBar *fyne.Container
|
||||||
ContentTabs *fyne.Container
|
ContentTabs *fyne.Container
|
||||||
Workarea *fyne.Container
|
Workarea *container.DocTabs
|
||||||
// Once initialized metadata containers for swapping
|
// Once initialized metadata containers for swapping
|
||||||
ProtocolMeta *ProtocolMetadata
|
ProtocolMeta *ProtocolMetadata
|
||||||
PacketMeta *PacketMetadata
|
PacketMeta *PacketMetadata
|
||||||
|
@ -23,26 +31,105 @@ type ppfApp struct {
|
||||||
// Once initialized instances of the editor views
|
// Once initialized instances of the editor views
|
||||||
EditorPacket *PacketEditor
|
EditorPacket *PacketEditor
|
||||||
EditorProtocol *ProtocolEditor
|
EditorProtocol *ProtocolEditor
|
||||||
|
// workspace handling
|
||||||
|
OpenProtocolFiles []*ProtocolFileHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
var PPF ppfApp
|
var PPF ppfApp
|
||||||
|
|
||||||
|
func NewPPF(fyneApp fyne.App, w fyne.Window) ppfApp {
|
||||||
|
PPF.App = fyneApp
|
||||||
|
PPF.Window = w
|
||||||
|
PPF.Toolbar = CreateToolbar(fyneApp)
|
||||||
|
PPF.Workarea = CreateWorkarea()
|
||||||
|
PPF.Extensions = container.NewCenter()
|
||||||
|
PPF.ProtocolMeta = NewMetadataProtocol()
|
||||||
|
PPF.Metadata = &PPF.ProtocolMeta.Metadata
|
||||||
|
PPF.ContextBar = container.NewCenter()
|
||||||
|
return PPF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ppf *ppfApp) GetContainer() *fyne.Container {
|
||||||
|
return container.NewBorder(
|
||||||
|
PPF.Toolbar,
|
||||||
|
PPF.ContextBar,
|
||||||
|
PPF.Metadata.Representation,
|
||||||
|
PPF.Extensions,
|
||||||
|
PPF.Workarea,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ppf *ppfApp) OpenFile(path string) {
|
||||||
|
pfh := LoadProtocolFileHandler(path)
|
||||||
|
ppf.OpenProtocolFiles = append(PPF.OpenProtocolFiles, pfh)
|
||||||
|
ppf.Workarea.Append(container.NewTabItem(pfh.Filename, pfh.GetWorkarea()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ppf *ppfApp) NewFile() {
|
||||||
|
pfh := NewProtocolFileHandler()
|
||||||
|
PPF.OpenProtocolFiles = append(PPF.OpenProtocolFiles, pfh)
|
||||||
|
ppf.Workarea.Append(container.NewTabItem(pfh.Filename, pfh.GetWorkarea()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ppf *ppfApp) SaveFile(path string) {
|
||||||
|
item := ppf.Workarea.Selected()
|
||||||
|
for _, pfh := range ppf.OpenProtocolFiles {
|
||||||
|
if pfh.Filename == item.Text {
|
||||||
|
protocolctl.Save(pfh.ProtocolEditor.Reference, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.Text = path
|
||||||
|
ppf.Workarea.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ppf *ppfApp) GetReferenceForFile(s string) *protocol.ProtocolStructure {
|
||||||
|
for _, pfh := range ppf.OpenProtocolFiles {
|
||||||
|
if pfh.Filename == s {
|
||||||
|
return pfh.ProtocolEditor.Reference
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func CreateToolbar(fyneApp fyne.App) fyne.CanvasObject {
|
func CreateToolbar(fyneApp fyne.App) fyne.CanvasObject {
|
||||||
toolbar := widget.NewToolbar()
|
toolbar := widget.NewToolbar()
|
||||||
toolbar.Append(widget.NewToolbarAction(theme.StorageIcon(), func() {
|
toolbar.Append(widget.NewToolbarAction(theme.MenuIcon(), func() {
|
||||||
PPF.ProtocolForging = !PPF.ProtocolForging
|
PPF.ProtocolForging = !PPF.ProtocolForging
|
||||||
//TODO: implement the switch
|
//TODO: implement the switch
|
||||||
}))
|
}))
|
||||||
toolbar.Append(widget.NewToolbarSeparator())
|
toolbar.Append(widget.NewToolbarSeparator())
|
||||||
toolbar.Append(widget.NewToolbarAction(theme.FolderNewIcon(), func() {
|
toolbar.Append(widget.NewToolbarAction(theme.ContentAddIcon(), func() {
|
||||||
|
PPF.NewFile()
|
||||||
}))
|
}))
|
||||||
toolbar.Append(widget.NewToolbarAction(theme.FolderOpenIcon(), func() {
|
toolbar.Append(widget.NewToolbarAction(theme.FolderOpenIcon(), func() {
|
||||||
|
dialog.NewFileOpen(func(uri fyne.URIReadCloser, err error) {
|
||||||
|
if uri == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
PPF.OpenFile(uri.URI().Path())
|
||||||
|
}, PPF.Window).Show()
|
||||||
}))
|
}))
|
||||||
toolbar.Append(widget.NewToolbarAction(theme.DocumentSaveIcon(), func() {
|
toolbar.Append(widget.NewToolbarAction(theme.DocumentSaveIcon(), func() {
|
||||||
|
if strings.HasPrefix(PPF.Workarea.Selected().Text, "*new") {
|
||||||
|
dialog.NewFileSave(func(uri fyne.URIWriteCloser, err error) {
|
||||||
|
if uri == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
PPF.SaveFile(uri.URI().Path())
|
||||||
|
}, PPF.Window).Show()
|
||||||
|
} else {
|
||||||
|
PPF.SaveFile(PPF.Workarea.Selected().Text)
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
toolbar.Append(widget.NewToolbarAction(theme.StorageIcon(), func() {
|
||||||
|
dialog.NewFileSave(func(uri fyne.URIWriteCloser, err error) {
|
||||||
|
if uri == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
PPF.SaveFile(uri.URI().Path())
|
||||||
|
}, PPF.Window).Show()
|
||||||
|
}))
|
||||||
|
|
||||||
toolbar.Append(widget.NewToolbarAction(theme.SettingsIcon(), func() {
|
toolbar.Append(widget.NewToolbarAction(theme.SettingsIcon(), func() {
|
||||||
|
|
||||||
}))
|
}))
|
||||||
|
@ -54,6 +141,18 @@ func CreateToolbar(fyneApp fyne.App) fyne.CanvasObject {
|
||||||
return toolbar
|
return toolbar
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateWorkarea() *fyne.Container {
|
func CreateWorkarea() *container.DocTabs {
|
||||||
return GetProtocolEditor().Representation
|
tabs := container.NewDocTabs()
|
||||||
|
tabs.OnClosed = func(ti *container.TabItem) {
|
||||||
|
if len(tabs.Items) == 0 {
|
||||||
|
PPF.Metadata.Representation.Hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tabs.OnSelected = func(ti *container.TabItem) {
|
||||||
|
PPF.ProtocolMeta.SetProtocol(PPF.GetReferenceForFile(ti.Text))
|
||||||
|
PPF.Metadata = &PPF.ProtocolMeta.Metadata
|
||||||
|
PPF.Metadata.Representation.Refresh()
|
||||||
|
PPF.Metadata.Representation.Show()
|
||||||
|
}
|
||||||
|
return tabs
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (pmd *ProtocolMetadata) SetChanged(setfunc func(s string)) {
|
||||||
pmd.OsiLayer.OnChanged = setfunc
|
pmd.OsiLayer.OnChanged = setfunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateMetadataProtocol() *ProtocolMetadata {
|
func NewMetadataProtocol() *ProtocolMetadata {
|
||||||
md := ProtocolMetadata{}
|
md := ProtocolMetadata{}
|
||||||
vbox := container.NewVBox()
|
vbox := container.NewVBox()
|
||||||
vbox.Add(widget.NewLabel("Protocol Metadata"))
|
vbox.Add(widget.NewLabel("Protocol Metadata"))
|
||||||
|
@ -87,8 +87,7 @@ func CreateMetadataProtocol() *ProtocolMetadata {
|
||||||
return &md
|
return &md
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetProtocolMetadata(prot *protocol.ProtocolStructure) {
|
func (md *ProtocolMetadata) SetProtocol(prot *protocol.ProtocolStructure) {
|
||||||
md := PPF.ProtocolMeta
|
|
||||||
setfunc := func(s string) {
|
setfunc := func(s string) {
|
||||||
protocolctl.UpdateMetaData(
|
protocolctl.UpdateMetaData(
|
||||||
prot,
|
prot,
|
||||||
|
@ -102,9 +101,14 @@ func SetProtocolMetadata(prot *protocol.ProtocolStructure) {
|
||||||
fmt.Printf("%s", protocolctl.ToJson(prot))
|
fmt.Printf("%s", protocolctl.ToJson(prot))
|
||||||
}
|
}
|
||||||
md.SetChanged(setfunc)
|
md.SetChanged(setfunc)
|
||||||
|
md.Representation.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateMetadataPacket() *PacketMetadata {
|
func (md *ProtocolMetadata) Unset() {
|
||||||
|
md.SetChanged(func(s string) {})
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMetadataPacket() *PacketMetadata {
|
||||||
md := PacketMetadata{}
|
md := PacketMetadata{}
|
||||||
vbox := container.NewVBox()
|
vbox := container.NewVBox()
|
||||||
vbox.Add(widget.NewLabel("Packet Metadata"))
|
vbox.Add(widget.NewLabel("Packet Metadata"))
|
||||||
|
|
|
@ -23,6 +23,13 @@ func GetProtocolEditor() *ProtocolEditor {
|
||||||
return protocolEditor
|
return protocolEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewProtocolEditor(ref *protocol.ProtocolStructure) *ProtocolEditor {
|
||||||
|
container := container.NewGridWrap(fyne.NewSize(300, 400))
|
||||||
|
protocolEditor := &ProtocolEditor{container, []*FieldEditor{}, ref}
|
||||||
|
protocolEditor.Redraw()
|
||||||
|
return protocolEditor
|
||||||
|
}
|
||||||
|
|
||||||
func (ed *ProtocolEditor) AddFieldCreator(fieldCreator *FieldEditor) {
|
func (ed *ProtocolEditor) AddFieldCreator(fieldCreator *FieldEditor) {
|
||||||
ed.Fields = append(ed.Fields, fieldCreator)
|
ed.Fields = append(ed.Fields, fieldCreator)
|
||||||
ed.Redraw()
|
ed.Redraw()
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"gitea.mmo.to/ProtocolPacketForger/ppf/protocol"
|
||||||
|
"gitea.mmo.to/ProtocolPacketForger/ppf/protocolctl"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProtocolFileHandler struct {
|
||||||
|
ProtocolEditor *ProtocolEditor
|
||||||
|
Filename string
|
||||||
|
Changed bool
|
||||||
|
|
||||||
|
Reference *protocol.ProtocolStructure
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProtocolFileHandler() *ProtocolFileHandler {
|
||||||
|
pfh := ProtocolFileHandler{}
|
||||||
|
pfh.Filename = "*new"
|
||||||
|
pfh.Changed = true
|
||||||
|
pfh.ProtocolEditor = GetProtocolEditor()
|
||||||
|
return &pfh
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadProtocolFileHandler(path string) *ProtocolFileHandler {
|
||||||
|
pfh := ProtocolFileHandler{}
|
||||||
|
pfh.Filename = path
|
||||||
|
pfh.Load()
|
||||||
|
return &pfh
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pfh *ProtocolFileHandler) Load() {
|
||||||
|
prot, err := protocolctl.LoadNew(pfh.Filename)
|
||||||
|
if err != nil {
|
||||||
|
// process error
|
||||||
|
}
|
||||||
|
pfh.ProtocolEditor = NewProtocolEditor(prot)
|
||||||
|
pfh.Reference = prot
|
||||||
|
PPF.ProtocolMeta.SetProtocol(prot)
|
||||||
|
}
|
||||||
|
func (pfh *ProtocolFileHandler) Save() {
|
||||||
|
|
||||||
|
pfh.Changed = false
|
||||||
|
}
|
||||||
|
func (pfh *ProtocolFileHandler) GetWorkarea() *container.Scroll {
|
||||||
|
return container.NewVScroll(pfh.ProtocolEditor.Representation)
|
||||||
|
}
|
Loading…
Reference in New Issue