Skip to content

Commit

Permalink
rename Sup -> Known
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Jul 22, 2024
1 parent c20f29b commit f79f3c3
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion base/fileinfo/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (fi *FileInfo) SetType(ftyp Known) {
mt := MimeFromKnown(ftyp)
fi.Mime = mt.Mime
fi.Cat = mt.Cat
fi.Known = mt.Sup
fi.Known = mt.Known
if fi.Name == "" && len(mt.Exts) > 0 {
fi.Name = "_fake" + mt.Exts[0]
fi.Path = fi.Name
Expand Down
22 changes: 11 additions & 11 deletions base/fileinfo/mimetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type MimeType struct {
Cat Categories

// if known, the name of the known file type, else NoSupporUnknown
Sup Known
Known Known
}

// CustomMimes can be set by other apps to contain custom mime types that
Expand All @@ -158,7 +158,7 @@ func MimeKnown(mime string) Known {
if !has {
return Unknown
}
return mt.Sup
return mt.Known
}

// ExtKnown returns the known type for given file extension,
Expand All @@ -172,7 +172,7 @@ func ExtKnown(ext string) Known {
if !has {
return Unknown
}
return mt.Sup
return mt.Known
}

// KnownFromFile returns the known type for given file,
Expand All @@ -188,7 +188,7 @@ func KnownFromFile(fname string) Known {
// MimeFromKnown returns MimeType info for given known file type.
func MimeFromKnown(ftyp Known) MimeType {
for _, mt := range AvailableMimes {
if mt.Sup == ftyp {
if mt.Known == ftyp {
return mt
}
}
Expand Down Expand Up @@ -223,20 +223,20 @@ func MergeAvailableMimes() {
ExtMimeMap[ex] = mt.Mime
}
}
if mt.Sup != Unknown {
if hsp, has := KnownMimes[mt.Sup]; has {
fmt.Printf("fileinfo.MergeAvailMimes: more-than-one mimetype has extensions for same known file type: %v -- one: %v other %v\n", mt.Sup, hsp.Mime, mt.Mime)
if mt.Known != Unknown {
if hsp, has := KnownMimes[mt.Known]; has {
fmt.Printf("fileinfo.MergeAvailMimes: more-than-one mimetype has extensions for same known file type: %v -- one: %v other %v\n", mt.Known, hsp.Mime, mt.Mime)
} else {
KnownMimes[mt.Sup] = mt
KnownMimes[mt.Known] = mt
}
}
}
}
// second pass to get any known guys that don't have exts
for _, mt := range AvailableMimes {
if mt.Sup != Unknown {
if _, has := KnownMimes[mt.Sup]; !has {
KnownMimes[mt.Sup] = mt
if mt.Known != Unknown {
if _, has := KnownMimes[mt.Known]; !has {
KnownMimes[mt.Known] = mt
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions parse/filestates.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type FileStates struct {
Filename string

// the known file type, if known (typically only known files are processed)
Sup fileinfo.Known
Known fileinfo.Known

// base path for reporting file names -- this must be set externally e.g., by gide for the project root path
BasePath string
Expand Down Expand Up @@ -62,7 +62,7 @@ func (fs *FileStates) SetSrc(fname, basepath string, sup fileinfo.Known) {

fs.Filename = fname
fs.BasePath = basepath
fs.Sup = sup
fs.Known = sup

fs.FsA.SetSrc(nil, fname, basepath, sup)
fs.FsB.SetSrc(nil, fname, basepath, sup)
Expand Down
4 changes: 2 additions & 2 deletions parse/languages/golang/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (gl *GoLang) Lookup(fss *parse.FileStates, str string, pos lexer.Pos) (ld c
if CompleteTrace {
fmt.Printf("lookup str: %v orig: %v\n", str, origStr)
}
lfs := pr.ParseString(str, fpath, fs.Src.Sup)
lfs := pr.ParseString(str, fpath, fs.Src.Known)
if lfs == nil {
return
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func (gl *GoLang) CompleteLine(fss *parse.FileStates, str string, pos lexer.Pos)
if CompleteTrace {
fmt.Printf("complete str: %v orig: %v\n", str, origStr)
}
lfs := pr.ParseString(str, fpath, fs.Src.Sup)
lfs := pr.ParseString(str, fpath, fs.Src.Known)
if lfs == nil {
return
}
Expand Down
16 changes: 8 additions & 8 deletions parse/lexer/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type File struct {
Filename string

// the known file type, if known (typically only known files are processed)
Sup fileinfo.Known
Known fileinfo.Known

// base path for reporting file names -- this must be set externally e.g., by gide for the project root path
BasePath string
Expand All @@ -48,12 +48,12 @@ type File struct {

// SetSrc sets the source to given content, and alloc Lexs -- if basepath is empty
// then it is set to the path for the filename
func (fl *File) SetSrc(src [][]rune, fname, basepath string, sup fileinfo.Known) {
func (fl *File) SetSrc(src [][]rune, fname, basepath string, known fileinfo.Known) {
fl.Filename = fname
if basepath != "" {
fl.BasePath = basepath
}
fl.Sup = sup
fl.Known = known
fl.Lines = src
fl.AllocLines()
}
Expand Down Expand Up @@ -141,8 +141,8 @@ func (fl *File) OpenFile(fname string) error {
return err
}
rns := RunesFromBytes(alltxt)
sup := fileinfo.KnownFromFile(fname)
fl.SetSrc(rns, fname, "", sup)
known := fileinfo.KnownFromFile(fname)
fl.SetSrc(rns, fname, "", known)
return nil
}

Expand Down Expand Up @@ -173,23 +173,23 @@ func (fl *File) InitFromLine(sfl *File, ln int) bool {
return false
}
src := [][]rune{sfl.Lines[ln], {}} // need extra blank
fl.SetSrc(src, sfl.Filename, sfl.BasePath, sfl.Sup)
fl.SetSrc(src, sfl.Filename, sfl.BasePath, sfl.Known)
fl.Lexs = []Line{sfl.Lexs[ln], {}}
fl.Comments = []Line{sfl.Comments[ln], {}}
fl.EosPos = []EosPos{sfl.EosPos[ln], {}}
return true
}

// InitFromString initializes from given string. Returns false if string is empty
func (fl *File) InitFromString(str string, fname string, sup fileinfo.Known) bool {
func (fl *File) InitFromString(str string, fname string, known fileinfo.Known) bool {
if str == "" {
return false
}
src := RunesFromString(str)
if len(src) == 1 { // need more than 1 line
src = append(src, []rune{})
}
fl.SetSrc(src, fname, "", sup)
fl.SetSrc(src, fname, "", known)
return true
}

Expand Down
3 changes: 3 additions & 0 deletions shell/interpreter/cogentcore_org-core-base-stringsx.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion shell/interpreter/make
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ command cosh {
yaegi extract cogentcore.org/core/shell/cosh
}

shell.RunCommands(args)
// shell.RunCommands(args)
base
cosh

6 changes: 3 additions & 3 deletions texteditor/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func completeParse(data any, text string, posLine, posChar int) (md complete.Mat
// log.Printf("CompletePi: data is nil not FileStates or is nil - can't complete\n")
return md
}
lp, err := parse.LanguageSupport.Properties(sfs.Sup)
lp, err := parse.LanguageSupport.Properties(sfs.Known)
if err != nil {
// log.Printf("CompletePi: %v\n", err)
return md
Expand All @@ -47,7 +47,7 @@ func completeEditParse(data any, text string, cursorPos int, comp complete.Compl
// log.Printf("CompleteEditPi: data is nil not FileStates or is nil - can't complete\n")
return ed
}
lp, err := parse.LanguageSupport.Properties(sfs.Sup)
lp, err := parse.LanguageSupport.Properties(sfs.Known)
if err != nil {
// log.Printf("CompleteEditPi: %v\n", err)
return ed
Expand All @@ -67,7 +67,7 @@ func lookupParse(data any, text string, posLine, posChar int) (ld complete.Looku
// log.Printf("LookupPi: data is nil not FileStates or is nil - can't lookup\n")
return ld
}
lp, err := parse.LanguageSupport.Properties(sfs.Sup)
lp, err := parse.LanguageSupport.Properties(sfs.Known)
if err != nil {
// log.Printf("LookupPi: %v\n", err)
return ld
Expand Down
4 changes: 2 additions & 2 deletions texteditor/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func (ed *Editor) keyInput(e events.Event) {
if !e.HasAnyModifier(key.Control, key.Meta) {
e.SetHandled()
if ed.Buffer.Options.AutoIndent {
lp, _ := parse.LanguageSupport.Properties(ed.Buffer.ParseState.Sup)
lp, _ := parse.LanguageSupport.Properties(ed.Buffer.ParseState.Known)
if lp != nil && lp.Lang != nil && lp.HasFlag(parse.ReAutoIndent) {
// only re-indent current line for supported types
tbe, _, _ := ed.Buffer.AutoIndent(ed.CursorPos.Ln) // reindent current line
Expand Down Expand Up @@ -399,7 +399,7 @@ func (ed *Editor) keyInputInsertBracket(kt events.Event) {
newLine := false
curLn := ed.Buffer.Line(pos.Ln)
lnLen := len(curLn)
lp, _ := parse.LanguageSupport.Properties(ed.Buffer.ParseState.Sup)
lp, _ := parse.LanguageSupport.Properties(ed.Buffer.ParseState.Known)
if lp != nil && lp.Lang != nil {
match, newLine = lp.Lang.AutoBracket(&ed.Buffer.ParseState, kt.KeyRune(), pos, curLn)
} else {
Expand Down
2 changes: 1 addition & 1 deletion texteditor/textbuf/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ func (ls *Lines) indentLine(ln, ind int) *Edit {
// level and character position for the indent of the current line.
func (ls *Lines) autoIndent(ln int) (tbe *Edit, indLev, chPos int) {
tabSz := ls.Options.TabSize
lp, _ := parse.LanguageSupport.Properties(ls.ParseState.Sup)
lp, _ := parse.LanguageSupport.Properties(ls.ParseState.Known)
var pInd, delInd int
if lp != nil && lp.Lang != nil {
pInd, delInd, _, _ = lp.Lang.IndentLine(&ls.ParseState, ls.lines, ls.hiTags, ln, tabSz)
Expand Down
3 changes: 0 additions & 3 deletions yaegicore/symbols/cogentcore_org-core-icons.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f79f3c3

Please sign in to comment.