當前位置: 首頁>>代碼示例>>Golang>>正文


Golang View.Settings方法代碼示例

本文整理匯總了Golang中github.com/limetext/lime/backend.View.Settings方法的典型用法代碼示例。如果您正苦於以下問題:Golang View.Settings方法的具體用法?Golang View.Settings怎麽用?Golang View.Settings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/limetext/lime/backend.View的用法示例。


在下文中一共展示了View.Settings方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: onNew

// Called when a new view is opened
func (t *qmlfrontend) onNew(v *backend.View) {
	fv := &frontendView{bv: v}
	v.Buffer().AddObserver(fv)
	v.Settings().AddOnChange("blah", fv.onChange)

	fv.Title.Text = v.Buffer().FileName()
	if len(fv.Title.Text) == 0 {
		fv.Title.Text = "untitled"
	}

	w2 := t.windows[v.Window()]
	w2.views = append(w2.views, fv)

	tabs := w2.window.ObjectByName("tabs")
	tab := tabs.Call("addTab", "", limeViewComponent).(qml.Object)
	try_now := func() {
		item := tab.Property("item").(qml.Object)
		if item.Addr() == 0 {
			// Happens as the item isn't actually loaded until we switch to the tab.
			// Hence connecting to the loaded signal
			return
		}
		item.Set("myView", fv)
		item.Set("fontSize", v.Settings().Get("font_size", 12).(float64))
		item.Set("fontFace", v.Settings().Get("font_face", "Helvetica").(string))
	}
	tab.On("loaded", try_now)
	try_now()
	tabs.Set("currentIndex", tabs.Property("count").(int)-1)
}
開發者ID:rokite,項目名稱:lime,代碼行數:31,代碼來源:main.go

示例2: onNew

// Called when a new view is opened
func (t *qmlfrontend) onNew(v *backend.View) {
	fv := &frontendView{bv: v}
	v.Buffer().AddCallback(fv.bufferChanged)
	v.Settings().AddOnChange("blah", fv.onChange)

	fv.Title.Text = v.Buffer().FileName()
	if len(fv.Title.Text) == 0 {
		fv.Title.Text = "untitled"
	}

	w2 := t.windows[v.Window()]
	w2.views = append(w2.views, fv)

	tabs := w2.window.ObjectByName("tabs")
	tab := tabs.Call("addTab", "", limeViewComponent).(qml.Object)
	try_now := func() {
		item := tab.Property("item").(qml.Object)
		if item.Addr() == 0 {
			// Happens as the item isn't actually loaded until we switch to the tab.
			// Hence connecting to the loaded signal
			return
		}
		item.Set("myView", fv)
	}
	tab.On("loaded", try_now)
	try_now()
}
開發者ID:EDi-nabi,項目名稱:lime,代碼行數:28,代碼來源:main.go

示例3: FormatLine

func (t *tbfe) FormatLine(v *backend.View, line int) string {
	buf := bytes.NewBuffer(nil)
	vr := v.Buffer().Line(v.Buffer().TextPoint(line, 0))
	log4go.Debug("FormatLine: %d, %s", line, vr)
	if vr.Size() == 0 {
		return ""
	}
	recipie := v.Transform(scheme, vr).Transcribe()
	highlight_line := false
	if b, ok := v.Settings().Get("highlight_line", highlight_line).(bool); ok {
		highlight_line = b
	}
	lastEnd := vr.Begin()
	for _, reg := range recipie {
		if lastEnd != reg.Region.Begin() {
			fmt.Fprintf(buf, "<span>%s</span>", v.Buffer().Substr(Region{lastEnd, reg.Region.Begin()}))
		}
		fmt.Fprintf(buf, "<span style=\"white-space:pre; color:#%s; background:#%s\">%s</span>", htmlcol(reg.Flavour.Foreground), htmlcol(reg.Flavour.Background), v.Buffer().Substr(reg.Region))
		lastEnd = reg.Region.End()
	}
	if lastEnd != vr.End() {
		io.WriteString(buf, v.Buffer().Substr(Region{lastEnd, vr.End()}))
	}
	return buf.String()
}
開發者ID:rzh,項目名稱:lime,代碼行數:25,代碼來源:main.go

示例4: Run

func (c *GlueMarkedUndoGroupsCommand) Run(v *backend.View, e *backend.Edit) error {
	pos := v.UndoStack().Position()
	mark, ok := v.Settings().Get(lime_cmd_mark).(int)
	if !ok {
		return fmt.Errorf("No mark in the current view")
	}
	if l, p := pos-mark, mark; p != -1 && (l-p) > 1 {
		v.UndoStack().GlueFrom(mark)
	}
	return nil
}
開發者ID:BinaryPaean,項目名稱:lime,代碼行數:11,代碼來源:glue.go

示例5: renderView

func (t *tbfe) renderView(wr io.Writer, v *backend.View, lay layout) {
	p := util.Prof.Enter("render")
	defer p.Exit()

	vr := lay.visible
	runes := v.Buffer().Substr(vr)
	recipie := v.Transform(scheme, vr).Transcribe()
	highlight_line := false
	if b, ok := v.Settings().Get("highlight_line", highlight_line).(bool); ok {
		highlight_line = b
	}
	lastEnd := 0
	for _, reg := range recipie {
		if lastEnd != reg.Region.Begin() {
			io.WriteString(wr, runes[lastEnd:reg.Region.Begin()])
		}
		fmt.Fprintf(wr, "<span style=\"color:#%s; background-color:#%s\">%s</span>", htmlcol(reg.Flavour.Foreground), htmlcol(reg.Flavour.Background), runes[reg.Region.Begin():reg.Region.End()])
		lastEnd = reg.Region.End()
	}
	if lastEnd != vr.End() {
		io.WriteString(wr, v.Buffer().Substr(Region{lastEnd, vr.End()}))
	}
}
開發者ID:Unverified,項目名稱:lime,代碼行數:23,代碼來源:main.go

示例6: renderView

func (t *tbfe) renderView(v *backend.View, lay layout) {
	p := util.Prof.Enter("render")
	defer p.Exit()

	sx, sy, w, h := lay.x, lay.y, lay.width, lay.height
	vr := lay.visible
	runes := v.Buffer().Substr(vr)
	x, y := sx, sy
	ex, ey := sx+w, sy+h

	style, _ := v.Settings().Get("caret_style", "underline").(string)
	inverse, _ := v.Settings().Get("inverse_caret_state", false).(bool)

	caretStyle := getCaretStyle(style, inverse)
	caretBlink, _ := v.Settings().Get("caret_blink", true).(bool)
	if caretBlink && blink {
		caretStyle = 0
	}
	tabSize := 4
	ts := v.Settings().Get("tab_size", tabSize)
	// TODO(.): crikey...
	if i, ok := ts.(int); ok {
		tabSize = i
	} else if f, ok := ts.(float64); ok {
		tabSize = int(f)
	}

	lineNumbers, _ := v.Settings().Get("line_numbers", true).(bool)

	recipie := v.Transform(scheme, vr).Transcribe()

	fg, bg := defaultFg, defaultBg
	sel := v.Sel()

	line, _ := v.Buffer().RowCol(vr.Begin())
	eofline, _ := v.Buffer().RowCol(v.Buffer().Size())
	lineNumberRenderSize := len(intToRunes(eofline))

	for i, r := range runes {
		o := vr.Begin() + i
		curr := 0
		fg, bg = defaultFg, defaultBg

		if lineNumbers {
			renderLineNumber(&line, &x, y, lineNumberRenderSize, fg, bg)
		}

		for curr < len(recipie) && (o >= recipie[curr].Region.Begin()) {
			if o < recipie[curr].Region.End() {
				fg = palLut(textmate.Color(recipie[curr].Flavour.Foreground))
				bg = palLut(textmate.Color(recipie[curr].Flavour.Background))
			}
			curr++
		}
		iscursor := sel.Contains(Region{o, o})
		if iscursor {
			fg = fg | caretStyle
			termbox.SetCell(x, y, ' ', fg, bg)
		}
		if r == '\t' {
			add := (x + 1 + (tabSize - 1)) &^ (tabSize - 1)
			for x < add {
				if x < ex {
					termbox.SetCell(x, y, ' ', fg, bg)
				}
				// A long cursor looks weird
				fg = fg & ^(termbox.AttrUnderline | termbox.AttrReverse)
				x++
			}
			continue
		} else if r == '\n' {
			x = sx
			if y++; y > ey {
				break
			} else if lineNumbers {
				renderLineNumber(&line, &x, y, lineNumberRenderSize, fg, bg)
			}
			continue
		}
		if x < ex {
			termbox.SetCell(x, y, r, fg, bg)
		}
		x++
	}
	fg, bg = defaultFg, defaultBg
	// Need this if the cursor is at the end of the buffer
	o := vr.Begin() + len(runes)
	iscursor := sel.Contains(Region{o, o})
	if iscursor {
		fg = fg | caretStyle
		termbox.SetCell(x, y, ' ', fg, bg)
	}

	// restore original caretStyle before blink modification
	caretStyle = caretStyle
}
開發者ID:ericcapricorn,項目名稱:lime,代碼行數:96,代碼來源:main.go

示例7: renderView

func (t *tbfe) renderView(v *backend.View, lay layout) {
	p := util.Prof.Enter("render")
	defer p.Exit()

	sx, sy, w, h := lay.x, lay.y, lay.width, lay.height
	vr := lay.visible
	runes := v.Buffer().Substr(vr)
	x, y := sx, sy
	ex, ey := sx+w, sy+h

	style, _ := v.Settings().Get("caret_style", "underline").(string)
	inverse, _ := v.Settings().Get("inverse_caret_state", false).(bool)

	caretStyle := getCaretStyle(style, inverse)
	oldCaretStyle := caretStyle

	caretBlink, _ := v.Settings().Get("caret_blink", true).(bool)
	if caretBlink && blink {
		caretStyle = 0
	}

	tabSize := 4
	if i, ok := v.Settings().Get("tab_size", tabSize).(int); ok {
		tabSize = i
	}

	lineNumbers, _ := v.Settings().Get("line_numbers", true).(bool)

	recipie := v.Transform(scheme, vr).Transcribe()

	fg, bg := defaultFg, defaultBg
	sel := v.Sel()

	line, _ := v.Buffer().RowCol(vr.Begin())
	eofline, _ := v.Buffer().RowCol(v.Buffer().Size())
	lineNumberRenderSize := len(intToRunes(eofline))

	for i, r := range runes {
		o := vr.Begin() + i
		curr := 0
		fg, bg = defaultFg, defaultBg

		if lineNumbers {
			renderLineNumber(&line, &x, y, lineNumberRenderSize, fg, bg)
		}

		// TODO: doc
		for curr < len(recipie) && (o >= recipie[curr].Region.Begin()) {
			if o < recipie[curr].Region.End() {
				fg = palLut(textmate.Color(recipie[curr].Flavour.Foreground))
				bg = palLut(textmate.Color(recipie[curr].Flavour.Background))
			}
			curr++
		}

		iscursor := sel.Contains(Region{o, o})
		if iscursor {
			fg = fg | caretStyle
			termbox.SetCell(x, y, ' ', fg, bg)
		}

		if r == '\t' {
			add := (x + 1 + (tabSize - 1)) &^ (tabSize - 1)
			for ; x < add; x++ {
				if x < ex {
					termbox.SetCell(x, y, ' ', fg, bg)
				}
				// A long cursor looks weird
				fg = fg & ^(termbox.AttrUnderline | termbox.AttrReverse)
			}
			continue
		} else if r == '\n' {
			x = sx
			if y++; y > ey {
				break
			} else if lineNumbers {
				// This results in additional calls to renderLineNumber.
				// Maybe just accumulate positions needing line numbers, rendering them
				// after the loop?
				renderLineNumber(&line, &x, y, lineNumberRenderSize, defaultFg, defaultBg)
			}
			continue
		}
		if x < ex {
			termbox.SetCell(x, y, r, fg, bg)
		}
		x++
	}
	fg, bg = defaultFg, defaultBg
	// Need this if the cursor is at the end of the buffer
	o := vr.Begin() + len(runes)
	iscursor := sel.Contains(Region{o, o})
	if iscursor {
		fg = fg | caretStyle
		termbox.SetCell(x, y, ' ', fg, bg)
	}

	// restore original caretStyle before blink modification
	caretStyle = oldCaretStyle

//.........這裏部分代碼省略.........
開發者ID:hanshenu,項目名稱:lime,代碼行數:101,代碼來源:main.go

示例8: getSettings

func getSettings(v *backend.View) *FrontendSettings {
	style, _ := v.Settings().Get("caret_style", "underline").(string)
	inverse, _ := v.Settings().Get("inverse_caret_state", false).(bool)

	return &FrontendSettings{
		v.Settings().Get("tab_size", 4).(int),
		v.Settings().Get("caret_blink", true).(bool),
		v.Settings().Get("highlight_line", false).(bool),
		getCaretStyle(style, inverse),
		v.Settings().Get("line_numbers", true).(bool),
	}
}
開發者ID:woldan,項目名稱:lime,代碼行數:12,代碼來源:main.go


注:本文中的github.com/limetext/lime/backend.View.Settings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。