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


Golang store.Store類代碼示例

本文整理匯總了Golang中github.com/elves/elvish/store.Store的典型用法代碼示例。如果您正苦於以下問題:Golang Store類的具體用法?Golang Store怎麽用?Golang Store使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: NewEditor

// NewEditor creates an Editor.
func NewEditor(file *os.File, sigs chan os.Signal, ev *eval.Evaler, st *store.Store) *Editor {
	seq := -1
	if st != nil {
		var err error
		seq, err = st.NextCmdSeq()
		if err != nil {
			// TODO(xiaq): Also report the error
			seq = -1
		}
	}

	prompt, rprompt := defaultPrompts()

	ed := &Editor{
		file:   file,
		writer: newWriter(file),
		reader: NewReader(file),
		sigs:   sigs,
		store:  st,
		evaler: ev,
		cmdSeq: seq,
		ps1:    eval.NewPtrVariableWithValidator(prompt, MustBeFn),
		rps1:   eval.NewPtrVariableWithValidator(rprompt, MustBeFn),

		abbreviations: make(map[string]string),
		beforeReadLine: eval.NewPtrVariableWithValidator(
			eval.NewList(), eval.IsListOfFnValue),
		afterReadLine: eval.NewPtrVariableWithValidator(
			eval.NewList(), eval.IsListOfFnValue),
	}
	ev.Editor = ed
	ev.Modules["le"] = makeModule(ed)
	return ed
}
開發者ID:elves,項目名稱:elvish,代碼行數:35,代碼來源:editor.go

示例2: newHistoryListing

func newHistoryListing(s *store.Store) (*historyListing, error) {
	seq, err := s.NextCmdSeq()
	if err != nil {
		return nil, err
	}
	cmds, err := s.Cmds(seq-100, seq)
	if err != nil {
		return nil, err
	}
	return &historyListing{cmds}, nil
}
開發者ID:wanlanjian,項目名稱:elvish,代碼行數:11,代碼來源:historyListing.go

示例3: newLocation

func newLocation(s *store.Store) (*location, error) {
	if s == nil {
		return nil, ErrStoreOffline
	}
	all, err := s.ListDirs()
	if err != nil {
		return nil, err
	}

	loc := &location{all: all}
	loc.listing = newListing(modeLocation, loc)
	return loc, nil
}
開發者ID:zhsj,項目名稱:elvish,代碼行數:13,代碼來源:location.go

示例4: NewEditor

// NewEditor creates an Editor.
func NewEditor(file *os.File, sigs <-chan os.Signal, st *store.Store) *Editor {
	seq := -1
	if st != nil {
		var err error
		seq, err = st.NextCmdSeq()
		if err != nil {
			// TODO(xiaq): Also report the error
			seq = -1
		}
	}

	return &Editor{
		file:   file,
		writer: newWriter(file),
		reader: NewReader(file),
		sigs:   sigs,
		store:  st,
		cmdSeq: seq,
	}
}
開發者ID:fionser,項目名稱:elvish,代碼行數:21,代碼來源:editor.go

示例5: newHistlist

func newHistlist(s *store.Store) (*histlist, error) {
	if s == nil {
		return nil, ErrStoreOffline
	}
	seq, err := s.NextCmdSeq()
	if err != nil {
		return nil, err
	}
	all, err := s.Cmds(0, seq)
	if err != nil {
		return nil, err
	}
	last := make(map[string]int)
	for i, entry := range all {
		last[entry] = i
	}
	hl := &histlist{all: all, last: last, indexWidth: len(strconv.Itoa(len(all) - 1))}
	hl.listing = newListing(modeHistoryListing, hl)
	return hl, nil
}
開發者ID:zhsj,項目名稱:elvish,代碼行數:20,代碼來源:histlist.go

示例6: NewEditor

// NewEditor creates an Editor.
func NewEditor(file *os.File, sigs chan os.Signal, ev *eval.Evaler, st *store.Store) *Editor {
	seq := -1
	if st != nil {
		var err error
		seq, err = st.NextCmdSeq()
		if err != nil {
			// TODO(xiaq): Also report the error
			seq = -1
		}
	}

	ed := &Editor{
		file:   file,
		writer: newWriter(file),
		reader: NewReader(file),
		sigs:   sigs,
		store:  st,
		evaler: ev,
		cmdSeq: seq,
	}
	ev.Editor = ed
	return ed
}
開發者ID:rathinaganesh,項目名稱:elvish,代碼行數:24,代碼來源:editor.go


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