Plan 9 from Bell Labs’s /usr/web/sources/contrib/nemo/octopus/port/x/xedit.m

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Oxedit: module {
	PATH:	con "/dis/o/xedit.dis";

	Tree: adt {
		tid:	int;			# tree id, never reused.
		path:	string;		# for debug, mostly
		col:	ref Panels->Panel;
		tag:	ref Panels->Panel;
		xtag:	ref Panels->Panel;
		eds:	list of ref Edit;
	
		new:		fn(path: string): ref Tree;
		find:		fn(tid: int):	ref Tree;
		close:	fn(t: self ref Tree);
		mk:		fn(ed: self ref Tree);

		findedit:	fn(t: self ref Tree, path: string): ref Edit;
		addedit:	fn(t: self ref Tree, ed: ref Edit);
		deledit: 	fn(t: self ref Tree, ed: ref Edit);
		lru:		fn(t: self ref Tree);
		dump:	fn(t: self ref Tree);
	};

	# Elog.typex
	Empty: con 0;
	Null : con '-';
	Delete : con 'd';
	Insert : con 'i';
	Replace: con 'r';
	Filename : con 'f';

	# support for sam
	Elog: adt{
		typex: int;		# Delete, Insert, Filename
		q0: int;		# location of change (unused in f)
		nd: int;		# number of deleted characters
		r: string;
	};

	# support for sam
	Elogbuf: adt {
		b:	array of ref Elog;
		n:	int;

		new:		fn(): ref Elogbuf;
		push:	fn(e: self ref Elogbuf, b: ref Elog);
		pop:		fn(e: self ref Elogbuf): ref Elog;
	};

	# Edit.edited
	Esel, Etext:	con 1<<iota;

	Edit: adt {
		path:		string;	# file path or window name
		dir:		string;		# for look/exec
		tid:		int;		# tree id
		keep:	int;		# do not auto-collect
		dirty:		int;		# changes made. (Dirs are never dirty)
		lru:		int;		# time of last lookup
		tag:		ref Panels->Panel;
		body:	ref Panels->Panel;
		col:		ref Panels->Panel;

		# support for sam command language
		elog:		ref Elog;
		elogbuf:	ref Elogbuf;
		buf:		ref Tblks->Blks;	# with edited file text
		edited:	int;				# Esel|Etext according to what changed
		q0:		int;
		q1:		int;

		pick {
		File =>
			qid:	Sys->Qid;
			lastcmd:	string;
		Msg =>
		Dir =>
			qid:	Sys->Qid;		# for dir
		}
	
		new:		fn(name: string, tid: int, msg: int): ref Edit;
		close:	fn(t: self ref Edit);
		mk:		fn(ed: self ref Edit);
		get:		fn(ed: self ref Edit): int;
		put:		fn(ed: self ref Edit, where: string): int;
		cleanto:	fn(ed: self ref Edit, cmd: string, arg: string): string;
		text:		fn(ed: self ref Edit): string;

		# support for sam
		getedits:	fn(ed: self ref Edit);
		clredits:	fn(ed: self ref Edit);
		putedits:	fn(ed: self ref Edit);
	};

	init:		fn(d: Oxdat);
	findpanel:	fn(id: int): (ref Tree, ref Edit);

	trees:	list of ref Tree;
	ui:		ref Panels->Panel;
	seled:	ref Edit;			# last edit selected/in use
	debug:	int;

};

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].