本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.TextIter类的典型用法代码示例。如果您正苦于以下问题:Golang TextIter类的具体用法?Golang TextIter怎么用?Golang TextIter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextIter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: find_prev_instance
func find_prev_instance(start, be, en *gtk.TextIter, pattern string) bool {
if start.BackwardSearch(pattern, 0, be, en, nil) {
return true
}
source_buf.GetEndIter(be)
return be.BackwardSearch(pattern, 0, be, en, nil)
}
示例2: find_next_instance
func find_next_instance(start, be, en *gtk.TextIter, pattern string) bool {
if start.ForwardSearch(pattern, 0, be, en, nil) {
return true
}
source_buf.GetStartIter(be)
return be.ForwardSearch(pattern, 0, be, en, nil)
}
示例3: mark_set_cb
func mark_set_cb() {
var cur gtk.TextIter
var be, en gtk.TextIter
source_buf.GetSelectionBounds(&be, &en)
selection := source_buf.GetSlice(&be, &en, false)
if prev_selection == selection {
return
}
prev_selection = selection
if selection_flag {
source_buf.GetStartIter(&be)
source_buf.GetEndIter(&en)
source_buf.RemoveTagByName("instance", &be, &en)
selection_flag = false
}
sel_len := len(selection)
if (sel_len <= 1) || (sel_len >= MAX_SEL_LEN) {
return
} else {
selection_flag = true
}
source_buf.GetStartIter(&cur)
for cur.ForwardSearch(selection, 0, &be, &cur, nil) {
source_buf.ApplyTagByName("instance", &be, &cur)
}
}
示例4: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.SetIconName("textview")
window.Connect("destroy", gtk.MainQuit)
textview := gtk.NewTextView()
textview.SetEditable(true)
textview.SetCursorVisible(true)
var iter gtk.TextIter
buffer := textview.GetBuffer()
buffer.GetStartIter(&iter)
buffer.Insert(&iter, "Hello ")
tag := buffer.CreateTag("bold", map[string]string{"background": "#FF0000", "weight": "700"})
buffer.InsertWithTag(&iter, "Google!", tag)
u := "http://www.google.com"
tag.SetData("tag-name", unsafe.Pointer(&u))
textview.Connect("event-after", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
if ev := *(**gdk.EventAny)(unsafe.Pointer(&arg)); ev.Type != gdk.BUTTON_RELEASE {
return
}
ev := *(**gdk.EventButton)(unsafe.Pointer(&arg))
var iter gtk.TextIter
textview.GetIterAtLocation(&iter, int(ev.X), int(ev.Y))
tags := iter.GetTags()
for n := uint(0); n < tags.Length(); n++ {
vv := tags.NthData(n)
tag := gtk.NewTextTagFromPointer(vv)
u := *(*string)(tag.GetData("tag-name"))
fmt.Println(u)
}
})
window.Add(textview)
window.SetSizeRequest(600, 600)
window.ShowAll()
gtk.Main()
}
示例5: gofmt
func gofmt(file string) {
rec, _ := file_map[file]
var buf []byte
if file == cur_file {
buf = []byte(get_source())
} else {
buf = rec.buf
}
bin := os.Getenv("GOBIN")
if bin != "" {
bin = filepath.Join(bin, "gofmt")
} else {
bin, _ = exec.LookPath("gofmt")
}
std, error, e := get_output([]string{bin}, buf)
if e != nil {
tabby_log(e.Error())
return
}
if file == cur_file {
error_buf.SetText(string(error))
} else {
rec.error = error
}
if 0 != len(error) {
return
}
if file == cur_file {
if string(buf) != string(std) {
var be, en gtk.TextIter
source_buf.GetSelectionBounds(&be, &en)
sel_be := be.GetOffset()
source_buf.SetText(string(std))
source_buf.GetIterAtOffset(&be, sel_be)
move_focus_and_selection(&be, &be)
}
} else if string(rec.buf) != string(std) {
rec.buf = std
rec.modified = true
}
}
示例6: fnr_find_next
func fnr_find_next(pattern string, global bool, map_filled *bool, m *map[string]int) bool {
var be, en, scope_en gtk.TextIter
get_iter_at_mark_by_name("fnr_en", &scope_en)
get_iter_at_mark_by_name("selection_bound", &en)
if en.ForwardSearch(pattern, 0, &be, &en, &scope_en) {
move_focus_and_selection(&be, &en)
return true
}
// Have to switch to next file or to beginning of current depending on <global>.
if global {
// Switch to next file.
fnr_find_next_fill_global_map(pattern, m, map_filled)
next_file := pop_string_from_map(m)
if "" == next_file {
return false
}
file_save_current()
file_switch_to(next_file)
fnr_refresh_scope(true)
source_buf.GetStartIter(&be)
source_buf.MoveMarkByName("insert", &be)
source_buf.MoveMarkByName("selection_bound", &be)
return fnr_find_next(pattern, global, map_filled, m)
} else {
// Temporary fix. Is there necessity to search the document all over again?
return false
// Start search from beginning of scope.
// get_iter_at_mark_by_name("fnr_be", &be)
// if be.ForwardSearch(pattern, 0, &be, &en, &scope_en) {
// move_focus_and_selection(&be, &en)
// return true
//} else {
// return false
//}
}
return false
}
示例7: file_save_current
func file_save_current() {
var be, en gtk.TextIter
rec, found := file_map[cur_file]
if false == found {
rec = new(FileRecord)
}
rec.buf = ([]byte)(get_source())
rec.modified = source_buf.GetModified()
source_buf.GetSelectionBounds(&be, &en)
rec.sel_be = be.GetOffset()
rec.sel_en = en.GetOffset()
file_stack_push(cur_file)
if found {
runtime.GC()
}
}