Esempio n. 1
0
File: lang.go Progetto: udhos/tabby
func init_lang() {
	lang_man := gtksourceview.SourceLanguageManagerGetDefault()
	lang_map = make(map[string]*gtksourceview.SourceLanguage)
	lang_map["go"] = lang_man.GetLanguage("go")
	lang_map["c"] = lang_man.GetLanguage("c")
	lang_map["h"] = lang_man.GetLanguage("cpp")
	lang_map["sh"] = lang_man.GetLanguage("sh")
	lang_map["diff"] = lang_man.GetLanguage("diff")
	lang_map["patch"] = lang_man.GetLanguage("diff")
	lang_map["cpp"] = lang_man.GetLanguage("cpp")
	lang_map["hpp"] = lang_man.GetLanguage("cpp")
	lang_map["cc"] = lang_man.GetLanguage("cpp")
	lang_map["latex"] = lang_man.GetLanguage("latex")
	lang_map["tex"] = lang_man.GetLanguage("latex")
	lang_map["Makefile"] = lang_man.GetLanguage("makefile")
	lang_map["am"] = lang_man.GetLanguage("makefile")
	lang_map["in"] = lang_man.GetLanguage("makefile")
	lang_map["xml"] = lang_man.GetLanguage("xml")
	lang_map["py"] = lang_man.GetLanguage("python")
	lang_map["scons"] = lang_man.GetLanguage("python")
	lang_map["SConstruct"] = lang_man.GetLanguage("python")
	lang_map["java"] = lang_man.GetLanguage("java")

	lang_map["default"] = lang_man.GetLanguage("sh")

	source_buf.SetLanguage(lang_map["default"])
}
Esempio n. 2
0
func main() {
	gtk.Init(&os.Args)
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
	window.SetTitle("SourceView")
	window.Connect("destroy", gtk.MainQuit)

	swin := gtk.ScrolledWindow(nil, nil)
	swin.SetPolicy(gtk.GTK_POLICY_AUTOMATIC, gtk.GTK_POLICY_AUTOMATIC)
	swin.SetShadowType(gtk.GTK_SHADOW_IN)
	sourcebuffer := gsv.SourceBufferWithLanguage(gsv.SourceLanguageManagerGetDefault().GetLanguage("cpp"))
	sourceview := gsv.SourceViewWithBuffer(sourcebuffer)

	var start gtk.GtkTextIter
	sourcebuffer.GetStartIter(&start)
	sourcebuffer.BeginNotUndoableAction()
	sourcebuffer.Insert(&start, `#include <iostream>
template<class T>
struct foo_base {
  T operator+(T const &rhs) const {
    T tmp(static_cast<T const &>(*this));
    tmp += rhs;
    return tmp;
  }
};

class foo : public foo_base<foo> {
private:
  int v;
public:
  foo(int v) : v(v) {}
  foo &operator+=(foo const &rhs){
    this->v += rhs.v;
    return *this;
  }
  operator int() { return v; }
};

int main(void) {
  foo a(1), b(2);
  a += b;
  std::cout << (int)a << std::endl;
}
`)
	sourcebuffer.EndNotUndoableAction()

	swin.Add(sourceview)

	window.Add(swin)
	window.SetSizeRequest(400, 300)
	window.ShowAll()

	gtk.Main()
}
Esempio n. 3
0
func main() {

	gtk.Init(&os.Args)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("µemacs/pp")
	window.Connect("destroy", gtk.MainQuit)
	window.Connect("key-press-event", handleKeyPress)

	SetKeyReturn(kh.GTKKeyPressEvent{gdk.KEY_Return, 0})

	swin := gtk.NewScrolledWindow(nil, nil)
	sourcebuffer := gsv.NewSourceBufferWithLanguage(gsv.SourceLanguageManagerGetDefault().GetLanguage("cpp"))
	sourceview = gsv.NewSourceViewWithBuffer(sourcebuffer)

	var start gtk.TextIter
	sourcebuffer.GetStartIter(&start)
	sourcebuffer.Insert(&start, `writing stuff, awww yea!`)

	textview = gtk.NewTextView()
	textbuffer = textview.GetBuffer()

	var bufiter gtk.TextIter
	sourcebuffer.GetStartIter(&bufiter)
	bufWrapper := ed.GtkTextBufferReadWriter{&sourceview.TextView.Container.Widget, bufiter, &sourcebuffer.TextBuffer}
	var comiter gtk.TextIter
	textbuffer.GetStartIter(&comiter)
	comWrapper := ed.GtkTextBufferReadWriter{&textview.Container.Widget, comiter, textbuffer}
	microemacs = editor.Editor{"", &bufWrapper, &comWrapper}

	vbox := gtk.NewVBox(false, 0)
	vbox.PackStart(swin, true, true, 0)
	vbox.PackEnd(textview, false, true, 0)

	swin.Add(sourceview)

	window.Add(vbox)
	window.SetSizeRequest(300, 300)
	window.ShowAll()

	gtk.Main()
}