示例#1
0
文件: navigation.go 项目: mattn/tabby
func mark_set_cb() {
	var cur gtk.GtkTextIter
	var be, en gtk.GtkTextIter

	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)
	}
}
示例#2
0
文件: navigation.go 项目: mattn/tabby
func find_next_instance(start, be, en *gtk.GtkTextIter, 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
0
func fnr_find_next(pattern string, global bool, map_filled *bool, m *map[string]int) bool {
	var be, en, scope_en gtk.GtkTextIter
	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
}