github.com/jmigpin/editor@v1.6.0/core/internalcmds/copyfileposition.go (about) 1 package internalcmds 2 3 import ( 4 "fmt" 5 6 "github.com/jmigpin/editor/core" 7 "github.com/jmigpin/editor/util/parseutil" 8 ) 9 10 func CopyFilePosition(args0 *core.InternalCmdArgs) error { 11 erow := args0.ERow 12 13 if !erow.Info.IsFileButNotDir() { 14 return fmt.Errorf("not a file") 15 } 16 17 ta := erow.Row.TextArea 18 ci := ta.CursorIndex() 19 rd := ta.RW() 20 line, col, err := parseutil.IndexLineColumn(rd, ci) 21 if err != nil { 22 return err 23 } 24 25 s := fmt.Sprintf("copyfileposition:\n\t%v:%v:%v", erow.Info.Name(), line, col) 26 erow.Ed.Messagef(s) 27 28 return nil 29 }