まとめました

補完リストとマルチラインechoの 保守が 大変なこともあってまとめました。
あと、大分すっきりさせました。

  • tooltip モードを廃止
  • useDummyAction を 廃止(anekosさんからもっと良い方法を教えていただきました)
  • useResize を 廃止 delayResize を 負の値で無効に変更
  • useWinGlass を 廃止(スタイルシートで変更して下さい)
  • 表示方法を共通化
  • アンカーのクリックを暫定実装
  • standard(デフォルト0)を追加(後述)
  • pMode(デフォルト BOTH)を追加(後述)
standard

nokturnalmortum さんから 指摘があったので、
0 で 両方 重なって表示
1 で 2.3 っぽく表示
となるように変更しました。

pMode

PANEL_MODE.MULTILINE で マルチラインecho のみ 対象
PANEL_MODE.COMPLETE で 補完リスト のみ 対象
PANEL_MODE.BOTH で 両方 対象

問題
  • キーが上手く動かないことがあるみたいです(再現手順があるとありがたいです)
  • アンカーのミドルクリックが使えない
  • アンカークリックで少しフォーカスの奪い合いする


なお、激しいフォーカスの奪い合いは
80行目(e.blur())を削除して


:tabopen a
:tabopen b
:buffer


で 上から 1つづつ順にアンカーをクリックすると確認できると思います。


// vim: set fdm=marker :
(function(){
  const PANEL_MODE={
    MULTILINE : 1,
    COMPLETE  : 2,
    BOTH      : 3
  };
	const useOpacity  = 1;
	const standard = 0;
	const pMode = PANEL_MODE.BOTH;

	const minHeight = "1em";
	const delayResize = 100;

	const sid = "liberator-statusline";
	const className = "liberator-overlay-container";

	//{{{ style sheet
	const fboxStyle = liberator.globalVariables.overlayStyle
		|| <>
		-moz-appearance:none;
		background:rgba(0,0,0,0.2);
		-moz-border-radius: 8px;
		padding:0.5em;
		border:none;
	</>;
	// WinGlass
	//<>
	//	background: transparent;
	//	-moz-appearance: -moz-win-glass;
	//	-moz-border-radius: 8px;
	//	padding:0.5em;
	//	border:none;
	//</>
	const iframeStyle = liberator.globalVariables.overlayIframeStyle
		|| <>
      {useOpacity ? <>opacity:0.85;</>:""}
			border:none;
			min-height:{minHeight};
		</>;
	//}}}

	function oneEventListenr(obj, event, usecapture, func){
		let args = [event, function(){
			this.removeEventListener.apply(this, args);
			func.apply(this, arguments);
		},usecapture];
		obj.addEventListener.apply(obj,args);	
	}

	function OverlayPanel(id, initFunc){
		let iframe = document.getElementById(id);
		let vbox = iframe.parentNode;
		let fbox;

		if(standard) fbox = document.querySelector(<>.{className}</>);
		if(!fbox){
			fbox = document.createElement("panel");

			fbox.setAttribute("noautohide", true);
			fbox.setAttribute("style", fboxStyle);
			fbox.classList.add(className);
			fbox.addEventListener("popupshown", function(){
				modes.remove(modes.MENU);
			},false);

			vbox.parentNode.insertBefore(fbox, vbox);
		}

		vbox.removeChild(iframe);

		const url = iframe.getAttribute("src");
		const onclick = iframe.getAttribute("onclick");
		iframe = document.createElementNS(XHTML,"iframe");
		iframe.setAttribute("id", id);
		iframe.setAttribute("style", iframeStyle);
		iframe.setAttribute("flex",1);
		iframe.setAttribute("onclick", <>
			var e = liberator.focus;
			if(e.ownerDocument === this.contentDocument) e.blur();
			{onclick};
		</>);

		vbox.appendChild(iframe);
		fbox.appendChild(vbox);

		let activeTimer = 0;
		function updateCollapsed(newValue){
			try{
			if(newValue) fbox.hidePopup();
			else{
				if(fbox.state === "open") return;
				activeTimer && window.clearTimeout(activeTimer);
				activeTimer = window.setTimeout(function(){
					activeTimer = 0;
					fbox.sizeTo(window.innerWidth, -1);
					fbox.openPopup(document.getElementById(sid), "before_start", 0, 0, false, false);
				},0);
			}
			}catch(ex){liberator.echoerr(ex);}
			return newValue;
		}
		vbox.watch("collapsed",function(id, oldValue, newValue) updateCollapsed(newValue));

		oneEventListenr(iframe,"load",true,function(){
			initFunc(id,fbox,vbox,iframe);
		});

		oneEventListenr(fbox,"popupshown",false,function(){
			this.hidePopup();
		});
		fbox.openPopupAtScreen(0,0,false);

		if(delayResize >= 0){
			if(!("activeTimer" in fbox)) fbox.activeTimer = 0;
			window.addEventListener("resize",function resize(event){
				if(vbox.collapsed) return;
				fbox.activeTimer&&window.clearTimeout(fbox.activeTimer);
				fbox.activeTimer = window.setTimeout(function(){
					fbox.activeTimer = 0;
					if(fbox.width == window.innerWidth) return;
					vbox.collapsed = true;
					vbox.collapsed = false;
				},delayResize);
			},false);
		}
		iframe.setAttribute("src",url);
	}

  if(pMode&PANEL_MODE.MULTILINE)
    OverlayPanel("liberator-multiline-output",function(id,fbox,vbox,iframe){
      commandline._multilineOutputWidget = iframe;
      commandline._outputContainer = vbox;
      iframe.contentDocument.body.setAttribute("id", "liberator-multiline-output-content");
    });
  if(pMode&PANEL_MODE.COMPLETE)
    OverlayPanel("liberator-completions",function(id,fbox,vbox,iframe){
      commandline._completionList = ItemList(id);
    });
})(this);

2010/05/12 00:07

よくみたら、standardのデフォルトが0でした…