1
/*=========================================================================
3
Program: CMake - Cross-Platform Makefile Generator
4
Module: $RCSfile: cmCursesPathWidget.cxx,v $
6
Date: $Date: 2003/12/15 22:26:00 $
7
Version: $Revision: 1.9 $
9
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12
This software is distributed WITHOUT ANY WARRANTY; without even
13
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
PURPOSE. See the above copyright notices for more information.
16
=========================================================================*/
1
17
#include "cmCursesPathWidget.h"
19
#include "cmCursesMainForm.h"
20
#include "cmSystemTools.h"
3
22
cmCursesPathWidget::cmCursesPathWidget(int width, int height,
5
24
cmCursesStringWidget(width, height, left, top)
7
26
m_Type = cmCacheManager::PATH;
31
void cmCursesPathWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW* w)
36
this->cmCursesStringWidget::OnType(key, fm, w);
39
void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
41
if ( !this->GetString() )
45
FORM* form = fm->GetForm();
46
form_driver(form, REQ_NEXT_FIELD);
47
form_driver(form, REQ_PREV_FIELD);
48
std::string cstr = this->GetString();
49
cstr = cstr.substr(0, cstr.find_last_not_of(" \t\n\r")+1);
50
if ( m_LastString != cstr )
65
std::vector<cmStdString> dirs;
67
cmSystemTools::SimpleGlob(glob.c_str(), dirs, (m_Type == cmCacheManager::PATH?-1:0));
68
if ( m_CurrentIndex < dirs.size() )
70
cstr = dirs[m_CurrentIndex];
72
if ( cstr[cstr.size()-1] == '*' )
74
cstr = cstr.substr(0, cstr.size()-1);
77
if ( cmSystemTools::FileIsDirectory(cstr.c_str()) )
82
this->SetString(cstr.c_str());
85
form_driver(form, REQ_END_FIELD);
90
if ( m_CurrentIndex >= dirs.size() )
96
void cmCursesPathWidget::OnReturn(cmCursesMainForm* fm, WINDOW* w)
98
this->cmCursesStringWidget::OnReturn(fm, w);