node/lib/metasm/metasm/gui/dasm_main.rb
def prompt_c_struct(prompt, opts={})
		inputbox(prompt, opts) { |st_name|
			stars = ''
			if opts[:allow_stars]
				stars = st_name[/\**$/]
				st_name[stars] = ''
			end

			# TODO propose typedef struct {} moo; too
			sh = @dasm.c_parser.toplevel.struct
			if sh[st_name].kind_of?(C::Union)
				stn_list = [st_name]
			else
				stn_list = sh.keys.grep(String).find_all { |k| sh[k].kind_of?(C::Union) }
			end

			if name = stn_list.find { |n| n == st_name } || stn_list.find { |n| n.downcase == st_name.downcase }
				# single match
				yield(name+stars)
			else
				# try autocomplete
				list = [['name']]
				list += stn_list.sort.grep(/#{st_name}/i).map { |stn| [stn+stars] }
				if list.length == 2
					# single autocompletion
					yield(list[1][0])
				else
					listwindow(prompt, list) { |ans|
						yield(ans[0])
					}
				end
			end
		}
	end
# prompts for a structure name, autocompletes to known structures, and/or display a listwindow with
# possible completions, yields the target structure name
prompts for a structure name, autocompletes to known structures, and/or display a listwindow with
possible completions, yields the target structure name
prompts for a structure name autocompletes to known structures and / or display a listwindow with possible completions yields the target structure name
def prompt_c_struct(prompt, opts={})
		inputbox(prompt, opts) { |st_name|
			stars = ''
			if opts[:allow_stars]
				stars = st_name[/\**$/]
				st_name[stars] = ''
			end
			sh = @dasm.c_parser.toplevel.struct
			if sh[st_name].kind_of?(C::Union)
				stn_list = [st_name]
			else
				stn_list = sh.keys.grep(String).find_all { |k| sh[k].kind_of?(C::Union) }
			end
			if name = stn_list.find { |n| n == st_name } || stn_list.find { |n| n.downcase == st_name.downcase }
				yield(name+stars)
			else
				list = [['name']]
				list += stn_list.sort.grep(/#{st_name}/i).map { |stn| [stn+stars] }
				if list.length == 2
					yield(list[1][0])
				else
					listwindow(prompt, list) { |ans|
						yield(ans[0])
					}
				end
			end
		}
	end
def prompt_c_struct ( prompt , opts = { } ) inputbox ( prompt , opts ) { | st_name | stars = '' if opts [ :allow_stars ] stars = st_name [ / \* *$ / ] st_name [ stars ] = '' end sh = @dasm . c_parser . toplevel . struct if sh [ st_name ] . kind_of? ( C :: Union ) stn_list = [ st_name ] else stn_list = sh . keys . grep ( String ) . find_all { | k | sh [ k ] . kind_of? ( C :: Union ) } end if name = stn_list . find { | n | n == st_name } || stn_list . find { | n | n . downcase == st_name . downcase } yield ( name + stars ) else list = [ [ 'name' ] ] list += stn_list . sort . grep ( / #{ st_name } /i ) . map { | stn | [ stn + stars ] } if list . length == 2 yield ( list [ 1 ] [ 0 ] ) else listwindow ( prompt , list ) { | ans | yield ( ans [ 0 ] ) } end end } end
prompts for a structure name, autocompletes to known structures, and/or display a listwindow with
possible completions, yields the target structure name
prompts for a structure name autocompletes to known structures and / or display a listwindow with possible completions yields the target structure name
# TODO propose typedef struct {} moo; too # single match # try autocomplete # single autocompletion
prompt
opts