修复界面错误,完成布局编写

This commit is contained in:
chenxinquan 2022-11-18 15:40:28 +08:00
parent d1a43996f8
commit 3832c0c72b
3 changed files with 80 additions and 10 deletions

View File

@ -200,6 +200,59 @@ func (fr *FrameReport)KeyBinding(g *gocui.Gui) error {
FRAMEREPORTVIEW_VIEWNAME_VULNINFO,
gocui.KeyEnter, gocui.ModNone, fr.NextView))
// FRAMEREPORTVIEW_VIEWNAME_REPORT
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyTab, gocui.ModNone, fr.NextView))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlQ, gocui.ModNone, fr.PreView))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlH, gocui.ModNone, fr.NextView))
// rcs = append(rcs, g.SetKeybinding(FRAMEREPORTVIEW_VIEWNAME_REPORT, gocui.KeyCtrlL, gocui.ModNone, fr.NextView))
// rcs = append(rcs, g.SetKeybinding(FRAMEREPORTVIEW_VIEWNAME_REPORT, gocui.KeyArrowUp, gocui.ModAlt, fr.PreView))
// rcs = append(rcs, g.SetKeybinding(FRAMEREPORTVIEW_VIEWNAME_REPORT, gocui.KeyArrowLeft, gocui.ModAlt, fr.NextView))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyArrowDown, gocui.ModNone, fr.CursorDown))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyArrowUp, gocui.ModNone, fr.CursorUp))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlJ, gocui.ModNone, fr.CursorDown))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlK, gocui.ModNone, fr.CursorUp))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlD, gocui.ModNone, fr.CursorPageDown))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlU, gocui.ModNone, fr.CursorPageUp))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeySpace, gocui.ModNone, fr.CursorPageDown))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyBackspace, gocui.ModNone, fr.CursorPageUp))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyBackspace2, gocui.ModNone, fr.CursorPageUp))
// rcs = append(rcs, g.SetKeybinding(
// FRAMEREPORTVIEW_VIEWNAME_REPORT,
// gocui.KeyCtrlM, gocui.ModNone, fr.CursorMoveMiddle))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlN, gocui.ModNone, fr.NextSummary))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyCtrlP, gocui.ModNone, fr.PreSummary))
rcs = append(rcs, g.SetKeybinding(
FRAMEREPORTVIEW_VIEWNAME_REPORT,
gocui.KeyEnter, gocui.ModNone, fr.NextView))
for _, rc := range rcs {
if rc != nil {
return rc

View File

@ -48,6 +48,8 @@ type ViewRact struct {
Bottom int
}
///////////////////////////////
// layout ract
func VIEWRACT_TARGET(maxx int, maxy int) ViewRact {
return ViewRact{(-1),
(-1),
@ -60,18 +62,21 @@ func VIEWRACT_VULN(maxx int, maxy int) ViewRact {
maxx,
int(float64(maxy)*0.3) }
}
func VIEWRACT_REPORT(maxx int, maxy int) ViewRact {
return ViewRact{32,
(int(float64(maxy)*0.3)),
(int(float64(maxx - 32)*0.5)),
maxy }
}
func VIEWRACT_VULNINFO(maxx int, maxy int) ViewRact {
return ViewRact{32 + (int(float64(maxx - 32)*0.5)),
(int(float64(maxy)*0.3)),
maxx,
maxy }
}
func VIEWRACT_REPORT(maxx int, maxy int) ViewRact {
return ViewRact{32,
(int(float64(maxy)*0.3)),
32 + (int(float64(maxx - 32)*0.5)),
maxy }
}
// layout ract
///////////////////////////////
func (fr *FrameReport)SetTargetLayout(g *gocui.Gui) error {
viewract := VIEWRACT_TARGET(g.Size())
@ -147,9 +152,12 @@ func (fr *FrameReport)SetVulnInfoLayout(g *gocui.Gui) error {
}
func (fr *FrameReport)SetReportLayout(g *gocui.Gui) error {
maxX, maxY := g.Size()
viewract := VIEWRACT_REPORT(g.Size())
view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_REPORT,
viewract.Left, viewract.Top,
viewract.Right, viewract.Bottom);
view, rc := g.SetView(FRAMEREPORTVIEW_VIEWNAME_REPORT, 40, int(float64(maxY)*0.3), maxX, maxY)
/* */
if (nil != rc) {
if (gocui.ErrUnknownView != rc) {
@ -179,6 +187,8 @@ func (fr *FrameReport)NextView(g *gocui.Gui, v *gocui.View) error {
case FRAMEREPORTVIEW_VIEWNAME_VULN:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULNINFO)
case FRAMEREPORTVIEW_VIEWNAME_VULNINFO:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_REPORT)
case FRAMEREPORTVIEW_VIEWNAME_REPORT:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET)
default:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULN)
@ -195,11 +205,13 @@ func (fr *FrameReport)PreView(g *gocui.Gui, v *gocui.View) error {
switch ( v.Name() ) {
case FRAMEREPORTVIEW_VIEWNAME_TARGET:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_REPORT)
case FRAMEREPORTVIEW_VIEWNAME_REPORT:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULNINFO)
case FRAMEREPORTVIEW_VIEWNAME_VULN:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET)
case FRAMEREPORTVIEW_VIEWNAME_VULNINFO:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_VULN)
case FRAMEREPORTVIEW_VIEWNAME_VULN:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET)
default:
rc = g.SetCurrentView(FRAMEREPORTVIEW_VIEWNAME_TARGET)
} // switch ( v ...

View File

@ -75,5 +75,10 @@ func layout(g *gocui.Gui) error {
return rc
} // if (nil != ...
rc = G_FrameReport.SetReportLayout(g)
if (nil != rc) {
return rc
} // if (nil != ...
return nil
}