[syslinux] [RFC][PATCH] ui: label completion on tab key

Sebastian Herbszt herbszt at gmx.de
Sun Aug 31 14:31:03 PDT 2008


This implements the label completion on tab key idea. It does introduce
"labelcompl" as new config keyword. The default value is 0 so it does not
change current behaviour.
If you press tab with an empty command line it will display all labels. If the
command line contains any characters it will display the matching labels.

This patch is only intended for testing since i didn't check if it doesn't
clobber required registers. Works for me with syslinux. Feedback welcome.

- Sebastian

Index: syslinux-3.71-27-g3d39943/core/ui.inc
===================================================================
--- syslinux-3.71-27-g3d39943.orig/core/ui.inc	2008-08-31 22:45:26.000000000 +0200
+++ syslinux-3.71-27-g3d39943/core/ui.inc	2008-08-31 22:51:44.000000000 +0200
@@ -108,6 +108,8 @@
 not_ascii:
 		cmp al,0Dh			; Enter
 		je command_done
+		cmp al,09h			; Tab
+		je display_labels
 		cmp al,'F' & 1Fh		; <Ctrl-F>
 		je set_func_flag
 %if IS_PXELINUX
@@ -142,6 +144,48 @@
 		mov byte [FuncFlag],1
 		jmp short get_char_2
 
+display_labels:
+		cmp word [LabelCompl],1		; Label completion enabled?
+		jnz get_char_2
+		mov cx,di
+		sub cx,command_line
+		call crlf
+		mov esi,[HighMemSize]		; Start from top of memory
+.scan:
+		cmp esi,[VKernelEnd]
+		jbe .not_vk
+
+		push cx				; save command line size
+
+		mov di,VKernelBuf
+		call rllunpack
+		; ESI updated on return
+
+		sub di,cx			; Return to beginning of buf
+		pop cx				; restore command line size
+		push si				; save SI
+		cmp cx,0
+		jz .print
+		push di
+		push cx
+		mov si,command_line
+		es repe cmpsb
+		pop cx
+		pop di
+		jne .next
+.print:
+		mov al,' '
+		call writechr
+
+		mov si,di
+		call writestr
+.next:
+		pop si				; restore SI
+		jmp .scan
+.not_vk:
+		call crlf
+		jmp enter_command
+
 ctrl_f:
 		xor ah,ah
 		mov [FuncFlag],ah
Index: syslinux-3.71-27-g3d39943/core/keywords
===================================================================
--- syslinux-3.71-27-g3d39943.orig/core/keywords	2008-08-31 22:45:26.000000000 +0200
+++ syslinux-3.71-27-g3d39943/core/keywords	2008-08-31 22:45:28.000000000 +0200
@@ -30,6 +30,7 @@
 ontimeout
 onerror
 noescape
+labelcompl
 f0
 f1
 f2
Index: syslinux-3.71-27-g3d39943/core/keywords.inc
===================================================================
--- syslinux-3.71-27-g3d39943.orig/core/keywords.inc	2008-08-31 22:45:26.000000000 +0200
+++ syslinux-3.71-27-g3d39943/core/keywords.inc	2008-08-31 22:45:28.000000000 +0200
@@ -75,6 +75,7 @@
 		keyword onerror,	pc_onerror
 		keyword allowoptions,	pc_setint16,	AllowOptions
 		keyword noescape,	pc_setint16,	NoEscape
+		keyword labelcompl,	pc_setint16,	LabelCompl
 		keyword f1,		pc_filename,	FKeyN(1)
 		keyword f2,		pc_filename,	FKeyN(2)
 		keyword f3,		pc_filename,	FKeyN(3)
Index: syslinux-3.71-27-g3d39943/core/parseconfig.inc
===================================================================
--- syslinux-3.71-27-g3d39943.orig/core/parseconfig.inc	2008-08-31 22:45:26.000000000 +0200
+++ syslinux-3.71-27-g3d39943/core/parseconfig.inc	2008-08-31 22:45:28.000000000 +0200
@@ -463,6 +463,7 @@
 CmdLinePtr	dw cmd_line_here	; Command line advancing pointer
 ForcePrompt	dw 0			; Force prompt
 NoEscape	dw 0			; No escape
+LabelCompl	dw 0			; Label completion on TAB key
 AllowImplicit   dw 1                    ; Allow implicit kernels
 AllowOptions	dw 1			; User-specified options allowed




More information about the Syslinux mailing list