示例#1
0
文件: list.go 项目: langxj/gxui
func (l *List) SelectNext() {
	if l.selectedItem != nil {
		selectedIndex := l.adapter.ItemIndex(l.selectedItem)
		l.Select(l.adapter.ItemAt(math.Mod(selectedIndex+1, l.itemCount)))
	} else {
		l.Select(l.adapter.ItemAt(0))
	}
}
示例#2
0
文件: tagMatcher.go 项目: tcw/saxer
func (tm *TagMatcher) AddTag(tagText string) {
	tagNameEnd := 0
	insideAttrValue := false
	insideAttrKey := false
	readSpace := false
	readEquals := false
	tm.tmpAttrPos = 0
	var separator rune = 0
	cleanedTag := tagText
	if strings.HasSuffix(tagText, "/") {
		cleanedTag = strings.TrimRight(tagText, "/")
	}
	trimmed := strings.TrimSpace(cleanedTag)
	for key, value := range trimmed {
		if value == rune(' ') && !insideAttrValue {
			if tagNameEnd == 0 {
				tagNameEnd = key
			}
			readSpace = true
		} else if value == rune('=') && !insideAttrValue {
			readEquals = true
			tm.tmpAttr[tm.tmpAttrPos] = key
			tm.tmpAttrPos++
		} else if readEquals && !insideAttrValue && (value == rune('\'') || value == rune('"')) {
			separator = value
			insideAttrValue = true
			insideAttrKey = false
			readEquals = false
			tm.tmpAttr[tm.tmpAttrPos] = key + 1
			tm.tmpAttrPos++
		} else if readSpace && !insideAttrValue {
			if !insideAttrKey {
				tm.tmpAttr[tm.tmpAttrPos] = key
				tm.tmpAttrPos++
			}
			insideAttrKey = true
		} else if value == separator && insideAttrValue {
			separator = 0
			insideAttrValue = false
			tm.tmpAttr[tm.tmpAttrPos] = key
			tm.tmpAttrPos++
		}
	}
	tag := tm.path.NextTag()
	if tm.tmpAttrPos == 0 {
		tag.Name = strings.TrimSpace(tagText)
	} else {
		tag.Name = tagText[:tagNameEnd]
	}
	if math.Mod(tm.tmpAttrPos, 4) == 0 {
		for i := 0; i < tm.tmpAttrPos; i = i + 4 {
			tag.AddAttribute(strings.TrimSpace(tagText[tm.tmpAttr[i]:tm.tmpAttr[i+1]]), tagText[tm.tmpAttr[i+2]:tm.tmpAttr[i+3]])
		}
	} else {
		panic("Parser tag attribute error")
	}
}