/* Returns string representation of file type. */ static var_t filetype_builtin(const call_info_t *call_info) { char *str_val = var_to_string(call_info->argv[0]); const int fnum = get_fnum(str_val); var_val_t var_val = { .string = "" }; free(str_val); if(fnum >= 0) { #ifndef _WIN32 const mode_t mode = curr_view->dir_entry[fnum].mode; var_val.const_string = get_mode_str(mode); #else const FileType type = curr_view->dir_entry[fnum].type; var_val.const_string = get_type_str(type); #endif } return var_new(VTYPE_STRING, var_val); } /* Returns file type from position or -1 if the position has wrong value. */ static int get_fnum(const char position[]) { if(strcmp(position, ".") == 0) { return curr_view->list_pos; } else { return -1; } }
/* Gets string representation of file type. Returns the string. */ static var_t filetype_builtin(const call_info_t *call_info) { char *str_val = var_to_string(call_info->argv[0]); const int fnum = get_fnum(str_val); var_val_t var_val = { .string = "" }; free(str_val); if(fnum >= 0) { const FileType type = curr_view->dir_entry[fnum].type; var_val.const_string = get_type_str(type); } return var_new(VTYPE_STRING, var_val); } /* Returns file type from position or -1 if the position has wrong value. */ static int get_fnum(const char position[]) { if(strcmp(position, ".") == 0) { return curr_view->list_pos; } return -1; } /* Retrieves type of current pane as a string. */ static var_t getpanetype_builtin(const call_info_t *call_info) { FileView *const view = curr_view; var_val_t var_val; if(flist_custom_active(view)) { var_val.string = (view->custom.unsorted ? "very-custom" : "custom"); } else { var_val.string = "regular"; } return var_new(VTYPE_STRING, var_val); }
/* Gets string representation of file type. Returns the string. */ static var_t filetype_builtin(const call_info_t *call_info) { char *str_val = var_to_string(call_info->argv[0]); const int fnum = get_fnum(str_val); var_val_t var_val = { .string = "" }; free(str_val); if(fnum >= 0) { const FileType type = curr_view->dir_entry[fnum].type; var_val.const_string = get_type_str(type); } return var_new(VTYPE_STRING, var_val); } /* Returns file type from position or -1 if the position has wrong value. */ static int get_fnum(const char position[]) { if(strcmp(position, ".") == 0) { return curr_view->list_pos; } else { return -1; } } /* Checks current layout configuration. Returns boolean value that reflects * state of specified layout type. */ static var_t layoutis_builtin(const call_info_t *call_info) { char *type; int result; type = var_to_string(call_info->argv[0]); if(strcmp(type, "only") == 0) { result = (curr_stats.number_of_windows == 1); } else if(strcmp(type, "split") == 0) { result = (curr_stats.number_of_windows == 2); } else if(strcmp(type, "vsplit") == 0) { result = (curr_stats.number_of_windows == 2 && curr_stats.split == VSPLIT); } else if(strcmp(type, "hsplit") == 0) { result = (curr_stats.number_of_windows == 2 && curr_stats.split == HSPLIT); } else { result = 0; } free(type); return var_from_bool(result); }